Il problema è che se provo a fare una DELETE per record i cui IDsentiero e IDtappa non esistono non mi restituisce nessun messaggio d'errore... perchè?
Forse uso male gli OLD? Ma per un BEFORE DELETE dovrebbe esserci l'OLD (per row trigger)
Codice PHP:
CREATE TRIGGER BEFORE_DELETE_ON_SENTIERO__HA__TAPPA
BEFORE DELETE ON SENTIERO__HA__TAPPA
FOR EACH ROW
BEGIN
-- NOW THIS QUERY WILL FAIL; it checks if the record that has to be deleted is in the table
IF NOT EXISTS ( SELECT *
FROM SENTIERO__HA__TAPPA as sht
WHERE OLD.IDsentiero=sht.IDsentiero and OLD.IDtappa=sht.IDtappa) THEN
SIGNAL SQLSTATE '45000'
SET MESSAGE_TEXT = 'DELETE: La tappa indicata non è nel sentiero; impossibile elimnarla';
END IF;
........
END$$

Rispondi quotando