CREATE TABLE JCL_ORG_ONJOB (
   ID NUMBER NOT NULL,
   DATA_ID NUMBER NULL,
   SUPER_ID NUMBER NULL,
   TYPE NUMBER NULL,
   ON_JOB_NUM NUMBER NULL,
   STAFF_NUM NUMBER NULL,
   DIMENSION NUMBER NULL,
   CREATOR NUMBER NULL,
   CREATE_TIME NVARCHAR2(100) NULL,
   UPDATE_TIME NVARCHAR2(100) NULL,
   CONSTRAINT JCL_ORG_ONJOB_PK PRIMARY KEY (ID)
);
/

CREATE SEQUENCE JCL_ORG_ONJOB_ID INCREMENT BY 1 START WITH 1 nomaxvalue minvalue 1 NOCYCLE;
/

CREATE
OR REPLACE TRIGGER JCL_ORG_ONJOB_ID_TIGGER BEFORE INSERT ON JCL_ORG_ONJOB FOR EACH ROW
BEGIN
SELECT
    JCL_ORG_ONJOB_ID.nextval INTO:new.ID
FROM
    dual;
END;
/

INSERT INTO JCL_ORG_ONJOB(DATA_ID,SUPER_ID,TYPE,ON_JOB_NUM,STAFF_NUM,CREATOR,CREATE_TIME,UPDATE_TIME)
SELECT id,supsubcomid,1,0,0,1,SYSDATE,SYSDATE from hrmsubcompany;
/

INSERT INTO JCL_ORG_ONJOB(DATA_ID,SUPER_ID,TYPE,ON_JOB_NUM,STAFF_NUM,CREATOR,CREATE_TIME,UPDATE_TIME)
SELECT id,supdepid,2,0,0,1,SYSDATE,SYSDATE from hrmdepartment;
/

