Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trigger Syntax in MySQL "5.051b community nt"

Status
Not open for further replies.

Clins

Programmer
May 13, 2009
7
TZ
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



 
I don't use mysql 5, but I think the syntax is

Code:
SELECT sender INTO phone_number FROM ozekimessagein WHERE sender = NEW.sender

-----------------------------------------
I cannot be bought. Find leasing information at
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top