Re: Last inserted id

From: "Geoffrey D(dot) Bennett" <g(at)netcraft(dot)com(dot)au>
To: Dave Page <dpage(at)vale-housing(dot)co(dot)uk>
Cc: "'Simeo Reig'" <simreig(at)terra(dot)es>, "'pgsql-odbc(at)postgresql(dot)org'" <pgsql-odbc(at)postgresql(dot)org>
Subject: Re: Last inserted id
Date: 2001-11-12 08:55:04
Message-ID: 20011112192504.A3780@april.netcraft.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-odbc

On Mon, Nov 12, 2001 at 08:23:08AM -0000, Dave Page wrote:
> > -----Original Message-----
> > From: Simeo Reig [mailto:simreig(at)terra(dot)es]
> > Sent: 11 November 2001 22:54
> > To: Dave Page
> > Subject: Re: [ODBC] Last inserted id
> >
> >
> > I had think that the problem was this but I believed that
> > was possible to make a mistake because I'm newer with
> > ADO. What must I do ? I see two possibilities:
> >
> > A) Make a select NEXTVAL from sequence, and
> > insert this value in the id
> >
> > B) Insert row and after make a CURRVAL
> >
> > What option Do you use ?
>
> Use option A), it's multi-user safe whereas the other method isn't.

Unless I'm missing something, option B _is_ multi-user safe.
currval() doesn't return the "current" value of the sequence (like
"select * from my_seq" would) -- it returns the last value that
nextval() gave that session (hence, it isn't defined until that
session does a nextval()).

I have no idea what ADO is :-), so there may be other issues here, but
I don't think multi-user access is one of them.

--
Geoffrey D. Bennett, RHCE, RHCX geoffrey(at)netcraft(dot)com(dot)au
Senior Systems Engineer http://www.netcraft.com.au/geoffrey/
NetCraft Australia Pty Ltd http://www.netcraft.com.au/linux/

In response to

Responses

Browse pgsql-odbc by date

  From Date Subject
Next Message Dave Page 2001-11-12 09:06:06 Re: Last inserted id
Previous Message Dave Page 2001-11-12 08:23:08 Re: Last inserted id