Re: sequence help - Mailing list pgsql-general

From Ragnar
Subject Re: sequence help
Date
Msg-id 1164708652.27070.155.camel@localhost.localdomain
Whole thread Raw
In response to sequence help  (Matthew Peter <survivedsushi@yahoo.com>)
List pgsql-general
On þri, 2006-11-28 at 01:12 -0800, Matthew Peter wrote:
> I'll jump right in with an example
>
> create sequence foo start with 1;
>
> create view foobar as select *, nextval('foo') from bar;
>
> The problem is I need a nextval()-like method that returns the iterations without
> updating the foo sequence. Therefore, maintaining the sequences original value by
> starting at 1 each time the foobar VIEW is invoked.

sounds like you do not really want sequences. (think of
concurrent selects from such a view)

the most natural way to do this is in the application
layer, but if you have to do this in the backend, you
could do it with a pl/pgsql user defined set returning
function, I guess.

gnari



pgsql-general by date:

Previous
From: Alban Hertroys
Date:
Subject: Re: sequence help
Next
From: George Weaver
Date:
Subject: Re: A generic trigger to log chanes on database tables