0

i got a problem here , in MYSQL i have:

1-Table called "norte" it has a column called "nortel" 2-Table called "bitacora" it has a column called "telefono"

im making a trigger for copying this information for example whenever i add something to "norte" table i want it to be automatically copied to bitacora table, i dunno what im doing wrong here´s my trigger

CREATE TRIGGER insertar AFTER INSERT ON norte
FOR EACH ROW 
BEGIN
INSERT INTO bitacora SET telefono = NEW.nortel 
END; 

the problem here is that it says unexpected END expecting';'

but if i delete the "END" it says

CREATE TRIGGER insertar AFTER INSERT ON norte
FOR EACH ROW 
BEGIN
INSERT INTO bitacora SET telefono = NEW.nortel;

Unexpected END_OF_INPUT expecting ';'

3 Answers 3

1

You need to change the delimiter.

delimiter |
CREATE TRIGGER insertar AFTER INSERT ON norte
FOR EACH ROW 
BEGIN
    INSERT INTO bitacora (telefono) values (NEW.nortel);
END
|
delimiter ;

Otherwise the DB thinks your trigger statement ends at the first ; and then it would be incomplete.

Sign up to request clarification or add additional context in comments.

Comments

0

You are missing a " ; " after the NEW.nortel:

It should be:

CREATE TRIGGER insertar AFTER INSERT ON norte 
FOR EACH ROW 
BEGIN 
  INSERT INTO bitacora SET telefono = NEW.nortel; 
END;

sqlfiddle demo

1 Comment

Thx for your; help i used the first answer and it seems it worked anyways thx both for responding me :) HAVE A GREAT DAY
0
DELIMITER $$


CREATE TRIGGER row_update_trigger  AFTER INSERT ON returns_loading_dc 
  FOR EACH ROW BEGIN
    INSERT INTO   Returns_receiving_Fc 
    set 
      Var_key=NEW.Var_key,
      Product_Title=NEW.Product_Title,
      Building=NEW.Building,
      Hub_ID=NEW.hub_id,
      JPIN=NEW.JPIN,
      Tagging_Required=NEW.Tagging_Required,
      Food_Non_Food=NEW.Food_Non_Food,
      Qty_loaded_from_hub=NEW.Total_Quantity_Loaded;


END $$ need help

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.