dbTalk Databases Forums  

plpgsql : column definition list

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss plpgsql : column definition list in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Masse Jacques
 
Posts: n/a

Default plpgsql : column definition list - 08-03-2004 , 12:02 PM






The result of the function test() should be a list of integer coming from a
column "ech_id" from a recursive function
data.sp_ech_recurs_desc_a(integer).

I have the following message:
ERROR: a column definition list is required for functions returning
"record"

How to define this list in this function ?

Thanks
--------
CREATE OR REPLACE FUNCTION test()
RETURNS SETOF record 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;
END LOOP;
return;
end
'
LANGUAGE 'plpgsql' VOLATILE;
------------

---------------------------(end of broadcast)---------------------------
TIP 4: Don't 'kill -9' the postmaster


Reply With Quote
  #2  
Old   
Joe Conway
 
Posts: n/a

Default Re: plpgsql : column definition list - 08-03-2004 , 12:13 PM






Masse Jacques wrote:
Quote:
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

Quote:
'
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

---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo (AT) postgresql (DOT) org



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.