tags:

views:

25

answers:

1

Hi all, I'm trying to create a trigger that monitor changes on a table and then insert those change to another table as follows

CREATE TRIGGER userChangePasswd
BEFORE UPDATE ON originalTable
FOR EACH ROW
BEGIN
INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable
END

mysql keeps showing the following error

ERROR 1064 (42000): 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 logs (email,clear,name ) SELECT email,clear,name FROM ' originalTable at line 5

the following statement works very file with a where clause criteria

INSERT INTO logs (email,clear,name ) SELECT email,clear,name FROM  originalTable

what's worng with the insertion statement within the trigger any ideas, Thanks in advance

A: 

I guess that this is for MySql and not for "Nysql".

CREATE TRIGGER `orgTbl_before_upd_tr` BEFORE UPDATE ON `orgTbl`

FOR EACH ROW BEGIN INSERT INTO newTbl (field1, field2) VALUES (old.field1, old.field2); END;

igors
yes its a typo