Using lightweight transactions
INSERT and UPDATE statements that use the IF clause support lightweight transactions, also known as Compare and Set (CAS).
Register a new user.
INSERT INTO users (login, email, name, login_count) VALUES ('jdoe', 'email@example.com', 'Jane Doe', 1) IF NOT EXISTS;
Perform a CAS operation against a row that does exist by adding the predicate
for the operation at the end of the query. For example, reset Jane Doe's
UPDATE users SET email = ‘firstname.lastname@example.org’ WHERE login = 'jdoe' IF email = ‘email@example.com’;
Attention: Be sure this document version matches your product version