sequence in select

Started by SunWuKungalmost 20 years ago2 messagesgeneral
Jump to latest
#1SunWuKung
Balazs.Klein@t-online.hu

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;

thx.
Balázs

#2Jim Nasby
Jim.Nasby@BlueTreble.com
In reply to: SunWuKung (#1)
Re: sequence in select

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