pl/pgsql problem with return types

From: Juris Zeltins <juris(dot)zeltins(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: pl/pgsql problem with return types
Date: 2005-03-11 10:54:52
Message-ID: 423178FC.3050107@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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_pkey PRIMARY 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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message AL ELK 2005-03-11 11:54:56 more execution time
Previous Message Scott Marlowe 2005-03-10 20:35:48 Re: best way to auto-update a field when row is updated