Re: GetLastInsertID ?

From: Dave Cramer <pg(at)fastcrypt(dot)com>
To: Mike Nolan <nolan(at)gw(dot)tssi(dot)com>
Cc: Dennis Bjorklund <db(at)zigo(dot)dhs(dot)org>, Stephane Pinel <spinel(at)noos(dot)fr>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: GetLastInsertID ?
Date: 2004-01-01 21:51:11
Message-ID: 1072993871.1662.43.camel@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Yes, it will

curval is the curval for *this* connection, not the current value for
the sequence!

Dave
On Thu, 2004-01-01 at 16:37, Mike Nolan wrote:
> > > the last inserted id in the table like we do with MySQL using the
> > > GetLastInsertID ?
> > >
> > > My need is to get back the new id just after inserting.
> >
> > Use currval() after you have inserted.
>
> That will not necessarily tell you the last insertion, depending
> upon how many other users there are doing inserts.
>
> For that matter, I'm not sure that the MySQL method works with multiple
> users either.
> --
> Mike Nolan
>
> ---------------------------(end of broadcast)---------------------------
> TIP 6: Have you searched our list archives?
>
> http://archives.postgresql.org
>
--
Dave Cramer
519 939 0336
ICQ # 1467551

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2004-01-01 22:21:12 Re: GetLastInsertID ?
Previous Message Baldur Norddahl 2004-01-01 21:45:35 why the need for is null?