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 02, 2021 07:51AM

Homework?

Quote

- While `expected_hash` is NULL, `identify_hash` may also be NULL ("nullable").

- while `expected_hash` is NOT NULL, `identify_hash` may be NULL
--> While `expected_hash` is NULL, `identify_hash` must NOT be non-NULL

- While `expected_hash` AND `identify_hash` is NOT NULL, `identify_hash` must == `expected_hash`.

What's unclear to you---how to turn those requirements into an IF...ELSE...END IF sequence referencing old old.expected_hash and old_identity_hash?

Read the manual pages on Triggers and on IF...ELSE...END IF, then give it a try. If you get stuck, post what you have here.



Edited 1 time(s). Last edit at 07/02/2021 08:10AM by Peter Brawley.

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.