I have a function in Postgres 9.4 similar to this one:
CREATE OR REPLACE FUNCTION myF(
INOUT _p1 character varying,
IN _p2 integer,
OUT _p3 boolean)
RETURNS setof retVal AS
$BODY$
_p3 := '0';
RETURN query SELECT 1 AS col1, 'test' as col2;
END;$BODY$
LANGUAGE plpgsql VOLATILE NOT LEAKPROOF
COST 100;
Having type retVal defined as well:
create type retVal as (col1 int, col2 character varying);
The body of the function is far more complex (and I need plpgsql for this purpose), and I have to invoke it from a Java program thru a
CallableStatement.executeQuery()
My questions are: 1) what should I put as RETURNS value in the function? 2) Is it correct to return the result via RETURN query syntax?
Thank you very much!