Re: Reading an OUT parameter out of a function call

From: Stefan Keller <sfkeller(at)gmail(dot)com>
To: Russell Keane <Russell(dot)Keane(at)inps(dot)co(dot)uk>
Cc: Adrian Klaver <adrian(dot)klaver(at)gmail(dot)com>, pgsql-general List <pgsql-general(at)postgresql(dot)org>
Subject: Re: Reading an OUT parameter out of a function call
Date: 2013-02-25 18:34:30
Message-ID: CAFcOn2_LUWoiaj9-p7DAcAMsCcwy6L4cBsje5F6eJY_p9U0ECA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thank you Keane and all.
That works for me too.

Yours, Stefan

2013/2/25 Russell Keane <Russell(dot)Keane(at)inps(dot)co(dot)uk>:
>> > I have a simple void function:
>> >
>> > CREATE OR REPLACE FUNCTION myfn(myparam OUT int) AS $$ BEGIN
>> > pnr := 1;
>> > END;
>> > $$ LANGUAGE plpgsql;
>> >
>> > How do I access myparam?
>> > I thought this should work with 9.1/9.2: SELECT (myfn()).myparam; Or
>> > inside another function?
>>
>> You get the above to load?
>> I get:
>> ERROR: "pnr" is not a known variable
>> LINE 4: pnr := 1;
>
> The following all works under 9.2:
>
> CREATE OR REPLACE FUNCTION myfn(myparam OUT int, myparam2 OUT int) AS $$ BEGIN
> myparam := 1;
> myparam2 := 2;
> END;
> $$ LANGUAGE plpgsql;
>
>
> select myparam from myfn();
> select myparam2 from myfn();
> select myfn();
> select * from myfn();

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Melik Yücel 2013-02-25 18:42:32 PosgreSQL Konfigürasyonu
Previous Message Adrian Klaver 2013-02-25 18:34:02 Re: [GENERAL] Use, Set Catalog and JDBC questions