Jason Clifford wrote:
On Fri, 20 Jun 2003, Raf wrote:

How safe is this in environments where lots of separate processes, using separate connections to the database, are updating the same table?

AFAIK, this is the safest method of updating the same table using different processes. The sequence never offers the same value for two different requests, even when they're parallel.


With the MySQL insert_id method you get the result of a completed insertion so you know for certain what it is.

MySQL don't implement transactions.
When you "commit" your transaction, you're sure that everything is fine. And then you could get the current value from the sequence using


SELECT sequence_name.currval (...)

or something like this. I don't remember exactly the attribute name, please take a look at your manual.

If you grab the number in advance isn't there a risk that another process will insert a record first and get the sequence number you're expecting?

Never. PG handles this concurrency graciously for you. Have a nice day. -- =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Luis Campos de Carvalho Analista de sistemas Intergal Sistemas http://www.integral.com.br =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=




Reply via email to