Refcursor_CallableStatement1
Two tables used in this example.

  Returning a refcursor

 

PostgreSQL function :

CREATE OR REPLACE FUNCTION refcursorfunc()
RETURNS refcursor AS
' DECLARE mycurs refcursor;
BEGIN OPEN mycurs FOR SELECT col FROM table_pgsql1
UNION SELECT col FROM table_pgsql2; RETURN mycurs; END;'
LANGUAGE plpgsql VOLATILE
COST 100;
ALTER FUNCTION refcursorfunc()
OWNER TO postgres;

Netbean 8.02 code pgsql_resultset_to_rowset1.txt

1. Creating function:

2. Loading result set:

Output: