X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 055DC5658C for ; Fri, 11 Mar 2005 10:59:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 84854-03 for ; Fri, 11 Mar 2005 10:59:55 +0000 (GMT) Received: from mail.diglat.lv (unknown [159.148.213.135]) by svr1.postgresql.org (Postfix) with ESMTP id B9B4A56587 for ; Fri, 11 Mar 2005 10:59:54 +0000 (GMT) Received: from localhost ([127.0.0.1]) by mail.diglat.lv (Kerio MailServer 6.0.8) for pgsql-sql@postgresql.org; Fri, 11 Mar 2005 12:59:55 +0200 Message-ID: <423178FC.3050107@gmail.com> Date: Fri, 11 Mar 2005 12:54:52 +0200 From: Juris Zeltins User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: pl/pgsql problem with return types Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.477 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200503/159 X-Sequence-Number: 20638 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