This is an working example of a Before Insert Trigger with an If statement and modifying the incoming values.
-- Reset the Active Delimiter so the ; will not be executed when the trigger code is loaded
DELIMITER |
-- Create the Trigger
CREATE TRIGGER CreditCard_GiftCardNoEncrypt
BEFORE INSERT ON CreditCard
FOR EACH ROW
BEGIN
IF (NEW.cardType !='GIFTCARD') THEN
SET NEW.cardNumber = DES_ENCRYPT(NEW.cardNumber,'f8zz9');
END IF;
SET NEW.encrypted = 1;
END
;
-- The Active Delimiter
|
-- Reset the Active Delimiter back to ;
DELIMITER ;
No comments:
Post a Comment