/**Begin D:\PDM_UPGRADE\PDM1\HDM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_PARTTIMEAPPLYBILL' AND KSQL_COL_NAME ='FMID')
 ALTER TABLE T_HDM_PARTTIMEAPPLYBILL ADD (FMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_PARTTIMEAPPLYBILL' AND KSQL_COL_NAME ='FSEQ')
 ALTER TABLE T_HDM_PARTTIMEAPPLYBILL ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_PARTTIMEAPPLYBILL_A' AND KSQL_COL_NAME ='FMID')
 ALTER TABLE T_HDM_PARTTIMEAPPLYBILL_A ADD (FMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_PARTTIMEBATCH')
 CREATE TABLE T_HDM_PARTTIMEBATCH (
FMID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(60) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FISEXISTSWORKFLOW CHAR(1) DEFAULT ' ' NOT NULL,
FISSUBMIT CHAR(1) DEFAULT ' ' NOT NULL,
FBARCODE VARCHAR(60) DEFAULT ' ' NOT NULL,
FINPUTDEVICETYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FEVENTEFFECTDATE DATETIME,
FBILLSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAUDITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAFFILIATIONORDID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_REGBASEBILL' AND KSQL_COL_NAME ='FMID')
 ALTER TABLE T_HDM_REGBASEBILL ADD (FMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_REGBASEBILL' AND KSQL_COL_NAME ='FSEQ')
 ALTER TABLE T_HDM_REGBASEBILL ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HDM_REGBASEBILL_A' AND KSQL_COL_NAME ='FMID')
 ALTER TABLE T_HDM_REGBASEBILL_A ADD (FMID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HDM_REGBATCH')
 CREATE TABLE T_HDM_REGBATCH (
FMID BIGINT DEFAULT 0 NOT NULL,
FBILLNO VARCHAR(60) DEFAULT ' ' NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FAUDITORID BIGINT DEFAULT 0 NOT NULL,
FAUDITDATE DATETIME,
FISEXISTSWORKFLOW CHAR(1) DEFAULT ' ' NOT NULL,
FISSUBMIT CHAR(1) DEFAULT ' ' NOT NULL,
FBARCODE VARCHAR(60) DEFAULT ' ' NOT NULL,
FINPUTDEVICETYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FEVENTEFFECTDATE DATETIME,
FBILLSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAUDITSTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FAFFILIATIONORDID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


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



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