MySQL Forums
Forum List  »  Triggers

The syntax error about creating trigger in phpMyAdmin
Posted by: Linda Zhong
Date: August 13, 2007 02:56PM

Hi,
I always have syntax error when creating trigger in SQL tab in phpMyAdmin.
My code is every simple, they are:


DELIMITER $$

DROP TRIGGER IF EXISTS `check_rows`$$

CREATE TRIGGER `check_rows` AFTER INSERT ON `my_table`
FOR EACH ROW
BEGIN
DECLARE my_id VARCHAR(36);
DECLARE done INT DEFAULT 0;
DECLARE new1 CURSOR FOR SELECT DISTINCT my_id FROM my_table;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
END$$

DELIMITER ;

----------------
After I run it, I got error::

SQL query:

DELIMITER $$ DROP TRIGGER IF EXISTS `check_rows` $$ CREATE TRIGGER `check_rows` AFTER INSERT ON `my_table`
FOR EACH
ROW
BEGIN DECLARE my_id VARCHAR( 36 ) ;



MySQL said:

#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 $$

DROP TRIGGER IF EXISTS `check_rows`$$

CREATE TRIGGER `check' at line 1

--------------------
then, if I run the code:

CREATE TRIGGER `check_rows` AFTER INSERT ON `my_table`
FOR EACH ROW
BEGIN
DECLARE my_id VARCHAR(36);
DECLARE done INT DEFAULT 0;
DECLARE new1 CURSOR FOR SELECT DISTINCT my_id FROM my_table;
DECLARE CONTINUE HANDLER FOR SQLSTATE '02000' SET done = 1;
END;


I got the same error.
----------------------------

If I run the code:

CREATE TRIGGER `check_rows` AFTER INSERT ON `my_table`
FOR EACH ROW
BEGIN
END;

Finally, the trigger will be created successfully with EMPTY statement between BEGIN and END.


------------------------------

I have no idea. Is there something to need to add to my phpMyAdmin configuration? I have phpMyAdmin 2.8.1. Which document that I should to follow for creating trigger syntax? ( I don't think it is http://dev.mysql.com/doc/refman/5.0/en/create-trigger.html).

Any help for this? Thanks in advance.

Linda

Options: ReplyQuote


Subject
Views
Written By
Posted
The syntax error about creating trigger in phpMyAdmin
15545
August 13, 2007 02:56PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.