1

My Function as Follows

CREATE OR REPLACE FUNCTION get_history(refcursor, encounterid integer, patientid integer) RETURNS SETOF refcursor

Begin

end

How to use above function in another function.

1 Answer 1

2

Why would you want to return SETOF refcursor?

Maybe you want

 RETURNS TABLE( ...)

or

 RETURNS SETOF some_composite_type

You call that like any other SELECT command ..

SELECT * FROM get_history(...)

And can use it in a plpgsql LOOP:

FOR my_row_var IN
    SELECT * FROM get_history(...)
LOOP
  -- do stuff
END LOOP;

Or just

 RETURNS refcursor

There is a detailed example how to handle this in the manual here.

Even including an example for RETURNS SETOF refcursor.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.