【问题标题】:how to use postgresql function in another function which returns set of Refcursor如何在另一个返回一组 Refcursor 的函数中使用 postgresql 函数
【发布时间】: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


    【解决方案1】:

    为什么要返回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 的示例。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2023-01-19
      • 2021-07-03
      • 1970-01-01
      • 1970-01-01
      • 2020-12-26
      • 1970-01-01
      • 2011-07-14
      相关资源
      最近更新 更多