drop trigger CheckMaxEnroll;

create trigger CheckMaxEnroll 
        before insert 
        on transcripts 
            referencing new as N 
        for each row 
        begin 
            if (:N.grade = 'I' and  
               (select maxenroll from schedule S 
		where N.crscode = S.crscode
                      and N.semester = S.semester) = 0)
             then 
               rollback;
            end if;
        end CheckMaxEnroll;     
.
run;

