Jan M schreef:
How do I update a record obtained from a query result while ensuring that:
1) The record is the actual record in the database not a possible duplicate,
e.g. is there a built-in record number identifying the actual DB record or
do I have to organise that in the table structure.

There is no built-in record number, but many use AUTO-INCREMENT fields as a unique record ID.

In many queries you will retrieve data from more than one table. The result set may thus consist of combined and possibly generated data from more than one table and so you not have "the actual record" as a single entity.

2) The record hasnt been or cannot be changed by another thread/process,
possibly by. locking / re-reading the record (is there another way?).

InnoDB (an engine type, see online manual) provides a mechanism called "transactions" which allow you to lock the rows involved in your query (so others cannot change the data), update them, etc. After you complete your transaction the changes are committed to the database. In case of an problem you can "roll back" the transaction.

Regards, Jigal.

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Reply via email to