Bug #23061 Cannot create a trigger in a script tab
Submitted: 6 Oct 2006 19:25 Modified: 7 Oct 2006 2:36
Reporter: marc castrovinci (Basic Quality Contributor) Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Query Browser Severity:S2 (Serious)
Version:1.2.4 OS:Linux (Ubuntu Linux)
Assigned to: CPU Architecture:Any
Tags: error 1064, script, syntax, trigger

[6 Oct 2006 19:25] marc castrovinci
Description:
When I try to create any, and even a simple trigger in the Query Browser I get the error:

Error while execeuting query: CREATE TRIGGER test 
BEFORE INSERT ON testtab
FOR EACH ROW
BEGIN
	SET NEW.MOD_DATE = NOW():
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 'SET NEW.MOD_DATE = NOW()' at line 5 (errno: 1064)
Click 'Ignore' if you'd like to have this error ignored until the end of the script.

The thing is it will compile fine if you run in in the query tab. 

How to repeat:
Set up:

CREATE DATABASE test;

CREATE TABLE `test`.`testtab` (
  `id` INTEGER  NOT NULL,
  `mod_date` DATETIME  NOT NULL
)
ENGINE = MYISAM;

Open a new script tab. Try to run the following command:

CREATE TRIGGER test 
BEFORE INSERT ON testtab
FOR EACH ROW
BEGIN
	SET NEW.mod_date = NOW();
END;

It should give you the aforementioned error.

Open a new query tab and run the same command.
It should create the trigger
[7 Oct 2006 2:36] MySQL Verification Team
Thank you for the bug report. I changed your script to:

DELIMITER //
CREATE TRIGGER test 
BEFORE INSERT ON testtab
FOR EACH ROW
BEGIN
	SET NEW.mod_date = NOW();
END//

Please try the above. Thanks in advance.