Luke Taylor wrote:
> Isn't it rather risky using MAX to obtain the next primary key, as
> there could be multiple threads creating new entities, and two or more
> of them could obtain the same value for MAX and attempt to use the same
> primary key?

If done outside a transaction, you could risk
the above scenario. But if the "SELECT MAX(...) ..."
and the "CREATE ..." is done in the same transaction,
the transaction isolation ensures that this cannot
happen.

> The best way I'm aware of is to use a DB sequence, but
> this involves proprietary SQL.

Yes, sequences are better, but not all databases support
them.


Best Regards,

Ole Husgaard.


--
--------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
List Help?:          [EMAIL PROTECTED]

Reply via email to