我尝试创建一个触发器,如果我键入了我不想要的值,就会引发错误。 示例:我有两个表,Patient和Appointment,在患者下面有行调用patient_type是IN或OUT,问题是如果我想将数据插入Appointment并且patient_id是IN,我想提出错误。< / p>
create or replace TRIGGER "appointment-OUT_PA"
BEFORE INSERT OR UPDATE
ON APPOINTMENT
FOR EACH ROW
BEGIN
IF (SELECT APPOINTMENT.PATIENT_ID, PATIENT.PATIENT_TYPE
FROM APPOINTMENT, PATIENT
WHERE PATIENT.PATIENT_TYPE = "IN") THEN
RAISE_APPLICATION_ERROR (-20500,
'You cannot insert appointment for In-Patient');
END IF;
END;