Estou executando o exemplo a partir do seguinte site:
MySQL:: Manual de Referência do MySQL 5.0:: 12.1.11 Sintaxe CREATE TRIGGER
eo problema é que desencadeia não pode ser definida por algum motivo:
Código:
CREATE DATABASE IF NOT EXISTS triggertest;
USE triggertest;
CREATE TABLE test1(a1 INT);
CREATE TABLE test2(a2 INT);
CREATE TABLE test3(a3 INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
CREATE TABLE test4(
a4 INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
b4 INT DEFAULT 0
);
delimiter |
CREATE TRIGGER testref BEFORE INSERT ON test1
FOR EACH ROW BEGIN
INSERT INTO test2 SET a2 = NEW.a1;
DELETE FROM test3 WHERE a3 = NEW.a1;
UPDATE test4 SET b4 = b4 + 1 WHERE a4 = NEW.a1;
END;
|
delimiter ;
eo resultado é o seguinte:
Código:
Error: 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 'delimiter | CREATE TRIGGER testref BEFORE INSERT ON test1 FOR EACH ROW BE' at line 1
O banco de dados é inicialmente vazia, sem outras tabelas ou dispara. Qual é exatamente o problema aqui e como posso corrigir isso? Thanks in advance.
Código:
# mysql -v
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 164
Server version: 5.1.28-rc FreeBSD port: mysql-server-5.1.28_1