Re: mysql's last_insert_id - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: mysql's last_insert_id
Date
Msg-id 20030829021109.GB23834@svana.org
Whole thread Raw
In response to Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
Responses Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
Re: mysql's last_insert_id  (Bo Lorentsen <bl@netgroup.dk>)
List 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

Attachment

pgsql-general by date:

Previous
From: "Williams, Travis L, NEO"
Date:
Subject: Re: Join question
Next
From: "Browne, George (AT-Atlanta)"
Date:
Subject: How does it work