Re: mysql's last_insert_id

Поиск
Список
Период
Сортировка
От Martijn van Oosterhout
Тема Re: mysql's last_insert_id
Дата
Msg-id 20030829021109.GB23834@svana.org
обсуждение исходный текст
Ответ на Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
Ответы Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
Список pgsql-general
On Thu, Aug 28, 2003 at 02:52:57PM +0200, Bo Lorentsen wrote:
> On Thu, 2003-08-28 at 10:02, Dennis Björklund wrote:
>
> > Yes, never use the oid at all is my suggestion.
> Hmm, will oid's not change so that they are unique regardless, or will
> oid be removed.

OIDs have never beebn unique, it's just that most databases never get big
enough to experience wraparound. They are also now optional per table and
may soon no longer be available by default.

> > If you need a unique id for a row then add a serial column that will
> > provide that, and use currval('the_sequence') to get the last inserted
> > value in that column for a session.
> This is just not a general solution to this problem, and will need
> awareness of the id type in the application layer.

There are various solutions. Some people use functions to do inserts, I just
use the string "currval(whatever)" in the application layer which the
database replaces with the appropriate value.

Whatever works for you.
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> "All that is needed for the forces of evil to triumph is for enough good
> men to do nothing." - Edmond Burke
> "The penalty good people pay for not being interested in politics is to be
> governed by people worse than themselves." - Plato

Вложения

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

Предыдущее
От: "Williams, Travis L, NEO"
Дата:
Сообщение: Re: Join question
Следующее
От: "Browne, George (AT-Atlanta)"
Дата:
Сообщение: How does it work