Salve a tutti, premesso che non sono afferatissimo in materia di trigger, vi descrivo il mio problema:
sto usando phpmyadmin su un server remoto con mysql 5.0.22, e ho creato il seguente trigger:
e phpmyadmin mi stampa il seguente messaggio:codice:DELIMITER $$ CREATE TRIGGER chiesa_insert AFTER INSERT ON jos_chiesa FOR EACH ROW BEGIN INSERT INTO jos_territorio(id, id_territorio, genere, utente) VALUES (NULL, NEW.id, NEW.genere, NEW.utente); END; $$
Allora ho tolto il delimiter e i due $$ sia all'inizio che alla fine. Risultato:Errore query SQL:
DELIMITER $$ CREATE TRIGGER chiesa_insert
AFTER INSERT ON jos_chiesa
FOR EACH
ROW
BEGIN INSERT INTO jos_territorio( id, id_territorio, genere, utente ) VALUES ( NULL , NEW.id, NEW.genere, NEW.utente ); $$
Messaggio di MySQL: Documentazione #1064 - 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 chiesa_insert AFTER INSERT ON jos_chiesa FOR EACH' at line 1
Se provo a creare un semplice trigger così fatto:Errore
query SQL:
CREATE TRIGGER chiesa_insert AFTER INSERT ON jos_chiesa
FOR EACH
ROW
BEGIN
INSERT INTO jos_territorio( id, id_territorio, genere, utente )
VALUES (
NULL , NEW.id, NEW.genere, NEW.utente
);
Messaggio di MySQL: Documentazione
#1064 - 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 'INSERT INTO jos_territorio( id, id_territorio, genere, utente )
VALUES (
NULL ' at line 4
il trigger viene correttamente creato.codice:CREATE TRIGGER chiesa_insert AFTER INSERT ON jos_chiesa FOR EACH ROW BEGIN END;
Suppongo che a questo punto la sintassi sbagliata stia nella insert, ma sinceramente non capisco dove stia sbagliando.
Qualcuno ha qualche idea? Vi ringrazio anticipatamente.

Rispondi quotando