FOR EXECUTE STATEMENT ... DO

Top  Previous  Next

The FOR EXECUTE-statement is a special version of the EXECUTE STATEMENT-statement. It only works with SQL that returns a result set.

 

The INTO clause is mandatory and is followed by a DO-clause followed by a single statement or block statement.

 

Syntax

FOR EXECUTE STATEMENT <string_value_expression>

INTO <variable_list>
DO <compound_statement>

 

This statement will loop the result set and execute the DO-section once for each row, the loop will end when the result set has been exhausted. If no rows are returned, the DO-clause will never be executed.

 

Example

execute udsblock

as

declare ovc2 varchar(128);

declare o1 integer;

begin

  sql = 'select rdb$relation_id, rdb$relation_name from rdb$relations ';

 

  for execute statement sql

  into :o1, :ovc2;

  do begin

   /* display a dialog with the table name */

       GUI.ShowMessage('Table found: ' || :ovc2);

     end;

end