Pages

Friday, December 23, 2011

How to resolve #Error Code : 1235 in Mysql

error:1235 mysql
Have you ever got '#Error Code : 1235 This version of MySQL doesn't yet support multiple triggers with the same action time and event for one table'??. If so, this post will discuss about it.
This error:1235 occurs because of executing trigger update in the same table of trigger. For example, as in this code below :

DELIMITER $$
DROP TRIGGER IF EXISTS bfr_upd_billing$$
CREATE TRIGGER bfr_upd_billing
BEFORE UPDATE ON billing FOR EACH ROW
BEGIN
    update billing set flg_sync = '0' where billing_no = NEW.BILLING_NO;  
END$$
DELIMITER ;
In that code we will get #error:1235 because we want to update a field in table 'billing', whereas we create trigger on that table.
To resolve this error, we need to fix this code like below :

DELIMITER $$
DROP TRIGGER IF EXISTS bfr_upd_billing$$
CREATE TRIGGER bfr_upd_billing
BEFORE UPDATE ON billing FOR EACH ROW
BEGIN
  SET NEW.FLG_SYNC='0';  
END$$
DELIMITER ;
Well, actually we need not to run update again on trigger body.

No comments:

Post a Comment

Don't Forget To Join Our Community
×
Widget