Search code examples
firebirdresultsetprocedureexecutesuspend

How to execute procedure returning resultset in Firebird


I have the following table

create table LIST_PIPE_TABLE
(
  ID INT,
  ITEM          VARCHAR(4000),
  IS_FOLDER     VARCHAR(10)
)

with 3 rows of data

insert into LIST_PIPE_TABLE values(1,'Victorias Secret','true')
insert into LIST_PIPE_TABLE values(2,'Porsche','true')
insert into LIST_PIPE_TABLE values(3,'Babbolat','false')

And a stored procedure that should return resultset

CREATE or alter PROCEDURE LIST_PIPE
RETURNS 
(   col1 varchar(4000),
    col2 varchar(10)
)
  AS  
begin
    FOR SELECT ITEM AS ITEM
       ,IS_FOLDER AS IS_FOLDER
      FROM LIST_PIPE_TABLE 
    into :col1, :col2
    do begin       
            suspend;          
     end 
end

When I try to execute it with the following statement

execute procedure LIST_PIPE

the only one top row is returned

COL1              COL2
Victorias Secret  true

Please advise what is wrong about it. How should I execute it to see all 3 rows it is designed to return?


Solution

  • When you have suspend in stored procedure, it is called "selectable stored sprocedure", and as the name says you select from it, so:

    select * from LIST_PIPE