pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Postgres Admin <postgres@productivitymedia.com>
To: pgsql-sql@postgresql.org
Cc: PostgreSQL - Admin <pgsql-admin@postgresql.org>
Subject: plpgsql question
Date: Tue, 30 Aug 2005 12:15:54 -0400
Message-ID: <4314863A.3030107@productivitymedia.com> (raw)
In-Reply-To: <1C7C5DE3-5EB5-4EB8-A187-290EF5081BD7@sitening.com>
References: <BAY101-DAV8EA3AA3EF2A17C6F7C9EEA3B60@phx.gbl>
	<F104769F-4833-4E10-892B-8EDCC0AE0E27@sitening.com>
	<BAY101-DAV106551B6BE74061AD63302A3AF0@phx.gbl>
	<1C7C5DE3-5EB5-4EB8-A187-290EF5081BD7@sitening.com>

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



view thread (14+ messages)  latest in thread

Message-ID: <4314863A.3030107@productivitymedia.com>
Permalink:  ../4314863A.3030107@productivitymedia.com/
Also on:    postgresql.org/message-id/4314863A.3030107@productivitymedia.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: postgres@productivitymedia.com, pgsql-admin@postgresql.org
  Subject: Re: plpgsql question
  In-Reply-To: <4314863A.3030107@productivitymedia.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox