MySQL Forums
Forum List  »  Triggers

Re: How to create a before update trigger for 2 fields "expected_hash" and "identify_hash" (both allow null)
Posted by: Peter Brawley
Date: July 01, 2021 11:03AM

> IF (new.identify_hash = clientdb_mapping.expected_hash) THEN

If this is intended to reference the current row value of clientdb_mapping.expected_hash, use OLD.expected_hash.

> -- UPDATE clientdb_mapping SET identify_hash = clientdb_mapping.expected_hash;

Re-read the manual page on Triggers. An Update Trigger may not invoke Update on the table for which it's defined (obviously, since it would thus begin an infinite regress). Instead, write ...

SET new.identity_hash=old.expected_hash;

> DELETE FROM pi_hash_migration_mapping;

That cmd will delete all rows from pi_hash_migration_mapping. Is that intended?

Options: ReplyQuote

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.