BEGIN
declare msg varchar(255);
IF NEW.update_by = 0 OR NEW.update_by='' OR NEW.update_by=Null THEN
set msg = concat('MyTriggerError: Trying to insert a invalied value: ', cast(new.id as char));
signal sqlstate '45000' set message_text = msg;
END IF;
END
====================
CREATE TRIGGER `allow_with_update_by` BEFORE INSERT ON `table_order`
FOR EACH
ROW BEGIN
IF NEW.update_by <>0
THEN
SET NEW.update_by = 2;
END IF ;
END ;
declare msg varchar(255);
IF NEW.update_by = 0 OR NEW.update_by='' OR NEW.update_by=Null THEN
set msg = concat('MyTriggerError: Trying to insert a invalied value: ', cast(new.id as char));
signal sqlstate '45000' set message_text = msg;
END IF;
END
====================
CREATE TRIGGER `allow_with_update_by` BEFORE INSERT ON `table_order`
FOR EACH
ROW BEGIN
IF NEW.update_by <>0
THEN
SET NEW.update_by = 2;
END IF ;
END ;
No comments:
Post a Comment