Hi,
here is the full code of trigger with exception, i couldn't add the
coReq condtion, because coReg is declared as char(1) in above
table, where is the id of the coreq class comign from? If you can
give that i can add it,
CREATE TRIGGER prevent_class_insertion --trigger definitions
BEFORE INSERT ON customers --to be triggered before insert
FOR EACH ROW
DECLARE
CURSOR c_classIds IS select * from SCHEDULE where
studentId=OLD.studentId and classId in(select PrereqId from
CLASSREQ where classId=NEW.classId)--selecting if there are any
rows with that student taking the prerequisite classes
BEGIN
open c_classIds;
if c_classIds%notfound then--if no rows found means he didnt take
one of the pre requisute class
SIGNAL 'pre requisite course not taken'--signal stops the
insertion
end if
CLOSE c_classIds;
END;
Thumbs up if this was helpful, otherwise let me know in comments
HW3.STUDENT Id First:yarchar10) yarchar(5) Last: yareh 10) HW3.CLASS ClassId: yarchar(5) Name: yareh 10) Desc: varchar(20) HW3.CLASSREQ...