Re: getting primary key values for inserted records?

Поиск
Список
Период
Сортировка
От scott.marlowe
Тема Re: getting primary key values for inserted records?
Дата
Msg-id Pine.LNX.4.33.0401280854210.24964-100000@css120.ihs.com
обсуждение исходный текст
Ответ на Re: getting primary key values for inserted records?  (Jeremy Buchmann <jeremy@wellsgaming.com>)
Список pgsql-jdbc
On Tue, 27 Jan 2004, Jeremy Buchmann wrote:

> On Jan 27, 2004, at 11:35 AM, Andrew Nelson wrote:
>
> > I've always wondered if something like this is totally safe.  What if
> > someone somewhere else outside of my code ran a insert or update that
> > didn't use the sequence at all but changed the id.  And that id turned
> > out to be the same as the id collect from the select
> > nextval('sequence');
> >
> > So I guess you would need to add a lock of some sorts.
> > Just wondering because this is something I have fought with for a long
> > time.
>
> Well, it's only safe if you use the sequence.  If you don't, you're on
> your own.
>
> Cheers,
> Jeremy

You could always program a before trigger that would not let you directly
insert or update that column, and would only use the sequence.


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

Предыдущее
От: Guido Fiala
Дата:
Сообщение: setQueryTimeOut(1) - not expected result...
Следующее
От: Dave Cramer
Дата:
Сообщение: Re: a little disillusioned now tomcat 5