Create a function with OUT parameters?

Top  Previous  Next

CREATE or REPLACE FUNCTION public.test_func(out junk1 varchar,out junk2 varchar)

AS

$BODY$

BEGIN

junk1 = 'fdfdfdfd';

junk2 = '7565656';

END;

$BODY$

LANGUAGE 'plpgsql' VOLATILE;

 

returns:

 

test_db=# select * from test_func();

 

junk1 | junk2

----------+---------

fdfdfdfd | 7565656

(1 row)

 

 

You can also return multiple rows by doing a for select loop.

 

There is no need to create a type anymore.

 

NOTE: This only works on a 8.1 or greater server.