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.
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.