plpgsql question

From: Postgres Admin <postgres(at)productivitymedia(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Cc: PostgreSQL - Admin <pgsql-admin(at)postgresql(dot)org>
Subject: plpgsql question
Date: 2005-08-30 16:15:54
Message-ID: 4314863A.3030107@productivitymedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-sql

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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Michael Fuhr 2005-08-30 16:50:14 Re: plpgsql question
Previous Message Thomas F. O'Connell 2005-08-30 15:13:48 Re: Numerical variables in pqsql statements

Browse pgsql-sql by date

  From Date Subject
Next Message Michael Fuhr 2005-08-30 16:50:14 Re: plpgsql question
Previous Message Thomas F. O'Connell 2005-08-30 15:13:48 Re: Numerical variables in pqsql statements