Functions returning more than one value

From: "Chris Ruprecht" <chrup999(at)yahoo(dot)com>
To: "pgsql" <pgsql-sql(at)postgresql(dot)org>
Subject: Functions returning more than one value
Date: 2001-08-08 12:59:29
Message-ID: 001d01c12009$f6174840$5dd26383@corp.compucom.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Browse pgsql-sql by date

  From Date Subject
Next Message Thomas Good 2001-08-08 13:14:19 Re: Referencing named attribute in where clause doesn't work with 7.1.2?
Previous Message Andreas Joseph Krogh 2001-08-08 12:57:13 Referencing named attribute in where clause doesn't work with 7.1.2?