pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Chris Ruprecht <chrup999@yahoo.com>
To: pgsql <pgsql-sql@postgresql.org>
Subject: Functions returning more than one value
Date: Wed, 8 Aug 2001 07:59:29 -0500
Message-ID: <001d01c12009$f6174840$5dd26383@corp.compucom.com> (raw)

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




view thread (4+ messages)  latest in thread

Message-ID: <001d01c12009$f6174840$5dd26383@corp.compucom.com>
Permalink:  ../001d01c12009$f6174840$5dd26383@corp.compucom.com/
Also on:    postgresql.org/message-id/001d01c12009$f6174840$5dd26383@corp.compucom.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: chrup999@yahoo.com
  Subject: Re: Functions returning more than one value
  In-Reply-To: <001d01c12009$f6174840$5dd26383@corp.compucom.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox