Obtaining ResultSet from a stored function

PostgreSQL's™ stored function can return results by means of a refcursor value. A refcursor.

As an extension to JDBC, the PostgreSQL™ JDBC driver can return refcursor values as ResultSet values.

It is also possible to treat the refcursor return value as a distinct type in itself. The JDBC driver provides the org.postgresql.PGRefCursorResultSet class for this purpose.