I'm trying to create a trigger to prevent inserts/updates on a table where the booking date is the same as the current date.
CREATE OR REPLACE TRIGGER driver_bookings BEFORE INSERT OR UPDATE ON Bookings
FOR EACH ROW WHEN (new.DriverID = old.DriverID)
BEGIN
IF TO_DATE(:new.StartDate, 'DD.MM.YYYY') = TO_DATE(sysdate,'DD.MM.YYYY');
raise_application_error(-20014, 'Booking cannot be made at this time.');
END IF;
END;
/
The table has (BookingID, BookingDate, StartDate).
To check that the trigger fires i am inserting this value into the table:
INSERT INTO Bookings VALUES (6,TO_DATE('9.11.2012','DD.MM.YYYY'), TO_DATE('09.11.2012/20:12','DD.MM.YYYY/HH24:MI');
For some reason the trigger allows the insert when it shouldnt and i have no idea whats wrong.
any help would be appreciated.