Sequences : getting back the nextval() result on an insert

Поиск
Список
Период
Сортировка
От Wim Ceulemans
Тема Sequences : getting back the nextval() result on an insert
Дата
Msg-id 000901bd951c$f3e5d2b0$67faa8c0@aladdin.nice.be
обсуждение исходный текст
Ответы Re: [GENERAL] Sequences : getting back the nextval() result on an insert  (Marin D <marin@cybernet.bg>)
Re: [GENERAL] Sequences : getting back the nextval() result on an insert  (Marin D <marin@cybernet.bg>)
Re: [GENERAL] Sequences : getting back the nextval() result on an insert  (Marin D <marin@cybernet.bg>)
Список pgsql-general
Hi
 
I am new to this list, but I've carefully searched the archives before posting this question.
 
I am using JDBC to access postgreSQL 6.3.
 
If one inserts records using a sequence to generate an auto-increment primary key, then you can get back the result by using "select currval('seq')". There is always a time between the insert and the select to retrieve the newly created primary key. What I do in my application is insert a record and display it in a java swing JTable (including the primary key).
 
How can I be certain that the primary key I retrieve with select currval('seq') is the one just inserted? Because in heavily loaded multi-user systems someone else can insert a record in the same table between my insert and my select.
 
Regards
Wim Ceulemans
Nice Software Solutions
 

В списке pgsql-general по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [GENERAL] psql source archives? 6.2.1 needed
Следующее
От: Oleg Broytmann
Дата:
Сообщение: Re: [QUESTIONS] SQL statement