![]() |
ALLBASE/SQL Reference Manual
> Chapter 12 SQL Statements S - ZWHILE |
|||||||||||||||||||||||
|
ScopeProcedures only SQL SyntaxWHILE Condition DO [Statement; [...]] ENDWHILE; Parameters
Description
AuthorizationAnyone can use the WHILE statement. ExampleCreate and execute a procedure to display all the quantities in the LargeOrders table for a given part:
CREATE PROCEDURE ShowOrders AS
BEGIN
DECLARE Quantity INTEGER;
DECLARE PartName CHAR(16);
DECLARE QtyCursor CURSOR FOR
SELECT PartName, Quantity
FROM LargeOrders;
OPEN QtyCursor;
WHILE ::sqlcode <> 100 DO
FETCH QtyCursor INTO :PartName, :Quantity
PRINT :PartName;
PRINT :Quantity;
ENDWHILE;
CLOSE QtyCursor;
END;
EXECUTE PROCEDURE ShowOrders;
|