Re: Question on stored functions

From: Bill Moran <wmoran(at)potentialtech(dot)com>
To: Gunjeet Singh <Gunjeet(dot)Singh(at)eng(dot)sun(dot)com>
Cc: pgsql-general(at)postgresql(dot)org, gunjeet(dot)singh(at)sun(dot)com
Subject: Re: Question on stored functions
Date: 2004-03-09 22:56:46
Message-ID: 404E4BAE.4020907@potentialtech.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gunjeet Singh wrote:
> Hi,
>
> I could only find support for defining functions in pl/pgsql.
> With a function I can have only one return value. What if I need
> to have multiple OUT parameters (i.e multiple return values) ?
> Is there any support for something that is similar to an Oracle
> stored procedure ?
>
> I understand that I can return a REFCURSOR from a postgres function,
> but my question is for a case, say, where I need to return 2 string
> variables/values based on some logic in addition to a REFCURSOR.
> How do I do that in pl/pgsql ?

Example:

create type demotype as (
value1 text,
value2 text );

create function returns2strings()
returns demotype
as '
declare
rval demotype;
begin
rval.value1 := ''some string'';
rval.value2 := ''some other string'';
return rval;
end;
' language 'plpgsql';

--
Bill Moran
Potential Technologies
http://www.potentialtech.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2004-03-09 23:10:31 Re: autocommit to off?
Previous Message scott.marlowe 2004-03-09 22:46:38 Re: Error message