返回 OUT 参数和行集
我想返回输出参数和行集。
在 DB2 中,我可以通过以下方式完成此操作,并在存储过程结束之前打开游标:
CREATE PROCEDURE rqstprtl.getInfo (
IN id BIGINT,
OUT var1 CHAR(6),
OUT var2 BIGINT
)
DYNAMIC RESULT SETS 1
我不确定如何使用 PostgreSQL 函数完成同样的事情。我的理解是,对于具有输出参数的函数,函数具有 record
返回类型(或无返回类型),但我还需要 setof record
返回类型返回行集。
I would like to return both output parametrs and a rowset.
In DB2, I can accomplish this with the following, and opening a cursor before the stored procedure ended:
CREATE PROCEDURE rqstprtl.getInfo (
IN id BIGINT,
OUT var1 CHAR(6),
OUT var2 BIGINT
)
DYNAMIC RESULT SETS 1
I'm unsure how to accomplish the same thing with PostgreSQL functions. My understanding is that functions have a return type of record
(or no return type) for functions that have output parameters, but I would also need a return type of setof record
to return the rowset.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以改用引用游标,因此一个 OUT 参数应该是引用游标类型。
帕维尔
You can use a refcursor instead, so one OUT parameter should be a refcursor type.
Pavel