Bug #24081 Unable to add compound statements in Trigger
Submitted: 8 Nov 2006 10:07 Modified: 8 Nov 2006 12:00
Reporter: Aftab Khan Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.24 OS:Windows (windows)
Assigned to: CPU Architecture:Any
Tags: triggers

[8 Nov 2006 10:07] Aftab Khan
Description:
I can not add comound statements in trigger, when ever I user 'begin' and 'end' keyword I always get following error.

Error

SQL query:

CREATE DEFINER = 'root'@ 'localhost'TRIGGER testref BEFORE INSERT ON cdr
FOR each
ROW BEGIN
INSERT INTO ncdr
SET name = 'xxx';
end;

MySQL said: Documentation
#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 'insert into ncdr set name='aftab'' at line 3 

How to repeat:
CREATE DEFINER = 'root'@ 'localhost'TRIGGER testref BEFORE INSERT ON cdr
FOR each
ROW BEGIN
INSERT INTO ncdr
SET name = 'xxx';
end;
[8 Nov 2006 12:00] Valeriy Kravchuk
This is not a bug. Please, read the manual:

http://dev.mysql.com/doc/refman/5.0/en/begin-end.html

and 

http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html

Set DELIMITER to something but ';' before defining triggers with compound statements.