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

Jens Helweg helweg@innominate.de
17 Nov 1999 18:35:54 GMT


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.

-- 
helweg@innominate.de
                                                        innominate AG
                                                    networking people
fon: +49.30.308806-14 fax: 77               web: http://innominate.de