CREATE OR REPLACE TRIGGER "TRI_DEPARTMENT_BEFORE_INSERT" BEFORE INSERT ON TBL_DEPARTMENT FOR EACH ROW BEGIN SELECT SEQ_DEPARTMENT.NEXTVAL INTO :NEW.DEPARTMENT_ID FROM DUAL; SELECT :new.department_id INTO :new.department_code FROM dual ; END;/
CREATE OR REPLACE TRIGGER "TRI_PERSON_BEFORE_INSERT" before INSERT ON tbl_person FOR EACH ROWDECLARE person_count number ;BEGIN SELECT seq_person.nextval INTO :new.person_id FROM dual ; SELECT max(person_sort)+1 INTO :NEW.person_sort FROM tbl_person WHERE department_id = :NEW.department_id; IF :NEW.person_sort IS NULL THEN :NEW.person_sort := 1 ; END IF ;END;/
CREATE OR REPLACE TRIGGER "TRI_REGIONS_BEFORE_INSERT" BEFORE INSERT ON TBL_REGIONS FOR EACH ROW BEGIN SELECT SEQ_REGIONS.NEXTVAL INTO :NEW.REGIONS_ID FROM DUAL; END;/
CREATE OR REPLACE TRIGGER "TRI_UNIT_BEFORE_INSERT" BEFORE INSERT ON TBL_UNIT FOR EACH ROW BEGIN SELECT SEQ_UNIT.NEXTVAL INTO :NEW.UNIT_ID FROM DUAL; END;/