Обсуждение: Re: @@IDENTITY (Was: Access - ODBC - serial problem)

Поиск
Список
Период
Сортировка

Re: @@IDENTITY (Was: Access - ODBC - serial problem)

От
"Dave Page"
Дата:

> -----Original Message-----
> From: Philippe Lang [mailto:philippe.lang@attiksystem.ch]
> Sent: 10 April 2004 09:59
> To: pgsql-odbc@postgresql.org
> Cc: scott.marlowe
> Subject: Re: [ODBC] @@IDENTITY (Was: Access - ODBC - serial problem)
>
> > For reasons unfathomable to modern man, Microsoft chose
> @@IDENTITY to mean, not the current user, as I or you or any
> sane person would expect, but to hold the incremented value of
> an autoincrementing column fed by an insert.
> Another triumph in orthogonally named things from Microsoft.

Ahh, that was some good thinking on their part, though it does sorta
make sense.

> - After an insert, Postgresql ODBC driver reads the data
> based on the values that have been inserted. There are cases
> were these values already existed in the table before the
> insert, and so the autoincrement fetched may not be correct.

It does? I wasn't aware of that. I assume you mean when using cursors
(which I never use) as it doesn't following a regular insert statement.

> Is there anything that can be done at the driver level?

Standard answer: The best method would be to do a "SELECT
currval('seq_name');" when required on the relevant sequence.

Regards, Dave.