[cvsnt-dev] Re: postgres doesn't do INSERT ... RETURNS

David Somers dsomers at omz13.com
Mon Jul 24 15:31:35 UTC 2006


Community technical support mailing list was retired 2010 and replaced with a professional technical support team. For assistance please contact: Pre-sales Technical support via email to sales@march-hare.com.


Tony Hoyle wrote:

> David Somers wrote:
>> Tony,
>> 
>> cvsapi/db/postgres/PostgresConnection is broken.
>> ::ExecuteAndReturnIdentity makes use of "RETURNING" which is an ORACLE
>> ::(and
>> SQLITE?)-specific option.
> 
> According to the to a site I read that's the recommended way of getting
> the id
> back on postgres....  maybe only works on the latest one.

Not on 8.1.4 which is the latest and greatest.

I saw a patch that implemented it about a year ago but I don't know the
status of it.

> Can't see any other way of doing it that's safe (using two statements is
> not safe as you may have many clients inserting).

Isn't the SessionId unique and only inserted once? So:

INSERT INTO SessionLog ( ... SessionId ...) Value ( ... 'XXX' ... )
SELECT id FROM SessionLog WHERE SessionId='XXX'

BTW, I do find your audit schema a bit odd in that sessionid in sessionlog
is not used throughout the other tables, but instead you seem to refer to
it indirectly by the id of sessionlog. (Having sessionid meaning different
things in different tables is also a tad confusing.)

David


More information about the cvsnt-dev mailing list