DELIMITER $$
DROP PROCEDURE IF EXISTS WhileLoopProc$$
CREATE PROCEDURE WhileLoopProc()
BEGIN
DECLARE x INT;
DECLARE str VARCHAR(255);
SET x = 1;
SET str = '';
WHILE x <= 5 DO
SET str = CONCAT(str,x,',');
SET x = x + 1;
END WHILE;
SELECT str;
END$$
DELIMITER ;
DECLARE
@I INT,@J INT,@K INT,@ptrval VARBINARY(16),@com VARCHAR(255)
SELECT @1=650000 SELECT @J=1
WHILE @I<=650020 /* OUTER LOOP
BEGIN
INSERT INTO report_table VALUES(@I,'report')
SELECT @K=MAX(line_num) FROM report_1 WHERE report_num=@1
WHILE @J<=@K /*INNER LOOP
BEGIN
SELECT @ptrval=TEXTPTR(report) FROM report_table WHERE report_num=@I
SELECT @com=(SELECT report FROM report_1 WHERE line_num=@J and report_num=@I)
UPDATETEXT report_table.report @ptrval NULL 0 @com
END
SELECT @com='' SELECT @J=1 SELECT @K=1 SELECT @I=@I+1
END