X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 73484D8591; Tue, 30 Aug 2005 13:16:11 -0300 (ADT) 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 00388-02; Tue, 30 Aug 2005 16:16:08 +0000 (GMT) Received: from ns2.instrumentalyst.com (blk-222-55-203.eastlink.ca [24.222.55.203]) by svr1.postgresql.org (Postfix) with ESMTP id D75B1D8586; Tue, 30 Aug 2005 13:16:03 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ns2.instrumentalyst.com (Postfix) with ESMTP id 263694B9; Tue, 30 Aug 2005 13:15:23 -0300 (ADT) Received: from ns2.instrumentalyst.com ([127.0.0.1]) by localhost (ns2.instrumentalyst.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 32749-04; Tue, 30 Aug 2005 13:15:18 -0300 (ADT) Received: from [192.168.2.2] (pcp842727pcs.beridg01.fl.comcast.net [68.56.170.170]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ns2.instrumentalyst.com (Postfix) with ESMTP id 7DC083BD; Tue, 30 Aug 2005 13:15:17 -0300 (ADT) Message-ID: <4314863A.3030107@productivitymedia.com> Date: Tue, 30 Aug 2005 12:15:54 -0400 From: Postgres Admin User-Agent: Thunderbird 1.6a1 (Macintosh/20050829) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Cc: PostgreSQL - Admin Subject: plpgsql question References: <1C7C5DE3-5EB5-4EB8-A187-290EF5081BD7@sitening.com> In-Reply-To: <1C7C5DE3-5EB5-4EB8-A187-290EF5081BD7@sitening.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at instrumentalyst.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.216 required=5 tests=[AWL=-0.041, FORGED_RCVD_HELO=0.05, UPPERCASE_25_50=0.207] X-Spam-Level: X-Archive-Number: 200508/386 X-Sequence-Number: 18705 Can I do something like this: CREATE TABLE sample (id SERIAL, node INTEGER, parent INTEGER); INSERT INTO sample(node,parent) VALUES(1,0); INSERT INTO sample(node,parent) VALUES(2,0); INSERT INTO sample(node,parent) VALUES(3,1); INSERT INTO sample(node,parent) VALUES(4,3) CREATE OR REPLACE FUNCTION article_display(anyelement, anyelement) RETURNS SETOF samle AS $$ DECLARE articleRow sample%ROWTYPE; BEGIN FOR articleRow IN SELECT comments FROM theirry.articles ORDER BY article_id DESC LIMIT $1 OFFSET $2 LOOP RETURN NEXT articleRow; END LOOP; RETURN; END; $$ LANGUAGE plpgsql; Thanks, J