Re: SELECT Question - Mailing list pgsql-general

From Joe Conway
Subject Re: SELECT Question
Date
Msg-id 3FBCEC4B.4050907@joeconway.com
Whole thread Raw
In response to Re: SELECT Question  (Kris Jurka <books@ejurka.com>)
Responses Re: SELECT Question
List pgsql-general
Kris Jurka wrote:
> A useful generic function would be one something like range(min,max) that
> would return a set of rows so you wouldn't have to actually have a table.
>

You mean like this?

CREATE OR REPLACE FUNCTION test(int,int) RETURNS SETOF int AS '
BEGIN
   FOR i IN $1..$2 LOOP
     RETURN NEXT i;
   END LOOP;
   RETURN;
END;
' LANGUAGE 'plpgsql' STRICT IMMUTABLE;

regression=# select * from test(4, 8);
  test
------
     4
     5
     6
     7
     8
(5 rows)

HTH,

Joe



pgsql-general by date:

Previous
From: konf@chalu.cz
Date:
Subject: Re: error durring compilation
Next
From: "Durai"
Date:
Subject: Re: error durring compilation