From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Robert Haas <robertmhaas(at)gmail(dot)com> |
Cc: | Rod Taylor <rod(dot)taylor(at)gmail(dot)com>, Josh Berkus <josh(at)agliodbs(dot)com>, Asko Oja <ascoja(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Out parameters handling |
Date: | 2009-03-07 16:51:03 |
Message-ID: | 162867790903070851g6e09be72hf02883c7ecfa37c7@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
2009/3/7 Robert Haas <robertmhaas(at)gmail(dot)com>:
> On Sat, Mar 7, 2009 at 9:08 AM, Rod Taylor <rod(dot)taylor(at)gmail(dot)com> wrote:
>> It wouldn't be so bad if you could assign internal and external column names.
>>
>> Within the function you call the column "v_foo" but the caller of the
>> function receives column "foo" instead.
>>
>> OUT v_foo varchar AS "foo"
>>
>>
>> Another alternative is requiring a prefix like plout for the
>> replacement to occur:
>>
>> ( OUT foo varchar )
>>
>> BEGIN
>> SELECT foo.somename INTO plout.foo FROM foo WHERE id = 10;
>>
>> RETURN NEXT;
>>
>> RETURN;
>> END;
>
> This is a good point. Uglifying the parameter names is sort of OK for
> input parameters, but is much more annoying for output parameters.
>
> ...Robert
>
hello
actually - function name should be used as label now. This code is working:
postgres=# create or replace function fx2(a integer, out b integer,
out c integer) as $$
begin
fx2.b := a + 10; fx2.c := a + 30;
return;
end; $$ language plpgsql;
CREATE FUNCTION
postgres=# select * from fx2(20);
┌────┬────┐
│ b │ c │
├────┼────┤
│ 30 │ 50 │
└────┴────┘
(1 row)
regards
Pavel Stehule
From | Date | Subject | |
---|---|---|---|
Next Message | Gregory Stark | 2009-03-07 17:15:37 | Re: Out parameters handling |
Previous Message | Tom Lane | 2009-03-07 16:44:58 | Re: small parallel restore optimization |