[Zope] ZSQL: How to use return value from an 'INSERT'?

Steen Suder CAB@Earthling.net
Wed, 17 Nov 1999 18:14:04 +0000


Jens Helweg wrote:
> 
> Steen Suder <sfs@kollegie6400.dk> wrote:
> > I'm using PostgreSQL 6.5 and Zope 2.x on RH6.
> 
> > When inserting a new record in database I'd like to access the return OID
> > from the INSERT query from within my ZSQL method.
> 
> > That is: if it returns anything... psql does return the OID.
> 
> > How do I do?
> 
> You can execute a second SQL-Method, i.e.:
> 
> <dtml-var sql_delimiter>
> SELECT MAX(OID) FROM your_table
> 
> to get something like an autoincremented primary key
> that was generated by your INSERT statement.
<CUT>

That's approx. what I came up with afterwards. To maintain integrity,
I'll have to wrap everything in transaction and perhaps lock the entire
tables.

I'm working on it now.

-- 
Best regards / Mvh.,
Steen Suder
sysadm kollegie6400.dk
OpenSource --- Sign of the time