Re: INSERT and get ID

Поиск
Список
Период
Сортировка
От Sebastiaan van Erk
Тема Re: INSERT and get ID
Дата
Msg-id 42E79710.2050509@sebster.com
обсуждение исходный текст
Ответ на Re: INSERT and get ID  (Roland Walter <rwa@mosaic-ag.com>)
Список pgsql-jdbc
If you're going to do an extra select anyway, I would do it *before* the
insert. Select the nextval from the sequence and use that as the primary
key for the insert.

Greetings,
Sebastiaan

Roland Walter wrote:
> Peter.Zoche@materna.de schrieb:
>
>>> You have to do a a "SELECT curval('myseq')" after the insert.
>>
>>
>>
>> I had this in mind, too, but I am not sure if it is really safe if
>> there are several inserts at the same time...
>>
>
> What do you mean with at the same time?
>
> Different connections see different sequence values. So there is no
> need to worry.
>
> If you did the
> insertions within the same connection, you have to ask the current value
> of the sequence after each INSERT.
>
>

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

Предыдущее
От: "Rohit Ankushe"
Дата:
Сообщение: JDBC JAR Problem
Следующее
От: "Xavier Poinsard"
Дата:
Сообщение: Re: JDBC JAR Problem