alter table JCL_ORG_STAFFS add description varchar2(200)
/

begin
	jcl_droptable('JCL_ORG_ITEMCLASS');
END;
/
CREATE TABLE JCL_ORG_ITEMCLASS (
	FID NUMBER NOT NULL,
	FNO NVARCHAR2(50) NOT NULL,
	FNAME NVARCHAR2 (50) NOT NULL,
	FMEMO NVARCHAR2 (255) NULL ,
	CREATOR NUMBER NULL,
	CREATE_TIME DATE NULL,
	UPDATE_TIME DATE NULL,
	CONSTRAINT JCL_ORG_ITEMCLASS_PK PRIMARY KEY (FID)
)
    /
BEGIN
	jcl_dropsequence('JCL_ORG_ITEMCLASS_ID');
END;
/
CREATE SEQUENCE JCL_ORG_ITEMCLASS_ID INCREMENT BY 1 START WITH 1 nomaxvalue minvalue 1 NOCYCLE
/
CREATE
OR REPLACE TRIGGER JCL_ORG_ITEMCLASS_ID_TIGGER BEFORE INSERT ON JCL_ORG_ITEMCLASS FOR EACH ROW
BEGIN
SELECT
    JCL_ORG_ITEMCLASS_ID.nextval INTO:new.FID
FROM
    dual;
END;
/

begin
	jcl_droptable('JCL_ORG_ITEM');
END;
/
CREATE TABLE JCL_ORG_ITEM (
	FID NUMBER NOT NULL,
	FCLASSID NUMBER NOT NULL,
	FNO NVARCHAR2(50) NOT NULL,
	FNAME NVARCHAR2 (255) NOT NULL,
	FMEMO NVARCHAR2 (255) NULL,
	FDELETE NUMBER NOT NULL,
	CREATOR NUMBER NULL,
	CREATE_TIME DATE NULL,
	UPDATE_TIME DATE NULL,
	CONSTRAINT JCL_ORG_ITEM_PK PRIMARY KEY (FID)
)
    /
BEGIN
	jcl_dropsequence('JCL_ORG_ITEM_ID');
END;
/
CREATE SEQUENCE JCL_ORG_ITEM_ID INCREMENT BY 1 START WITH 1 nomaxvalue minvalue 1 NOCYCLE
/
CREATE
OR REPLACE TRIGGER JCL_ORG_ITEM_ID_TIGGER BEFORE INSERT ON JCL_ORG_ITEM FOR EACH ROW
BEGIN
SELECT
    JCL_ORG_ITEM_ID.nextval INTO:new.FID
FROM
    dual;
END;
/

declare
V_NUM number;
BEGIN
    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'HrmCompany_ed';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER HrmCompany_ed';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_COMP_ed';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_COMP_ed';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_COMP_del';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_COMP_del';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_dept_ed';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_dept_ed';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_dept_del';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_dept_del';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_job_ed';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_job_ed';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'JCL_ORG_job_del';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER JCL_ORG_job_del';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'hrmresource_ed';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER hrmresource_ed';
end if;

    V_NUM := 0;
select count(0) into V_NUM from user_triggers where trigger_name = 'cus_fielddata_jclgw';
if V_NUM > 0 then
    execute immediate 'DROP TRIGGER cus_fielddata_jclgw';
end if;
END;
/