Обсуждение: @@SPID MS SQL alternative

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

@@SPID MS SQL alternative

От
"Jan Blaha"
Дата:
Hi I am looking for some way how to get some ID variable that remains
unchanged and unique throughout a connection, like MS SQL @@SPID. I am
running PostGreSQL 7.2.1 Native Windows Port. I would be thanksfull for
any help.
                   Thanks a lot
                                  Honza


Re: @@SPID MS SQL alternative

От
Bruno Wolff III
Дата:
On Fri, Apr 16, 2004 at 11:09:00 +0200,
  Jan Blaha <jan.blaha@terminus.cz> wrote:
> Hi I am looking for some way how to get some ID variable that remains
> unchanged and unique throughout a connection, like MS SQL @@SPID. I am
> running PostGreSQL 7.2.1 Native Windows Port. I would be thanksfull for
> any help.

You could use a sequence to provide this. You will need to make an initial
call of nextval at the start of the session and then not call it again
(for the same sequence). Use currval to retrieve the id.