CREATE OR REPLACE TRIGGER Guest_Change_In_WorkingHour
BEFORE INSERT OR UPDATE OR DELETE ON guest
BEGIN
IF TO_NUMBER(TO_CHAR(SYSDATE,'hh24')) < 8 -- cant do anything before 8:00am
OR TO_NUMBER(TO_CHAR(SYSDATE,'hh24')) >= 5
-- changes must be made BEFORE 5:00pm
OR TO_CHAR(SYSDATE,'dy') in ('sun','sat') THEN -- nothing on weekends
RAISE_APPLICATION_ERROR (-20000, 'Satff changes only allowed during business hours.');
END IF;
END;
/
This trigger for during working hours (8AM To 5PM) can perform insert, delete and update data. For my problem is when the time is 4.00AM still can insert, delete and update data. I found that this trigger ignore AM and PM. How to solve?