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

Started by Zlatko Matićover 18 years ago3 messagesgeneral
Jump to latest
#1Zlatko Matić
zlatko.matic1@sb.t-com.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

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Zlatko Matić (#1)
Re: ERROR: a column definition list is required for functions returning "record"

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.matic1@sb.t-com.hr>:

Show quoted text

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

#3Zlatko Matić
zlatko.matic1@sb.t-com.hr
In reply to: Zlatko Matić (#1)
Re: ERROR: a column definition list is required for functions returning "record"

OK. Thanks.
Regards,

Zlatko

----- Original Message -----
From: "Pavel Stehule" <pavel.stehule@gmail.com>
To: "Zlatko Matiďż˝" <zlatko.matic1@sb.t-com.hr>
Cc: <pgsql-general@postgresql.org>
Sent: Tuesday, July 17, 2007 12:14 PM
Subject: Re: [GENERAL] ERROR: a column definition list is required for
functions returning "record"

Show quoted text

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.matic1@sb.t-com.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

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org/