IF ( numrows = 0 ) then begin RAISE_APPLICATION_ERROR(-20004,'Parent does not exist. Cannot insert child.'); end; end if; end; end if; end; / -- Insert trigger for Ocenki Create Trigger "ti_Ocenki" after insert on "Ocenki" referencing new as new_ins for each row declare numrows integer; begin -- restrict child Ocenki when parent Predmet insert if (:new_ins."n_predm" is not null) then begin select count( * ) into numrows from "Predmet" where :new_ins."n_predm" = "Predmet"."n_predm"; IF ( numrows = 0 ) then begin RAISE_APPLICATION_ERROR(-20004,'Parent does not exist. Cannot insert child.'); end; end if; end; end if; -- restrict child Ocenki when parent Student insert if (:new_ins."Nz" is not null) then begin select count( * ) into numrows from "Student" where :new_ins."Nz" = "Student"."Nz"; IF ( numrows = 0 ) then begin RAISE_APPLICATION_ERROR(-20004,'Parent does not exist. Cannot insert child.'); end; end if; end; end if; end; / Create role "Stud_admin" / Create role "Dekan" / Grant "Stud_admin" to "Petrov_P_P" / Grant "Dekan" to "Иванов_И_И" / /* Roles permissions */ Grant select on "Student" to "Stud_admin" / Grant update on "Student" to "Stud_admin" / Grant delete on "Student" to "Stud_admin" / Grant insert on "Student" to "Stud_admin" / Grant references on "Student" to "Stud_admin" / Grant select on "Student" to "Dekan" / Grant update on "Student" to "Dekan" / Grant delete on "Student" to "Dekan" / Grant insert on "Student" to "Dekan" / Grant references on "Student" to "Dekan" / Grant select on "Ocenki" to "Stud_admin" / Grant update on "Ocenki" to "Stud_admin" / Grant delete on "Ocenki" to "Stud_admin" / Grant insert on "Ocenki" to "Stud_admin" / Grant references on "Ocenki" to "Stud_admin" / Grant select on "Ocenki" to "Dekan" / Grant update on "Ocenki" to "Dekan" / Grant delete on "Ocenki" to "Dekan" / Grant insert on "Ocenki" to "Dekan" / Grant references on "Ocenki" to "Dekan" / Grant select on "Predmet" to "Stud_admin" / Grant update on "Predmet" to "Stud_admin" / Grant delete on "Predmet" to "Stud_admin" / Grant insert on "Predmet" to "Stud_admin" / Grant references on "Predmet" to "Stud_admin" / Grant select on "FCLT" to "Stud_admin" / Grant update on "FCLT" to "Stud_admin" / Grant delete on "FCLT" to "Stud_admin" / Grant insert on "FCLT" to "Stud_admin" / Grant references on "FCLT" to "Stud_admin" / Grant select on "SPECT" to "Stud_admin" / Grant update on "SPECT" to "Stud_admin" / Grant delete on "SPECT" to "Stud_admin" / Grant insert on "SPECT" to "Stud_admin" / Grant references on "SPECT" to "Stud_admin" / /* Users permissions */