Re: SELECT Question

From: Joe Conway <mail(at)joeconway(dot)com>
To: Kris Jurka <books(at)ejurka(dot)com>
Cc: Alex <alex(at)meerkatsoft(dot)com>, Lada 'Ray' Lostak <ray(at)unreal64(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: SELECT Question
Date: 2003-11-20 16:31:07
Message-ID: 3FBCEC4B.4050907@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-patches

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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Durai 2003-11-20 16:40:55 Re: error durring compilation
Previous Message konf 2003-11-20 16:23:59 Re: error durring compilation

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2003-11-20 16:34:11 Re: cleanup execTuples.c
Previous Message Manfred Koizar 2003-11-20 14:33:53 Re: SELECT Question