Trigger created successfully but its not working as it should

I have created this trigger that inserts a record into another table once a record has been inserted in another table

DELIMITER $$
CREATE TRIGGER logan AFTER INSERT ON messagein
FOR EACH ROW
  BEGIN
  DECLARE le_number INT;
  SET le_number = (select messagefrom from messagein where id=NEW.id);
    insert into messageout (MessageTo,MessageText) VALUES(le_number,"Thank you for contacting our company.Our sales representatives shall be in touch with you soon.");
  END $$
DELIMITER ;

This trigger is created successfully but no message is inserted into the messageout table.What is the reason for this?.

Answers


This trigger is wrong, it contains two errors:

Try this code:

CREATE TRIGGER logan AFTER INSERT ON messagein
FOR EACH ROW
  BEGIN
    insert into messageout (MessageTo,MessageText) 
    VALUES(NEW.messagefrom,'Thank you for contacting our company.Our sales representatives shall be in touch with you soon.');
  END 

A link to working demo: http://sqlfiddle.com/#!2/bdbff/1


Need Your Help

Importing text file to Excel with VBA - multiple strings with same delimiter

regex excel vba

I'm trying to import a number of text files into Excel using the VBA code below. Whilst the code produces a list of the Transaction Sales Numbers with corresponding date for each file imported, I ...

TextArea in aspnet web service

c# web-services

I am writing a web service, as in put I will enter a subject and message,