pl/pgsql problem with return types - Mailing list pgsql-sql

From Juris Zeltins
Subject pl/pgsql problem with return types
Date
Msg-id 423178FC.3050107@gmail.com
Whole thread Raw
Responses Re: pl/pgsql problem with return types  (John DeSoi <desoi@pgedit.com>)
List pgsql-sql
Hello!

i have problem with pl/pgsql function;

====================================================
===
ERROR:  wrong record type supplied in RETURN NEXT
CONTEXT:  PL/pgSQL function "tests" line 6 at return next
===

-- Function: tests(int8)
-- DROP FUNCTION tests(int8);

CREATE OR REPLACE FUNCTION tests(int8) RETURNS SETOF pages AS
$BODY$DECLARE   P    RECORD;
BEGIN   FOR P IN select pageid from pages   LOOP       RETURN NEXT P;   END LOOP;   RETURN;
END;$BODY$ LANGUAGE 'plpgsql' STABLE;
ALTER FUNCTION tests(int8) OWNER TO diglat_web;

====================================================
-- Table: pages
-- DROP TABLE pages;

CREATE TABLE pages
( pageid int8 NOT NULL, ppageid int8 NOT NULL DEFAULT 0, name varchar(100), status int4 DEFAULT 0, CONSTRAINT
pages_pkeyPRIMARY KEY (pageid), CONSTRAINT pages_in_pages_fkey FOREIGN KEY (ppageid) REFERENCES pages 
 
(pageid) ON UPDATE RESTRICT ON DELETE RESTRICT, CONSTRAINT pages_uniq UNIQUE (pageid, ppageid)
)
WITH OIDS;
====================================================

Actualy function is correct... and the same code run successfully on 
other table.. there is the problem ?

Thanks



pgsql-sql by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: best way to auto-update a field when row is updated
Next
From: "ALÝ ÇELÝK"
Date:
Subject: more execution time