【发布时间】:2013-01-22 09:55:34
【问题描述】:
我的功能如下
CREATE OR REPLACE FUNCTION get_history(refcursor, meetid integer, patientid integer) RETURNS SETOF refcursor
开始
结束
如何在另一个函数中使用上述函数。
【问题讨论】:
标签: function postgresql stored-procedures ref-cursor
我的功能如下
CREATE OR REPLACE FUNCTION get_history(refcursor, meetid integer, patientid integer) RETURNS SETOF refcursor
开始
结束
如何在另一个函数中使用上述函数。
【问题讨论】:
标签: function postgresql stored-procedures ref-cursor
为什么要返回SETOF refcursor?
也许你想要
RETURNS TABLE( ...)
或
RETURNS SETOF some_composite_type
您可以像其他任何 SELECT 命令一样调用它..
SELECT * FROM get_history(...)
并且可以在 plpgsql LOOP 中使用它:
FOR my_row_var IN
SELECT * FROM get_history(...)
LOOP
-- do stuff
END LOOP;
或者只是
RETURNS refcursor
There is a detailed example how to handle this in the manual here.
甚至包括RETURNS SETOF refcursor 的示例。
【讨论】: