Execute statements for each row of a result set.
The result set defined by the query expression is iterated and for each row found the list of procedural-sql-statements in the for body is executed. All columns of the result set are available as variables within the for body. This means that all items in the select list must have a unique name. If a for-name is given, this can be used to qualify variable references within the for body.
The query expression can be a call to a result set procedure in which case the names in as part of the values clause is used as variable names.
For a list of
procedural-sql-statements, see Procedural SQL Statements.
If labels are specified at both the beginning and the end of the
FORstatement, they must be the same.
If a label is specified at the end it must also be specified at the beginning.
The for-name may not be the same as the name of a label for any compound statement within the scope of the for statement.
The body of a
FORstatement is atomic which means that it cannot contain a
FORstatement may be terminated by a
LEAVEstatement using label.
ExamplesFOR SELECT code, country, currency_code FROM countries DO RETURN (code, country, currency_code); END FOR; FOR st AS CALL mimer_store_web.view_basket(session_number) DO IF st.title = 'American splendour' THEN ... ELSE ... END IF; END FOR;
For more information, see the Mimer SQL Programmer's Manual, Iterating through a result set - FOR loop.
Mimer Information Technology AB
Voice: +46 18 780 92 00
Fax: +46 18 780 92 40