Re: plpgsql out parameter with select into

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Imre Horvath <blemidon(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: plpgsql out parameter with select into
Date: 2010-08-18 04:39:37
Message-ID: AANLkTiknsTxxG7v0tjZsd2XYev-sbA+hBgSO3fnKC_oX@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello

It cannot work, you mix the sql with plpgsql language

2010/8/17 Imre Horvath <blemidon(at)gmail(dot)com>:
> Hi!
>
> My question is, how can I get the out parameter from a function with
> SELECT INTO by name?
> I mean:
>
> create function testfunc1(OUT _status integer) returns integer as
> $BODY$
>        _status := 0;
> $BODY$
> language plpgsql;
>
> create function testfunc2() as
> declare
>        status integer;
> $BODY$
>        select into status * from testfunc1();
> $BODY$
> language plpgsql;
>
> create function testfunc3() as
> declare
>        status integer;
> $BODY$
>        select into status _status from testfunc1();
> $BODY$
> language plpgsql;
>
> testfunc2 works, testfunc3 not.
>
> Thanks in advance:
> Imre Horvath
>
>

create or replace function test1(out _status integer) returns integer
as $$ begin _status := 10; end; $$ language plpgsql;
create or replace function test3() returns void as $$ declare status
integer; begin select into status _status from test1(); raise notice
'%', status; end; $$ language plpgsql;

this working for me.

postgres=# select test3();
NOTICE: 10
test3
───────

(1 row)

Regards

Pavel Stehule

> --
> Sent via pgsql-sql mailing list (pgsql-sql(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-sql
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Sergey Konoplev 2010-08-18 05:42:52 Re: plpgsql out parameter with select into
Previous Message Scott Marlowe 2010-08-18 02:33:08 Re: Question about POSIX Regular Expressions performance on large dataset.