Hi all,
How can I get more than one value back from a function?
I have a situation here, where a function needs to return a value - but also
needs to indicate from which type of record the value comes.
The most elegant would be something like the 2 functions listed below. They
don't work, since v_val3 and v_val4 are treated as constants in test2() and
can not be changed. Is there a way this can make it into a future release?
Best regards,
Chris
drop function test1();
create function test1() returns integer as '
declare
v_res boolean;
v_val1 integer;
v_val2 integer;
begin
v_val1 := 1;
v_val2 := 2;
v_res := test2( v_val1, v_val2 );
return v_val1 + v_val2;
end;
' language 'plpgsql';
drop function test2(integer, integer);
create function test2(integer, integer) returns boolean as '
declare
v_val3 alias for $1;
v_val4 alias for $2;
begin
v_val3 := 3;
v_val4 := 4;
return true;
end;
' language 'plpgsql';
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?
http://www.postgresql.org/users-lounge/docs/faq.html