plpgsql question - Mailing list pgsql-sql

From Postgres Admin
Subject plpgsql question
Date
Msg-id 4314863A.3030107@productivitymedia.com
Whole thread Raw
In response to Re: Numerical variables in pqsql statements  ("Thomas F. O'Connell" <tfo@sitening.com>)
Responses Re: [ADMIN] plpgsql question
List 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

pgsql-sql by date:

Previous
From: "Thomas F. O'Connell"
Date:
Subject: Re: Numerical variables in pqsql statements
Next
From: Michael Fuhr
Date:
Subject: Re: [ADMIN] plpgsql question