EXECUTE STATEMENT ... AS DATASET

Syntax

execute statement 'select field1 from table1' as dataset dset;

or

stmnt = 'select field1 from table1'; 
execute statement stmnt as dataset dset; 

Example

execute ibeblock
returns (FIRSTNAME varchar(50), LASTNAME varchar(50))
as
begin
 stmnt = 'select FIRSTNAME, LASTNAME from CUSTOMER';
 execute statement stmnt as dataset dset;
 
  iCount = ibec_ds_RecordCount(dset);
  i = 0;
  while (i < iCount) do
  begin
    FIRSTNAME = ibec_trim(ibec_ds_getfield(dset,0));
    LASTNAME = ibec_trim(ibec_ds_getfield(dset,1));
    suspend;
    i = i + 1;
    ibec_ds_Next(dset);
  end;
end