I want to select information from the first table into third table after comparing the content in the second table, if the information are equal then record is being inserted into third table; the following is the trigger i composed.
DELIMITER |
CREATE TRIGGER troubleshoot_trig AFTER INSERT ON ozekimessagein
FOR EACH ROW
BEGIN
DECLARE soln_msg varchar(160);
DECLARE phone_number varchar(13);
DECLARE prob_code varchar(5);
SELECT INTO phone_number sender FROM ozekimessagein WHERE sender = NEW.sender;
SELECT INTO prob_code msg FROM ozekimessagein WHERE msg = NEW.msg;
SELECT INTO soln_msg msg FROM troubleshooter WHERE code = prob_code;
INSET INTO ozekimessageout(receiver, msg) VALUES(phone_number, soln_msg);
END
|
DELIMITER;
If i run the above the following is the error message i get:
Error
SQL query:
DELIMITER | CREATE TRIGGER troubleshoot_trig AFTER INSERT ON ozekimessagein
FOR EACH
ROW
BEGIN DECLARE soln_msg varchar( 160 ) ;
DECLARE phone_number varchar( 13 ) ;
DECLARE prob_code varchar( 5 ) ;
SELECT INTO phone_number sender
FROM ozekimessagein
WHERE sender = NEW.sender;
SELECT INTO prob_code msg
FROM ozekimessagein
WHERE msg = NEW.msg;
SELECT INTO soln_msg msg
FROM troubleshooter
WHERE code = prob_code;
INSET INTO ozekimessageout( receiver, msg ) VALUES (
phone_number, soln_msg
);
END |
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 'INTO phone_number sender FROM ozekimessagein WHERE sender = NEW.sender;
SELECT' at line 9
DELIMITER |
CREATE TRIGGER troubleshoot_trig AFTER INSERT ON ozekimessagein
FOR EACH ROW
BEGIN
DECLARE soln_msg varchar(160);
DECLARE phone_number varchar(13);
DECLARE prob_code varchar(5);
SELECT INTO phone_number sender FROM ozekimessagein WHERE sender = NEW.sender;
SELECT INTO prob_code msg FROM ozekimessagein WHERE msg = NEW.msg;
SELECT INTO soln_msg msg FROM troubleshooter WHERE code = prob_code;
INSET INTO ozekimessageout(receiver, msg) VALUES(phone_number, soln_msg);
END
|
DELIMITER;
If i run the above the following is the error message i get:
Error
SQL query:
DELIMITER | CREATE TRIGGER troubleshoot_trig AFTER INSERT ON ozekimessagein
FOR EACH
ROW
BEGIN DECLARE soln_msg varchar( 160 ) ;
DECLARE phone_number varchar( 13 ) ;
DECLARE prob_code varchar( 5 ) ;
SELECT INTO phone_number sender
FROM ozekimessagein
WHERE sender = NEW.sender;
SELECT INTO prob_code msg
FROM ozekimessagein
WHERE msg = NEW.msg;
SELECT INTO soln_msg msg
FROM troubleshooter
WHERE code = prob_code;
INSET INTO ozekimessageout( receiver, msg ) VALUES (
phone_number, soln_msg
);
END |
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 'INTO phone_number sender FROM ozekimessagein WHERE sender = NEW.sender;
SELECT' at line 9