From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Masse Jacques <jacques(dot)masse(at)bordeaux(dot)cemagref(dot)fr> |
Cc: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: plpgsql : column definition list |
Date: | 2004-08-03 16:13:47 |
Message-ID: | 410FB9BB.8020702@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
Masse Jacques wrote:
> I have the following message:
> ERROR: a column definition list is required for functions returning
> "record"
> CREATE OR REPLACE FUNCTION test()
> RETURNS SETOF record AS
make this
RETURNS SETOF int AS
> '
> declare
> parent integer;
> rec RECORD;
> begin
> ... a "SELECT INTO parent ..." giving a value to the variable parent
> ...
> FOR rec IN SELECT ech_id from data.sp_ech_recurs_desc_a(parent) LOOP
> RETURN NEXT rec;
and make this
RETURN NEXT rec.ech_id;
You only want to return type "record" for composite (multicolumn) types
that are not knowable in advance of writing the query (i.e. that might
vary from call to call).
HTH,
Joe
From | Date | Subject | |
---|---|---|---|
Next Message | Martin Foster | 2004-08-03 18:05:23 | Performance Bottleneck |
Previous Message | Masse Jacques | 2004-08-03 16:02:37 | plpgsql : column definition list |