--- Josh Berkus <josh@agliodbs.com> wrote:
> you cannot select the results of
> a query directly into a
> RECORD variable without a loop.
>
Pardon??
kper=# create function test(integer) returns varchar
as 'declare stuff record; begin select * into stuff
from employee where empid =$1; return stuff.empnum;
end;' language 'plpgsql';
CREATE
kper=# select test(66664);test
------3094
(1 row)
kper=# select empid, empnum from employee where empid
= 66664;empid | empnum
-------+--------66664 | 3094
(1 row)
This functinality has been in pl/pgsql from early days
AFAIK. Be aware that this only works reliably if you
have some way to be sure of what will be selected
("empid" is a unique column in this example), because
the second and later rows to be returned from the
query will be silently discarded.
__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - forms, calculators, tips, more
http://taxes.yahoo.com/