/**Begin D:\PDM_UPGRADE\PDM1\HDM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACKINCHARGE') 
 CREATE TABLE T_HDM_SECBACKINCHARGE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACKINCHARGEIN') 
 CREATE TABLE T_HDM_SECBACKINCHARGEIN (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACKSUPERIOR') 
 CREATE TABLE T_HDM_SECBACKSUPERIOR (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACKSUPERIORIN') 
 CREATE TABLE T_HDM_SECBACKSUPERIORIN (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACK') 
 CREATE TABLE T_HDM_SECBACK (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FISEXISTSWORKFLOW CHAR(1) DEFAULT ' ' NOT NULL,
FAUDITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAFFRECORDID BIGINT DEFAULT 0 NOT NULL,
FAFFACTIONID BIGINT DEFAULT 0 NOT NULL,
FLABORRELTYPEID BIGINT DEFAULT 0 NOT NULL,
FLABORRELSTATUSID BIGINT DEFAULT 0 NOT NULL,
FPOSTYPEID BIGINT DEFAULT 0 NOT NULL,
FPOSSTATUSID BIGINT DEFAULT 0 NOT NULL,
FBACKSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FCOUNTRYBACKID BIGINT DEFAULT 0 NOT NULL,
FBASELOCATIONBACKID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYBACKID BIGINT DEFAULT 0 NOT NULL,
FDEPTBACKID BIGINT DEFAULT 0 NOT NULL,
FPOSPATTERNBACK VARCHAR(2) DEFAULT ' ' NOT NULL,
FPOSITIONBACKID BIGINT DEFAULT 0 NOT NULL,
FJOBBACKID BIGINT DEFAULT 0 NOT NULL,
FPOSTSTANDARDBACKID BIGINT DEFAULT 0 NOT NULL,
FBACKDATE DATETIME,
FENDDATE DATETIME,
FDURATION INT DEFAULT 0 NOT NULL,
FREACHDATE DATETIME,
FSTARTDATE DATETIME,
FSECBACKREASONID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FSUBMITNOTICSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FSTOPNOTICSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FEFFECTSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FEFFECTTIME DATETIME,
FGENBYTERMRECORD VARCHAR(2) DEFAULT ' ' NOT NULL,
FCMPEMPBACKID BIGINT DEFAULT 0 NOT NULL,
FTERMINATERSN NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTERMINATEUSER BIGINT DEFAULT 0 NOT NULL,
FTERMINATETIME DATETIME,
FSECONDMENTRECORDID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FERMANFILEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACK_A') 
 CREATE TABLE T_HDM_SECBACK_A (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FBARCODE VARCHAR(60) DEFAULT ' ' NOT NULL,
FINPUTDEVICETYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FEVENTEFFECTDATE DATETIME,
FISSUBMIT CHAR(1) DEFAULT ' ' NOT NULL,
FORGINID BIGINT DEFAULT 0 NOT NULL,
FADMINORGINID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPINID BIGINT DEFAULT 0 NOT NULL,
FORGBACKID BIGINT DEFAULT 0 NOT NULL,
FADMINORGBACKID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPBACKID BIGINT DEFAULT 0 NOT NULL,
FDATASOURCE VARCHAR(50) DEFAULT ' ' NOT NULL,
FDATASOURCEID BIGINT DEFAULT 0 NOT NULL,
FBILLTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FAFFAIRACTIONID BIGINT DEFAULT 0 NOT NULL,
FCOUNTRYINID BIGINT DEFAULT 0 NOT NULL,
FBASELOCATIONINID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYINID BIGINT DEFAULT 0 NOT NULL,
FDEPTINID BIGINT DEFAULT 0 NOT NULL,
FPOSPATTERNIN VARCHAR(2) DEFAULT ' ' NOT NULL,
FPOSITIONINID BIGINT DEFAULT 0 NOT NULL,
FPOSTSTANDARDINID BIGINT DEFAULT 0 NOT NULL,
FJOBINID BIGINT DEFAULT 0 NOT NULL,
FCMPEMPINID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECBACK_L') 
 CREATE TABLE T_HDM_SECBACK_L (
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FTERMINATERSN NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDCHG') 
 CREATE TABLE T_HDM_SECRECORDCHG (
FID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FMODIFYTIME DATETIME,
FCREATETIME DATETIME,
FORGID BIGINT DEFAULT 0 NOT NULL,
FBARCODE VARCHAR(60) DEFAULT ' ' NOT NULL,
FINPUTDEVICETYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FISEXISTSWORKFLOW CHAR(1) DEFAULT ' ' NOT NULL,
FAUDITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FEVENTEFFECTDATE DATETIME,
FISSUBMIT CHAR(1) DEFAULT ' ' NOT NULL,
FAFFRECORDID BIGINT DEFAULT 0 NOT NULL,
FAFFACTIONID BIGINT DEFAULT 0 NOT NULL,
FLABORRELTYPEID BIGINT DEFAULT 0 NOT NULL,
FLABORRELSTATUSID BIGINT DEFAULT 0 NOT NULL,
FPOSTYPEID BIGINT DEFAULT 0 NOT NULL,
FPOSSTATUSID BIGINT DEFAULT 0 NOT NULL,
FERMANFILEID BIGINT DEFAULT 0 NOT NULL,
FSECRECORDID BIGINT DEFAULT 0 NOT NULL,
FPERSONID BIGINT DEFAULT 0 NOT NULL,
FCHANGESTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FPLANSTARTDATE DATETIME,
FPLANENDDATE DATETIME,
FPLANDURATION INT DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FDURATION INT DEFAULT 0 NOT NULL,
FTERMINATERSN NVARCHAR(255) DEFAULT ' ' NOT NULL,
FTERMINATEUSER BIGINT DEFAULT 0 NOT NULL,
FTERMINATETIME DATETIME,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL,
FEFFECTSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FEFFECTTIME DATETIME,
FORGINID BIGINT DEFAULT 0 NOT NULL,
FCMPEMPINID BIGINT DEFAULT 0 NOT NULL,
FADMINORGINID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPINID BIGINT DEFAULT 0 NOT NULL,
FORGBACKID BIGINT DEFAULT 0 NOT NULL,
FADMINORGBACKID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPBACKID BIGINT DEFAULT 0 NOT NULL,
FCMPEMPBACKID BIGINT DEFAULT 0 NOT NULL,
FSUBMITNOTICSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FSTOPNOTICSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDCHG_L') 
 CREATE TABLE T_HDM_SECRECORDCHG_L (
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FTERMINATERSN NVARCHAR(255) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDCHG_A') 
 CREATE TABLE T_HDM_SECRECORDCHG_A (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
FDEPEMPID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDBUSEVENT') 
 CREATE TABLE T_HDM_SECRECORDBUSEVENT (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSOURCEENTITY VARCHAR(50) DEFAULT ' ' NOT NULL,
FBOID BIGINT DEFAULT 0 NOT NULL,
FISBUSINESSEVENTBO VARCHAR(10) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FCANCELEDEVENTID BIGINT DEFAULT 0 NOT NULL,
FOPERATEUSERID BIGINT DEFAULT 0 NOT NULL,
FOPERATEDATE DATETIME,
FEVENTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDEVENT') 
 CREATE TABLE T_HDM_SECRECORDEVENT (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FEVENTTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
FEXECUTEWAY VARCHAR(10) DEFAULT ' ' NOT NULL,
FSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FEVENTBATCHTYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
FCANCELEDEVENTID BIGINT DEFAULT 0 NOT NULL,
FOPERATEUSERID BIGINT DEFAULT 0 NOT NULL,
FOPERATEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECRECORDHIS') 
 CREATE TABLE T_HDM_SECRECORDHIS (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FVID BIGINT DEFAULT 0 NOT NULL,
FPRESTATUS VARCHAR(10) DEFAULT ' ' NOT NULL,
FPREBSED DATETIME,
FPREBSLED DATETIME,
FBUSIEVENTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECONDMENTRECORD') 
 CREATE TABLE T_HDM_SECONDMENTRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FBOID BIGINT DEFAULT 0 NOT NULL,
FISCURRENTVERSION CHAR(1) DEFAULT ' ' NOT NULL,
FSECONDMENTID BIGINT DEFAULT 0 NOT NULL,
FSECBACKID BIGINT DEFAULT 0 NOT NULL,
FSECCHANGENOWID BIGINT DEFAULT 0 NOT NULL,
FDEPEMPID BIGINT DEFAULT 0 NOT NULL,
FERMANFILEID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FSECSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FORGINID BIGINT DEFAULT 0 NOT NULL,
FADMINORGINID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPINID BIGINT DEFAULT 0 NOT NULL,
FDEPENDENCYINID BIGINT DEFAULT 0 NOT NULL,
FCMPEMPINID BIGINT DEFAULT 0 NOT NULL,
FCOUNTRYINID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYINID BIGINT DEFAULT 0 NOT NULL,
FDEPTINID BIGINT DEFAULT 0 NOT NULL,
FPOSPATTERNIN VARCHAR(2) DEFAULT ' ' NOT NULL,
FPOSITIONINID BIGINT DEFAULT 0 NOT NULL,
FSTANDARDPOSINID BIGINT DEFAULT 0 NOT NULL,
FJOBINID BIGINT DEFAULT 0 NOT NULL,
FBASELOCATIONINID BIGINT DEFAULT 0 NOT NULL,
FORGOUTID BIGINT DEFAULT 0 NOT NULL,
FADMINORGOUT BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPOUTID BIGINT DEFAULT 0 NOT NULL,
FCOUNTRYOUTID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYOUTID BIGINT DEFAULT 0 NOT NULL,
FDEPTOUTID BIGINT DEFAULT 0 NOT NULL,
FPOSPATTERNOUT VARCHAR(2) DEFAULT ' ' NOT NULL,
FPOSITIONOUTID BIGINT DEFAULT 0 NOT NULL,
FSTANDARDPOSOUTID BIGINT DEFAULT 0 NOT NULL,
FJOBOUTID BIGINT DEFAULT 0 NOT NULL,
FCOUNTRYBACKID BIGINT DEFAULT 0 NOT NULL,
FCOMPANYBACKID BIGINT DEFAULT 0 NOT NULL,
FDEPTBACKID BIGINT DEFAULT 0 NOT NULL,
FPOSPATTERNBACK VARCHAR(2) DEFAULT ' ' NOT NULL,
FPOSTSTANDARDBACKID BIGINT DEFAULT 0 NOT NULL,
FPOSITIONBACKID BIGINT DEFAULT 0 NOT NULL,
FJOBBACKID BIGINT DEFAULT 0 NOT NULL,
FLEAVEDATE DATETIME,
FSTARTDATE DATETIME,
FENDDATE DATETIME,
FREACHDATE DATETIME,
FSECREASONID BIGINT DEFAULT 0 NOT NULL,
FPLANENDDATE DATETIME,
FPLANDURATION INT DEFAULT 0 NOT NULL,
FSECREASONEND NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECONDMENTRECORD_A') 
 CREATE TABLE T_HDM_SECONDMENTRECORD_A (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FINITDATASOURCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FINITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FINITBATCH BIGINT DEFAULT 0 NOT NULL,
FDATASTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FSOURCEVID BIGINT DEFAULT 0 NOT NULL,
FISMODIFY CHAR(1) DEFAULT ' ' NOT NULL,
FHISVERSION VARCHAR(10) DEFAULT ' ' NOT NULL,
FCHANGEDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
FBASELOCATIONBACKID BIGINT DEFAULT 0 NOT NULL,
FBACKDATE DATETIME,
FSECBACKREASON BIGINT DEFAULT 0 NOT NULL,
FDURATION INT DEFAULT 0 NOT NULL,
FORGBACKID BIGINT DEFAULT 0 NOT NULL,
FADMINORGBACKID BIGINT DEFAULT 0 NOT NULL,
FEMPGROUPBACKID BIGINT DEFAULT 0 NOT NULL,
FDEPENDENCYTYPEINID BIGINT DEFAULT 0 NOT NULL,
FTERMSOURCE VARCHAR(2) DEFAULT ' ' NOT NULL,
FTERMTASKSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FCMPEMPOUTID BIGINT DEFAULT 0 NOT NULL,
FINDARKPOSITIONID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECONDMENTRECORD_L') 
 CREATE TABLE T_HDM_SECONDMENTRECORD_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSECREASONEND NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECINSUP') 
 CREATE TABLE T_HDM_SECINSUP (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECININCHARGE') 
 CREATE TABLE T_HDM_SECININCHARGE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECOUTINCHARGE') 
 CREATE TABLE T_HDM_SECOUTINCHARGE (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_SECOUTSUP') 
 CREATE TABLE T_HDM_SECOUTSUP (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);



/**End D:\PDM_UPGRADE\PDM1\HDM_table.sql **/
