Hi
I wanted to create a trigger to fire on insert or update, when a room had already been booked. The reserved_For,reserved_Until are both Date fields and have the following format (to_date('21-11-2003 09:00','DD-MM-YYYY HH24:MI'),to_date('21-11-2003 11:00','DD-MM-YYYY HH24:MI').
I've create the following trigger and although the trigger is created, it does not work as when I try to enter the same infomation with a differnt pk it allows me to;
CREATE OR REPLACE TRIGGER DBRoom
BEFORE INSERT OR UPDATE OF reserved_For,reserved_Until
ON room_rev
FOR EACH ROW
BEGIN
IF new.reserved_For LIKE ld.reserved_For)
AND new.reserved_Until LIKE ld.reserved_Until)
THEN
RAISE_APPLICATION_ERROR(-20000, 'Room is Booked, try again');
END IF;
END DBroom;
------------------------------------------
Any suggestions?
I wanted to create a trigger to fire on insert or update, when a room had already been booked. The reserved_For,reserved_Until are both Date fields and have the following format (to_date('21-11-2003 09:00','DD-MM-YYYY HH24:MI'),to_date('21-11-2003 11:00','DD-MM-YYYY HH24:MI').
I've create the following trigger and although the trigger is created, it does not work as when I try to enter the same infomation with a differnt pk it allows me to;
CREATE OR REPLACE TRIGGER DBRoom
BEFORE INSERT OR UPDATE OF reserved_For,reserved_Until
ON room_rev
FOR EACH ROW
BEGIN
IF new.reserved_For LIKE ld.reserved_For)
AND new.reserved_Until LIKE ld.reserved_Until)
THEN
RAISE_APPLICATION_ERROR(-20000, 'Room is Booked, try again');
END IF;
END DBroom;
------------------------------------------
Any suggestions?