Re: ERROR: a column definition list is required for functions returning "record"

From: "Pavel Stehule" <pavel(dot)stehule(at)gmail(dot)com>
To: Zlatko Matić <zlatko(dot)matic1(at)sb(dot)t-com(dot)hr>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: ERROR: a column definition list is required for functions returning "record"
Date: 2007-07-17 10:14:19
Message-ID: 162867790707170314w37bf7dfcn5f8e65d32b2afe75@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

you have to specify column names and column types. Like

postgres=# create or replace function foog() returns setof record as $$
declare r record; begin r := row(10,20); return next r ; return; end;
$$ language plpgsql;

postgres=# select * from foog() t(a int, b int); a | b
----+----
10 | 20
(1 row)

Regards
Pavel Stehule

2007/7/17, Zlatko Matić <zlatko(dot)matic1(at)sb(dot)t-com(dot)hr>:
>
>
> I have a plpgsql function that returns dataset.
> First it was defined to return SETOF someview.
> Then I changed it to return SETOF RECORD, in order to be able to return
> dataset with varying number of columns.
> But, I get the following error:"ERROR: a column definition list is required
> for functions returning "record" SQL state: 42601".
> What does it mean? What is "columns definition list"?
>
> Thanks,
>
> Zlatko
>

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Michael Nolan 2007-07-17 12:48:11 Re: What's the logical counterpart of the to_hex function?
Previous Message Gregory Stark 2007-07-17 10:14:14 Re: interaction with postgres defined types in custom c functions