0
CREATE TRIGGER my_trigger BEFORE INSERT
ON employee
FOR EACH ROW BEGIN
INSERT INTO trigger_test VALUES('added a new employee');
END;

The above code works fine in pop sql but it shouldn't work because the delimiter by default is ';' and you can't change it in pop sql using the 'DELIMITER' command, so the code should end at the INSERT statement and therefore an error should be thrown. Can someone explain why this is happening?

The Impaler
  • 45,731
  • 9
  • 39
  • 76
  • The delimiter tells the database client how to group lines of code and send them to the database server as a single unit. In your case, it seems that pop sql is somehow guessing correctly that you want to send all those five lines to be executed as a whole. Maybe you are highliting/selecting them, before executing or something else. The DELIMITER command can be useful for non-interactive code that is run in the server as a "SQL script". – The Impaler Feb 28 '23 at 15:24
  • If you're using a GUI, it may not care about delimiters, it does its own grouping. – Barmar Feb 28 '23 at 15:42

0 Answers0