I am facing a problem in creating a trigger and i am not sure why this is erroring out.can you please help me.
I have written a trigger mentioned below and it gives me this error upon trying to execute the trigger ...
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 'DECLARE store_itemid INTEGER; store_hostid INTEGER; store_desc VARCHAR(255);' at line 4
mysql> delimiter // CREATE TRIGGER init_trigger AFTER INSERT ON test_trigger FOR EACH ROW DECLARE store_itemid INT; store_hostid INT; store_desc VARCHAR(255); store_key VARCHAR(255); store_lastvalue VARCHAR(255); store_lastclock VARCHAR(255); store_preval INT; store_status INT; BEGIN SELECT itemid into store_itemid,hostid into store_hostid,description into store_desc,key_ into store_key,lastvalue into store_lastvalue,lastclock into store_lastclock,prevvalue into store_preval,status into store_status FROM test_triggers WHERE lastvalue > 80;
IF store_lastvalue > 80 THEN
INSERT INTO test_triggers1 (itemid,hostid,description,key,lastvalue,lastclock,prevvalue,status) values (store_itemid,store_hostid,store_desc,store_key,store_lastvalue,store_lastclock,store_preval,store_status);
END IF; END; //