Re: sequence in select - Mailing list pgsql-general

From Jim Nasby
Subject Re: sequence in select
Date
Msg-id BC39FD09-712B-45BD-8D7D-2CF94FB62745@pervasive.com
Whole thread Raw
In response to sequence in select  ("SunWuKung" <Balazs.Klein@t-online.hu>)
List pgsql-general
On Jun 22, 2006, at 9:10 AM, SunWuKung wrote:
> Hi,
> I put the following into a function. Is this always going to give me a
> sequence with an increment of 1 independently from other transactions?
> If not what would be the standard way to return a sequence from a
> query?
>
> CREATE TEMPORARY SEQUENCE rank_seq;
> SELECT nextval('rank_seq') FROM whatever ORDER BY id;
> DROP SEQUENCE rank_seq;

That will do what you want.
--
Jim C. Nasby, Sr. Engineering Consultant      jnasby@pervasive.com
Pervasive Software      http://pervasive.com    work: 512-231-6117
vcard: http://jim.nasby.net/pervasive.vcf       cell: 512-569-9461



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Out of memory error in 8.1.0 Win32
Next
From: Tom Lane
Date:
Subject: Re: Out of memory error in 8.1.0 Win32