如何在Firebird中执行返回结果集的过程 [英] How to execute procedure returning resultset in Firebird

查看:219
本文介绍了如何在Firebird中执行返回结果集的过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下表

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

具有3行数据

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

仅返回第一行

COL1              COL2
Victorias Secret  true

请告知该怎么了.我应该如何执行它才能查看设计返回的所有3行?

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

推荐答案

在存储过程中有suspend时,它称为可选存储过程",顾名思义,您可以从中选择它,因此:

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

这篇关于如何在Firebird中执行返回结果集的过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆