There's plenty of DB's that support AUTOINCREMENT (or some variant of that word) to generate a unique primary key.
But what about for those cases where I might want to know the key in advance of the row being inserted?
Or perhaps I want a GUID type situation, where the keys are not only unique within their table, but globally unique.
Perhaps I just don't want to use AUTOINCREMENT
The sloppy (?) way is to start a transaction, select max(pk) + 1, insert a row with the result, and end the transaction. Does this *always* guarantee uniqueness? I vaguely recall there was a way to do select AND update the table in one query (in Oracle). Is there a way to do this that is database-vendor neutral?
Other ideas? Best practices?
Thanks.
