Here is an example snippet. I am trying to have a INOUT parameter and also trying to return a refcursor.
CREATE OR REPLACE FUNCTION reffunc2(IN key int, INOUT name int)
RETURNS refcursor
AS $$
DECLARE
ref refcursor;
BEGIN
name = 123;
OPEN ref FOR SELECT col FROM test;
RETURN ref;
END;
$$
LANGUAGE plpgsql;
Specifying an
OUTorINOUTparameter is the same as specifying a return value, so the two definitions have to match:with a single
OUTparameter,RETURNSmust specify the type of that parameterwith more than one
OUTparameter, you must useRETURNS recordYou cannot specify one result column as
OUTparameter and the other one as result.Use this:
In the function body, you must assign values to
nameandxand useRETURNwithout argument.