toprashantjha Posted November 21, 2008 Share Posted November 21, 2008 Hi all, I am very new with MYSQL.. i was trying to create one trigger as mentioned in the code given bellow... But it is not creating trigger and if i remove BEGIN and END from the query then it is working fine (if i go for only on action). any idea???? i am using MYSQL GUI V6.0 CREATE TRIGGER TBL_TEST_TRIGGER AFTER UPDATE ON TBL_TEST_PRASHANT_EMPLOYEE3 FOR EACH ROW BEGIN UPDATE TBL_TEST_PRASHANT_EMPLOYEE1 SET name = 'test' ; UPDATE TBL_TEST_PRASHANT_EMPLOYEE4 SET FLD_DEPT = 'test' ; END; Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/ Share on other sites More sharing options...
gnawz Posted November 21, 2008 Share Posted November 21, 2008 I think your= are using unstable SQL statements.. Try: CREATE TRIGGER TBL_TEST_TRIGGER AFTER UPDATE ON TBL_TEST_PRASHANT_EMPLOYEE3 FOR EACH ROW UPDATE TBL_TEST_PRASHANT_EMPLOYEE1 SET name = 'test', EMPLOYEE4 SET FLD_DEPT = 'test'; ; Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/#findComment-695226 Share on other sites More sharing options...
toprashantjha Posted November 21, 2008 Author Share Posted November 21, 2008 Thanks for the reply.. Above query is correct only ..got the solution... the problem was not using delimiter .... Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/#findComment-695230 Share on other sites More sharing options...
Mchl Posted November 21, 2008 Share Posted November 21, 2008 Exactly... what I was just going to post... DELIMITER $$ CREATE TRIGGER TBL_TEST_TRIGGER AFTER UPDATE ON TBL_TEST_PRASHANT_EMPLOYEE3 FOR EACH ROW BEGIN UPDATE TBL_TEST_PRASHANT_EMPLOYEE1 SET name = 'test' ; UPDATE TBL_TEST_PRASHANT_EMPLOYEE4 SET FLD_DEPT = 'test' ; END $$ DELIMITER ; Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/#findComment-695231 Share on other sites More sharing options...
fenway Posted November 21, 2008 Share Posted November 21, 2008 You might want to consider naming your trigger with a prefix that tell you when they are triggered (like "AU_" for after update). Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/#findComment-695740 Share on other sites More sharing options...
Mchl Posted November 21, 2008 Share Posted November 21, 2008 I do it as a suffix actually. Quote Link to comment https://forums.phpfreaks.com/topic/133631-solved-trigger-problem/#findComment-695747 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.