> -----Original Message-----
> From: Jean-Michel POURE [mailto:jm.poure@freesurf.fr]
> Sent: 12 November 2001 10:06
> To: pgsql-odbc@postgresql.org
> Subject: Re: [ODBC] Last inserted id
>
>
> At 09:55 12/11/01 +0000, you wrote:
> >'Cos that's not safe either - you might get multiple rows
> inserted at
> >the same time - unlikely, but certainly possible.
>
> In most cases a simple timestamp is enough because you add some other
> parameter to you query (ex:company name, or whatever field
> you inserted).
> For example, if you insert values with First_name=Dave,
> Second_name=Page,
> Timestamp=current time and query the resulting row, there is
> *very little*
> chance to get rows from other users.
>
> I guess this is the recommended way (see Access howto).
There is *very little* chance, but very little is not *no chance* (bear in
mind that at this point in time in the example we're discussing no primary
key value is yet known).
I would always suggest that people do a select nextval('seq') followed by a
suitable insert. It requires no locking, is definitely multi user safe and
will *always* correctly identify the row. The only downside is that it
requires a quick select before the insert, but if this minor speed sacrifice
was that much of an issue then VB+ADO+ODBC is possibly not the technology to
use in such a project anyway IMHO.
Regards, Dave.