Ad ogni modo mi sto avvicinando alla soluzione del malvagio trigger...
Certo che con delle slide serie ed un compilatore come quello del c++ avrei già risolto da un pezzo...
Mi dice:codice:CREATE TRIGGER Inserimento BEFORE INSERT ON Studenti FOR EACH ROW trig: BEGIN DECLARE trovato INT /*Se la matricola è nulla blocchiamo l'inserimento*/ IF NEW.Matr IS NULL THEN LEAVE trig END IF /*Contiamo quanti studenti ci sono con quella matricola*/ SELECT COUNT(*) INTO trovato FROM Studenti WHERE matr = new.matr; /*Se ce ne sono più di 0 vuol dire che esiste già, percui blocchiamo l'inserimento */ IF (trovato > 0) THEN LEAVE trig END IF /*Se arriva a questo punto vuol dire che è tutto ok percui può inserire lo studente*/ END
codice:Error Code : 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 'IF NEW.Matr is null then leave trig end if /*Contiamo quanti studenti ci son' at line 5 Execution Time : 00:00:00:000 Transfer Time : 00:00:00:000 Total Time : 00:00:00:000 Error Code : 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 'if (trovato > 0) then leave trig end if /*Se arriva a questo punto vuol dire' at line 2 Execution Time : 00:00:00:000 Transfer Time : 00:00:00:000 Total Time : 00:00:00:000

Rispondi quotando