Hello. I am just learning Zope. I have a few projects that I created using Apache and FastCGI, but Zope has caught my eye. In learning Zope, I came across a stumbling block, and that is how to retrieve the OID that an INSERT query will create when using Postgre. In previous projects, when a new record (let's say a contact) was created, if the INSERT was successful, the user was automatically refreshed to the newly created record. (If not, an error was displayed). I can not figure out how to get the OID that is returned by issuing a INSERT SQL statement. Can anyone help me out with this one? Thanks! Jeremy - jeremy@cowgar.com
Jeremy Cowgar <jcowgar@bhsys.com> said:
In learning Zope, I came across a stumbling block, and that is how to retrieve the OID that an INSERT query will create when using Postgre.
You shouldn't use database internal oid's anywhere in your code, if that's what you mean by OID. Give every table a primary key "ident" (or whatever - my favourite, "id", doesn't work well in Zope; the second-best, "oid", is already in use under pgsql). Insert using "null" or "nextval('tablename_ident_seq')" (the exact name of the sequence associated with the serial field is given during the table create). Retrieve the newly inserted record's id by doing "select currval('tablename_ident_seq')".
participants (2)
-
Jeremy Cowgar -
news@cdegroot.com