Re: Using generate_series to create a unique ID in a query? - Mailing list pgsql-general

From Jan de Visser
Subject Re: Using generate_series to create a unique ID in a query?
Date
Msg-id 1159c1e90711140827h2c1cf6d2r9fcab43e90c90105@mail.gmail.com
Whole thread Raw
In response to Re: Using generate_series to create a unique ID in a query?  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Using generate_series to create a unique ID in a query?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
On 11/14/07, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> hubert depesz lubaczewski <depesz@depesz.com> writes:
> > On Mon, Nov 12, 2007 at 03:11:50PM -0800, Sarah Dougherty wrote:
> >> To recap with an example, the query below works fine, but how do I add a
> >> series to it?
>
> > generate_series will not help with this.
> > try the sequence approach, or this:
> > http://www.depesz.com/index.php/2007/08/17/rownum-anyone-cumulative-sum-in-one-query/
>
> That's a fairly ugly/messy way of doing it.  If you're going to need a C
> function anyway, why not just do it directly?  As in the attachment.
>
> regression=# create function rownum() returns int as '/home/tgl/pgsql/rownum'
> regression-# language c;
> CREATE FUNCTION

Any reason why this couldn't appear in the core of some future
version? I've been wanting something like this a couple of times
before. Note that Oracle has it as well.

jan

pgsql-general by date:

Previous
From: Andrew Sullivan
Date:
Subject: Re: reserving space in a rec for future update
Next
From: Tom Lane
Date:
Subject: Re: Using generate_series to create a unique ID in a query?