[Zope] q: How should I get a guaranteed unique id in Zope?
Philippe Jadin
all@123piano.com
Tue, 15 Jan 2002 09:32:12 +0100
Joe Block wrote:
>
> I'm probably missing something in postgresql where I can do an insert
> and have it return whatever jobid it automatically generates. On the
> Zope side, I'm using ZPsycoPg as my postgres connection.
I'm almost sure you can have this unique ID generated by postgresql. In
mysql you can, so...
When you have an index field defined as unique in your sql db
(eventually auto increment), the db will take care of id uniqueness for you.
Imho it's safer than handling this on your own. The second step is to
find a way to get the latest inserted row in your table, and get the
unique Id from there. I have no idea how you do this in zope (maybe the
zsql method returns the unique id on exec?)
Good luck !
Philippe