En réponse à Casey Duncan <casey@zope.com>:
This is a common operation. Most databases support a way to retrieve the last (or next) generated id for a table without resorting to using max(id)+1. I would refer to your database documentation on this.
The DB is Oracle8 with ZOracleDA. The trouble is, I need to generate this id in the first place, and as I said I'd rather not use a sequence. Thus the max(id)+1
As for concurrency, just make sure you perform both operations in a single database transaction. Many database adapters automatically wrap each method call in a transaction. So by putting both sql statements in one ZSQL method (separated using <dtml-var sql_delimiter>) will do what you want. If the DA doesn't automatically do implicit transactions for you then just wrap the whole thing with "begin" and "end" SQL statements yourself.
thanks. But what I want to make sure is that a transaction implies atomic operation, ie nobody else can perform another select max(id)+1 before the select of the first caller is performed. Is that OK with my current setup ?