Re: [Zope] ZSQL: How to use return value from an 'INSERT'?
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
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
participants (2)
-
Jens Helweg -
Steen Suder