Обсуждение: sequence in select

Поиск
Список
Период
Сортировка

sequence in select

От
"SunWuKung"
Дата:
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


Re: sequence in select

От
Jim Nasby
Дата:
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