Salve a tutti, sono nuovo di questo forum, vi ho trovato perchè ho un enorme problema. Non riesco a creare i trigger in Mysql.
Questo è il mio trigger:
codice:CREATE TRIGGER totale_documento_vendita_insert AFTER INSERT ON articolo_appartiene_a_documento_vendita FOR EACH ROW DECLARE tot_imp_articolo float; DECLARE iva_articolo int; DECLARE tot_iva_articolo float; BEGIN Select iva_articolo = IVA from articolo where codice = new.codice; tot_imp_articolo = new.prezzo_vendita-(new.prezzo_vendita*new.sconto/100))*new.quantita; tot_iva_articolo = tot_imp_articolo * iva_articolo / 100; update documento_vendita set totale = totale + tot_imp_articolo + tot_iva_articolo where id = new.id; END;
Non capisco dov'è il problema,questo è l'errore che mi viene restituito:
Mi potete aiutare?Errore
query SQL:
CREATE TRIGGER totale_documento_vendita_insert AFTER INSERT ON articolo_appartiene_a_documento_vendita
FOR EACH
ROW DECLARE tot_imp_articolo FLOAT;
Messaggio di MySQL:
#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 'DECLARE tot_imp_articolo float' at line 3
Grazie

Rispondi quotando