D
D
Daniel2018-02-27 22:59:56
MySQL
Daniel, 2018-02-27 22:59:56

Why is mysql trigger not being created?

Why the completely copied mysql trigger does not work, I have already considered it to the holes. All databases exist with such fields.

mysql>
mysql>  USE  statistic;  CREATE TRIGGER`countryLog` AFTER INSERT ON `Country` FOR EACH ROW BEGIN INSERT INTO log(msg,row_id) values ('insert', NEW.id_country); END;
Database changed
ERROR 1064 (42000): 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 '' at line 1
ERROR 1064 (42000): 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 'END' at line 1
mysql>

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Melkij, 2018-02-27
@daniil14056

Because here you, on the contrary , did not change the command delimiter, which is what you need to do.
Such is the stupid mysql syntax, the parser needs to be specially explained where the trigger (or stored procedure) ends.

E
entermix, 2018-02-27
@entermix

CREATE TRIGGER `countryLog` AFTER INSERT ON `Country`
 FOR EACH ROW INSERT INTO log(`msg`, `row_id`) VALUES ('insert', NEW.id_country)

A
AVKor, 2018-02-27
@AVKor

Because here:
three requests (last - END;).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question