Solution: implicit vs. explicit RETURN when OUT is used

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: Solution: implicit vs. explicit RETURN when OUT is used
Date: 2008-01-04 09:31:30
Message-ID: 20080104103130.3fe0b614@webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Fri, 4 Jan 2008 09:38:35 +0100
Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it> wrote:

> create or replace function testA(out _BasketID1 int, out _BasketID2
> int) as $$
> begin
> _BasketID1:=1;
> _BasketID2:=2;
> return;
> end;
> $$ language plpgsql;
>
> create or replace function testB(out _BasketID1 int, out _BasketID2
> int) as
> $$
> begin
> select into _BasketID1,_BasketID2 * from testA();
> return;
> end;
> $$ language plpgsql;
>

> But when I switch to
>
> select into _BasketID1,_BasketID2 _BasketID1,_BasketID2 from
> testA();
>
> nothing get back from testB().

OK switching to:

select _BasketID1,_BasketID2 into _BasketID1,_BasketID2 from testA();
still didn't return anything but
changing the def to

create or replace function testB(out _BasketID1 int, out _BasketID2
int) as
$$
begin
select a._BasketID1,a._BasketID2 into _BasketID1z,_BasketID2z from
testA() as a;
return;
end;
$$ language plpgsql;

did work.

here you get the same in a maybe more readable, cut&pastable format:

http://www.webthatworks.it/d1/node/page/returning_composite_type_postgresql_functions_without_declaring_explicitly_composite_type

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

In response to

Browse pgsql-general by date

  From Date Subject
Next Message mljv 2008-01-04 09:36:02 Re: server process (PID 27884) was terminated by signal 4 (SIGILL)
Previous Message mljv 2008-01-04 09:08:03 Re: Updating a production database schema from dev server