Example of WHILE Loops in an SPL Routine
The following example illustrates the use of WHILE loops
in an SPL routine. In the SPL procedure, simp_while, the first
WHILE loop executes a DELETE statement. The second WHILE loop executes
an INSERT statement and increments the value of an SPL variable.
CREATE PROCEDURE simp_while()
DEFINE i INT;
WHILE EXISTS (SELECT fname FROM customer
WHERE customer_num > 400)
DELETE FROM customer WHERE id_2 = 2;
END WHILE;
LET i = 1;
WHILE i < 10
INSERT INTO tab_2 VALUES (i);
LET i = i + 1;
END WHILE;
END PROCEDURE;