FOR EXECUTE STATEMENT ... DO

Syntax

FOR EXECUTE STATEMENT <select-statement> INTO <var> [, <var> ...]
DO <compound-statement>

<select-statement> ::  = Any SELECT statement.
<var>              ::  = A PSQL variable, optionally preceded by “:”

Example

create procedure DynamicSampleThree
  ( TextField varchar(100),
    TableName varchar(100) )
returns
  ( LongLine varchar(32000) )
 as
 declare variable Chunk varchar(100);
 begin 
   Chunk = '';
   for execute statement
     'select ' || TextField || ' from ' || TableName into :Chunk
   do
     if (Chunk is not null) then
       LongLine = LongLine || Chunk || ' ';
   suspend;
 end

(Source: Firebird 2.1 Language Reference Update, 10 July 2009)

It should be noted that the Firebird 2.0 and IBEBlock statements, FOR EXECUTE STATEMENT … DO, are almost but not totally identical: in the case of IBEBlock it is possible to select into the only variable:

for execute statement 'select field1, field2, field3 ...'
   into :myvar
do
...

In this case it is possible to access selected field values using indices:

myvar[0]
myvar[1]
myvar[2]

or

myvar['FIELD1']
myvar['FIELD2']
myvar['FIELD3']