/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\HPDI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPTPL' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_OPTPL ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPTPL' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_OPTPL ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPTPL' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_OPTPL ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPTPL' AND KSQL_COL_NAME ='FALIAS') 
 ALTER TABLE T_HPDI_OPTPL ADD (FALIAS NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTGTPL' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_PAYROLLACTGTPL ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTGTPL' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_PAYROLLACTGTPL ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTGTPL' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_PAYROLLACTGTPL ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTGTPL' AND KSQL_COL_NAME ='FALIAS') 
 ALTER TABLE T_HPDI_PAYROLLACTGTPL ADD (FALIAS NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPPKG' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_OPPKG ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPPKG' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_OPPKG ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPPKG' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_OPPKG ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_OPPKG' AND KSQL_COL_NAME ='FALIAS') 
 ALTER TABLE T_HPDI_OPPKG ADD (FALIAS NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTG' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_PAYROLLACTG ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTG' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_PAYROLLACTG ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACTG' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_PAYROLLACTG ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_TASKCENTER_L') 
 CREATE TABLE T_HPDI_TASKCENTER_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_TASKCENTER') 
 CREATE TABLE T_HPDI_TASKCENTER (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FINDEX INT DEFAULT 0 NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FORGMSGRECVCENTERID BIGINT DEFAULT 0 NOT NULL,
FTASKRULEID BIGINT DEFAULT 0 NOT NULL,
FTASKCREATEMANNER VARCHAR(2) DEFAULT ' ' NOT NULL,
FTASKEXECUTESTATUS VARCHAR(2) DEFAULT ' ' NOT NULL,
FTASKEXECUTEDATE DATETIME,
FEXECUTEFAILMSG NVARCHAR(255) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_BUVALUECONFIG') 
 CREATE TABLE T_HPDI_BUVALUECONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FINDEX INT DEFAULT 0 NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FMSGSUBSCRIBERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_BUVALUECONFIGENT') 
 CREATE TABLE T_HPDI_BUVALUECONFIGENT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRELYCONDITION VARCHAR(2) DEFAULT ' ' NOT NULL,
FAPIDEPLOYENTITY VARCHAR(30) DEFAULT ' ' NOT NULL,
FAPIDEPLOYENTITYFIELD VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_TASKRULE') 
 CREATE TABLE T_HPDI_TASKRULE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(60) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE VARCHAR(2) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(2) DEFAULT 'C' NOT NULL,
FDISABLERID BIGINT DEFAULT 0 NOT NULL,
FDISABLEDATE DATETIME,
FINDEX INT DEFAULT 0 NOT NULL,
FISSYSPRESET CHAR(1) DEFAULT '0' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSEORGID BIGINT DEFAULT 0 NOT NULL,
FCREATEORGID BIGINT DEFAULT 0 NOT NULL,
FCTRLSTRATEGY VARCHAR(10) DEFAULT ' ' NOT NULL,
FMSGSUBSCRIBERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_HPDI_TASKRULEENT') 
 CREATE TABLE T_HPDI_TASKRULEENT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FEXECUTESEQ INT DEFAULT 0 NOT NULL,
FPAYROLLACTGID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACT' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_PAYROLLACT ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACT' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_PAYROLLACT ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACT' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_PAYROLLACT ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_PAYROLLACT' AND KSQL_COL_NAME ='FALIAS') 
 ALTER TABLE T_HPDI_PAYROLLACT ADD (FALIAS NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TRIGGERCOLLA' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_HPDI_TRIGGERCOLLA ADD (FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TRIGGERCOLLA' AND KSQL_COL_NAME ='FSIMPLENAME') 
 ALTER TABLE T_HPDI_TRIGGERCOLLA ADD (FSIMPLENAME NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TRIGGERCOLLA' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_HPDI_TRIGGERCOLLA ADD (FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_HPDI_TRIGGERCOLLA' AND KSQL_COL_NAME ='FALIAS') 
 ALTER TABLE T_HPDI_TRIGGERCOLLA ADD (FALIAS NVARCHAR(100) DEFAULT ' ' NOT NULL );

/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\HPDI_table.sql **/
