I
I
Ilya T.2020-10-29 09:24:06
MySQL
Ilya T., 2020-10-29 09:24:06

What's wrong with my trigger?

mariadb.
I'm trying to create a simple trigger:

create trigger replace_data
before insert on logs
for each row
begin
SET NEW.msg = replace(NEW.msg,'xxx','yyy');
end;


I get:
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '' at line 5

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lazy @BojackHorseman MySQL, 2020-10-29
@Insaned

24.1 Defining Stored Programs
If you use the mysql client program to define a stored program containing semicolon characters, a problem arises. By default, mysql itself recognizes the semicolon as a statement delimiter, so you must redefine the delimiter temporarily to cause mysql to pass the entire stored program definition to the server.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question