以下触发是停止重复预订房间并为预约提供替代房间。我在展示房间时遇到了问题。你能告诉我哪里出错了吗?
CREATE OR REPLACE TRIGGER CHECK_APPOINTMENT
BEFORE INSERT OR UPDATE OF APP_DATE,C_NO,
RM_NO,APP_TIME ON APPOINTMENT
FOR EACH ROW
DECLARE
CURSOR C_APP
IS
SELECT APP_DATE,C_NO,APP_TIME,RM_NO
FROM APPOINTMENT;
V_APP_DATE APPOINTMENT.APP_DATE%TYPE;
V_APP_TIME APPOINTMENT.APP_TIME%TYPE;
V_C_NO APPOINTMENT.C_NO%TYPE;
V_RM_NO APPOINTMENT.RM_NO%TYPE;
I_RM_NO APPOINTMENT.RM_NO%TYPE;
RM_BKED_ERROR EXCEPTION;
BEGIN
OPEN C_APP;
FETCH C_APP INTO V_APP_DATE,V_C_NO,V_APP_TIME,V_RM_NO;
IF :NEW.C_NO=V_C_NO
AND:NEW.RM_NO=V_RM_NO
AND:NEW.APP_DATE=V_APP_DATE
AND:NEW.APP_TIME=V_APP_TIME
THEN
RAISE RM_BKED_ERROR;
END IF;
SELECT R.RM_NO
INTO I_RM_NO
FROM ROOM R,BRANCH B
WHERE R.RM_NO <> :NEW.RM_NO
AND B.BRN_NO = :NEW.BRN_NO
AND B.BRN_NO=R.BRN_NO
GROUP BY R.RM_NO;
EXCEPTION
WHEN RM_BKED_ERROR THEN
Raise_Application_error (-20000, 'ROOM ALREADY BOOKED FOR AN APPOINTMENT.THE FOLLOWING ROOMS ARE AVAILABLE '||I_RM_NO);
CLOSE C_APP;
END;
/