Mysql Error 1064 Trigger
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up MySQL - Create Trigger Error 1064 (near 'DELIMITER ; ') up vote 0 down vote favorite 1 Hope everyone is well. I am trying to create a mysql trigger however i keep getting the following error: [Err] 1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'DELIMITER' at line 1 [Err] DELIMITER ; The code I have is as follows (please note, the actual file is 130 lines long I have just included the part where the problem is, or at least i believe it to be). /* BB Events Insert After Trigger */ DELIMITER $$ CREATE TRIGGER `event_insert_after` AFTER INSERT ON `bb_events` FOR EACH ROW BEGIN UPDATE `bb_device` SET `latitude` = NEW.`latitude`, `longitude` = NEW.`longitude`, `status_code` = NEW.`status_code`, `timestamp` = NEW.`timestamp`, `speed` = NEW.`speed`, `driver_id` = NEW.`driver_id`, `heading` = NEW.`heading` WHERE `account_id` = NEW.`account_id` AND `device_id` = NEW.`device_id`; IF NEW.`status_code` = 62465 THEN INSERT INTO `bb_journey` (`account_id`, `device_id`, `start_timestamp`, `start_street`, `start_city`, `start_state`, `start_country`, `start_latitude`, `start_longitude`, `start_geozone`, `start_odometer`) VALUES (NEW.`account_id`, NEW.`device_id`, NEW.`timestamp`, NEW.`street`, NEW.`city`, NEW.`state`, NEW.`country`, NEW.`latitude`, NEW.`longitude`, NEW.`geozone_id`, NEW.`odometer`); UPDATE `bb_device` SET `current_journey` = (SELECT `id` FROM `bb_journey` WHERE `account_id` = NEW.`account_id` AND `device_id` = NEW.`device_id` ORDER BY `id` DESC LIMIT 1) WHERE `account_id` = NEW.`account_id` AND `device_id` = NEW.`device_id`; END IF; IF NEW.`status_code` = 62467 THEN UPDATE `bb_journey` SET `end_timestamp` = NEW.`timestamp`, `end_street` = NEW.`street`, `end_city` = NEW.`city`, `end_state` = NEW.`state`, `end_country` = NEW.`country`, `end_latitude` = NEW.`latitude`, `end_longitude` = NEW.`longitude`, `end_geozone` = NEW.`geozone_id`, `end_odometer` = NEW.`od
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up error 1064 in trigger mysql up vote -1 down vote favorite This is my first http://stackoverflow.com/questions/23082874/mysql-create-trigger-error-1064-near-delimiter time using mysql and I am tying to learn how to use trigger. Im using navicat, i go to table design and then go triggers tab. I create a trigger named testing and in definition I typed: delimiter | CREATE TRIGGER lpr.mytesting AFTER INSERT ON lpr.lpr_opt_upload FOR EACH ROW BEGIN set new.lpr_text := reverse(new.lpr_text); END; | delimiter ; All im tying to do is whenever something new is inserted, I reverse http://stackoverflow.com/questions/10690684/error-1064-in-trigger-mysql the text in lpr_text field. However, i get "1064 - you have an error in your SQL; check the manual that corresponds o your MySql server version for the right syntax to yse 'ON lpr_opt_upload' FOR EACH ROW create trigger testing before insert on lpr_op' at line 1." I dont understand what Im doing wrong, I am just copying an trigger example. //-------------------------------------------------------------------------// I figured out the problem. I am using navicat and in navicat trigger tab, you only type the body into the definition, Not the header (ex: CREATE TRIGGER lpr.mytesting AFTER INSERT ON lpr.lpr_opt_upload). There are check box next to the name of your trigger and you use those instead of writing your own header. mysql share|improve this question edited Apr 30 '13 at 1:07 Jocelyn 7,46242242 asked May 21 '12 at 18:35 help 3593825 thanks, you are right. –help May 21 '12 at 18:39 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote The DELIMITER command is a client command, which not all clients support (it doesn't get sent to the server at all, it just instructs the client how to tell statements apart in order that they get sent to the server correctly). References to it in the MySQ
log in tour help Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the http://dba.stackexchange.com/questions/72507/mysql-syntax-error-when-creating-a-trigger company Business Learn more about hiring developers or posting ads with us Database Administrators Questions Tags Users Badges Unanswered Ask Question _ Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are mysql error voted up and rise to the top MySQL Syntax Error When Creating a Trigger up vote 0 down vote favorite I am trying to create a trigger but I am getting a syntax error and I am not really sure why I am. CREATE TRIGGER Section_Insert AFTER INSERT ON Section -> FOR EACH ROW BEGIN -> INSERT INTO Audit(changeTime, tableName, Action) VALUES (NOW(), 'Section', 'INSERT'); ERROR 1064 (42000): You have an error in your mysql error 1064 SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 3 mysql trigger errors syntax share|improve this question asked Jul 27 '14 at 19:11 LearningMySQL 12 You need a delimiter and you are missing END –Mihai Jul 27 '14 at 19:16 Thank you that fixed it. –LearningMySQL Jul 27 '14 at 20:27 add a comment| 2 Answers 2 active oldest votes up vote 1 down vote You need to use the Delimiter /// first if you are creating a trigger. Delimiter /// CREATE TRIGGER Section_Insert AFTER INSERT ON Section FOR EACH ROW BEGIN INSERT INTO Audit(changeTime, tableName, Action) VALUES (NOW(), 'Section', 'INSERT'); End; /// share|improve this answer answered Jul 28 '14 at 4:56 Karthick 721419 add a comment| up vote 1 down vote Since the Trigger has a single line, you don't need a delimiter and you do not need BEGIN END CREATE TRIGGER Section_Insert AFTER INSERT ON Section FOR EACH ROW INSERT INTO Audit(changeTime, tableName, Action) VALUES (NOW(), 'Section', 'INSERT'); share|improve this answer answered Oct 27 '14 at 18:52 RolandoMySQLDBA 108k15139276 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as