question about PL/pgSQL function

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

question about PL/pgSQL function

От:
"datactrl" <quals@bigfoot.com>
Дата:
With postgres 7.1
1. Function like example found on 24.4 Example in Programmer Guide   CREATE FUNCTION xxx (EMP, integer) RETURNS boolean AS'......   (which EMP is a table )   How do I pass a record to this function in PL/PGSQL? I try this
....   select into rec1 * from EMP where empNo =''xxxx'';   i1 :=  xxx(rec1,5);
....   But it won't work!
2. Is that possible to return a record from a function? And how do I get the
returned record in PL/pgSql

JACK


Re: question about PL/pgSQL function

От:
"Josh Berkus" <josh@agliodbs.com>
Дата:
Jack,

>     select into rec1 * from EMP where empNo =''xxxx'';
>     i1 :=  xxx(rec1,5);

Bad syntax.  The correct syntax is:
SELECT * INTO rec1 FROM EMP WHERE empNo=''xxxx'';

> 2. Is that possible to return a record from a function? And how do I
> get the
> returned record in PL/pgSql

No, it is not possible.  I know the list archives are kinda hard to
search, but we've discussed this question ad naseum; in fact, I just
provided a workaround earlier this week.

-Josh


______AGLIO DATABASE SOLUTIONS___________________________                                      Josh Berkus Complete information technology      josh@agliodbs.com  and data management solutions       (415) 565-7293 for law firms, small businesses        fax 621-2533   and non-profit organizations.      San Francisco

Re: question about PL/pgSQL function

От:
Jan Wieck <JanWieck@Yahoo.com>
Дата:
Josh Berkus wrote:
> Jack,
>
> >     select into rec1 * from EMP where empNo =''xxxx'';
> >     i1 :=  xxx(rec1,5);
>
> Bad syntax.  The correct syntax is:
>
>    SELECT * INTO rec1 FROM EMP WHERE empNo=''xxxx'';
>
> > 2. Is that possible to return a record from a function? And how do I
> > get the
> > returned record in PL/pgSql
>
> No, it is not possible.  I know the list archives are kinda hard to
> search, but we've discussed this question ad naseum; in fact, I just
> provided a workaround earlier this week.
   Not yet. In the current 7.2 development tree it's possible to   return a cursor opened inside of the procedure. Maybe  I  can   even improve it so you can open an empty cursor and *fill* it   like a tuple sink so to speak.  Mainly depends on if and  how   we want to improve the capabilities of portals.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


FAQ