aliases and set of record

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: <pgsql-general(at)postgresql(dot)org>
Subject: aliases and set of record
Date: 2008-03-20 12:41:39
Message-ID: 20080320134139.15d45f21@webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I'd like to use default param so I build up an alias of BasketItems
create or replace function BasketItems(
_BasketID bigint, _Split boolean, out _ItemID int, out _qty
real )

as...

create or replace function BasketItems(
_BasketID bigint, out _ItemID int, out _qty real
)
returns setof record as
$$
declare
_row record;
begin
for _row in
select _ItemID as __ItemID, _qty as __qty from
BasketItems(_BasketID,null)
loop
_ItemID:=_row.__ItemID;
_qty:=_row.__qty;
return next;
end loop;
return;
end;
$$ language plpgsql;

This return 2 empty records _qty and _ItemID are empty
select * from BasketItems(2);

this returns what's expected:
select _ItemID as __ItemID, _qty as __qty from BasketItems(2,null);

What's wrong?

Any way to fix it keeping the names of the returned columns
consistent?

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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Ivan Sergio Borgonovo 2008-03-20 12:47:07 Re: [solved] aliases and set of record
Previous Message Karsten Hilbert 2008-03-20 11:40:46 Re: Problem with async notifications of table updates