Обсуждение: aliases and set of record

Поиск
Список
Период
Сортировка

aliases and set of record

От
Ivan Sergio Borgonovo
Дата:
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


Re: [solved] aliases and set of record

От
Ivan Sergio Borgonovo
Дата:
On Thu, 20 Mar 2008 13:41:39 +0100
Ivan Sergio Borgonovo <mail@webthatworks.it> wrote:

[snip]

>  for _row in
>   select _ItemID as __ItemID, _qty as __qty from
>     BasketItems(_BasketID,null)
>   loop
...

->

for _row in
 select bi._ItemID as __ItemID, bi._qty as __qty from
   BasketItems(_BasketID,null) as bi
loop

A bit annoying but works.

I hope it will be taken as a reference and not as garbage on the list.

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