Skip site navigation (1) Skip section navigation (2)

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 (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-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

pgsql-admin by date

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

pgsql-sql by date

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

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group