Обсуждение: out parameter and setof record

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

out parameter and setof record

От
uran1@o2.pl
Дата:
In PostgreSql 8.1 i've tried to use Out parameter but when I've changed
function (added Out parameter)

------------------------------------

CREATE OR REPLACE FUNCTION reffunc3(FROM_ID in integer,COUNT_ROW OUT
integer) RETURNS SETOF Person AS '
DECLARE
   rec RECORD;
BEGIN

   SELECT count(*) INTO COUNT_ROW FROM Person WHERE ssn>FROM_ID ;

   FOR rec IN SELECT ssn,name  FROM Person WHERE ssn>FROM_ID
     LOOP
       c;RETURN NEXT rec ;
     END LOOP ;

   RETURN ;
END;
' LANGUAGE plpgsql;



--SELECT * from reffunc3(1) ;
----------------------------------------

i've seen :

----
ERROR:  function result type must be integer because of OUT parameters
----

Of course when I change parameter to Integer it must be Record error
appears.

What should I change, and how to call this function?

Mirek


Re: out parameter and setof record

От
"A. Kretschmer"
Дата:
am  30.05.2006, um  3:21:27 -0700 mailte uran1@o2.pl folgendes:
> In PostgreSql 8.1 i've tried to use Out parameter but when I've changed
> function (added Out parameter)
> ...
> ----
> ERROR:  function result type must be integer because of OUT parameters
> ----
>
> Of course when I change parameter to Integer it must be Record error
> appears.

A good explanation for IN/OUT-Parameters can you find there:
http://people.planetpostgresql.org/xzilla/index.php?/archives/149-out-parameter-sql-plpgsql-examples.html#extended


HTH Andreas
--
Andreas Kretschmer    (Kontakt: siehe Header)
Heynitz:  035242/47215,      D1: 0160/7141639
GnuPG-ID 0x3FFF606C http://wwwkeys.de.pgp.net
 ===    Schollglas Unternehmensgruppe    ===