FOR SELECT…DO
Go Up to Procedures and Triggers
Repeats a block or statement for each row retrieved by the SELECT
statement. Available in triggers and stored procedures.
FOR <select_expr> DO <compound_statement>
Argument | Description |
---|---|
<select_expr> |
|
<compound_statement> |
Statement or block executed once for each row retrieved by the |
Description: FOR SELECT
is a loop statement that retrieves the row specified in the <select_expr> and performs the statement or block following DO
for each row retrieved.
The <select_expr> is a normal SELECT
, except the INTO
clause is required and must be the last clause.
Example: The following isql
statement selects department numbers into the local variable, RDNO
, which is then used as an input parameter to the DEPT_BUDGET
procedure:
FOR SELECT DEPT_NO
FROM DEPARTMENT
WHERE HEAD_DEPT = :DNO
INTO :RDNO
DO
BEGIN
EXECUTE PROCEDURE DEPT_BUDGET :RDNO RETURNING_VALUES :SUMB;
TOT = TOT + SUMB;
END