plpgsql function returning SETOF RECORD Question

From: <jbduffy(at)ntlworld(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: plpgsql function returning SETOF RECORD Question
Date: 2004-02-23 13:21:32
Message-ID: 20040223132208.MQDR10961.mta07-svc.ntlworld.com@mta7-svc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi

When I run the function below I recieve an error message saying that column definitions need to be specified for a function returing a type RECORD.

I was under the impression that the FOR row IN SELECT... loop would assign a column structure to the RECORD type. Am I wrong about this?

CREATE FUNCTION test() RETURNS SETOF RECORD AS '
DECLARE
row RECORD;
BEGIN
FOR row IN SELECT * FROM dates LOOP
RETURN NEXT row;
END LOOP;

RETURN;
END;
' LANGUAGE 'plpgsql';

PostgreSQL 7.3.2-3 on Red Hat 9.

Regards

John Duffy

-----------------------------------------
Email provided by http://www.ntlhome.com/

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message PostgreSQL Bugs List 2004-02-24 01:26:57 BUG #1083: Insert query reordering interacts badly with NEXTVAL()/CURRVAL()
Previous Message Sumita Biswas 2004-02-23 08:54:32 Re: Postgres DB