From: | Stephan Szabo <sszabo(at)megazone(dot)bigpanda(dot)com> |
---|---|
To: | Juan F Diaz <j-diaz(at)publicar(dot)com> |
Cc: | <pgsql-novice(at)postgresql(dot)org> |
Subject: | Re: Returning SETOF RECORD |
Date: | 2003-08-25 18:18:40 |
Message-ID: | 20030825102931.S93434-100000@megazone.bigpanda.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
On Mon, 25 Aug 2003, Juan F Diaz wrote:
> Hi, Im trying to return a setof record (plpgsql) but this error message
> appears and i dont know what to do.
> ERROR: A column definition list is required for functions returning
> RECORD
>
> The function is the following (there may or may not be data in the
> table(s)) right now there is no data in the table (it should return
> null or something).
>
> DECLARE
> Libro ALIAS FOR $1;
> Refe ALIAS FOR $2;
> res RECORD;
> BEGIN
> FOR res IN select color, alto, ancho from referencias where
> IdReferencia like Refe and IdLibro like Libro LOOP
> RETURN NEXT res;
> END LOOP;
> return;
> END;
>
> And another question, is it possible to call a function that returns a
> setof anything like this:
> select foo();
From some of the languages you can do this, but not plpgsql.
> select * from foo(); ??
If the function returns a setof record, you need to give it the column
name/type information in the query, like:
select * from foo() as bar(color text, alto text, ancho text);
From | Date | Subject | |
---|---|---|---|
Next Message | Juan Francisco Diaz | 2003-08-25 20:30:08 | INSERT INTO foo (col1,col2,...,coln) not working |
Previous Message | Stephan Szabo | 2003-08-25 17:50:09 | Re: Way to tell what SQL is currently running? |