[cvsnt] Re: Audit DB: commitlog.sessionid is always 0

Olaf Groeger Olaf.Groeger at gmx.de
Fri Jan 6 07:30:40 GMT 2006


Tony Hoyle wrote:

> Olaf Groeger wrote:
>> Hmm, i'm not sure that i understood you. You suppose that the insert in
>> sessionlog doesn't returns the correct id but 0, which causes the 0 in
>> the successesive inserts into commitlog and historylog?
> 
> Basically, yes.  There's no standardised way in SQL of returning the id
> of the last insert... indeed some (Firebird) can't do it at all.  In
> ODBC you can use select @@identity but that needs to be supported by the
> underlying driver.  Most of the native drivers have a function that
> returns it.
> 
Ah, ok. Now i understand. Well, this is because there is no standard about
"identity" columns. MSSQL manages them entirely (you can disable this),
PostGreSQL automatigally creates a sequence and auto-increments
(overwritable), MySql has an auto-increment feature, IIRC. But many
databases doesn't support such auto-valued columns at all (Oracle).
Consequently only those databases with auto values provide a way to return
the generated value.

Back to the original posting: You're right: select @@identity doesn't work
with PostGreSQL. The error from the log is "ERROR:  column "identity" does
not exist".

Olaf





More information about the cvsnt mailing list