/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DATAUPLOADLOG' AND KSQL_COL_NAME ='FSRCTOTAL') 
 ALTER TABLE T_EB_DATAUPLOADLOG ADD (FSRCTOTAL NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DATAUPLOADLOG' AND KSQL_COL_NAME ='FTOTALMAPPING') 
 ALTER TABLE T_EB_DATAUPLOADLOG ADD (FTOTALMAPPING NVARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION' AND KSQL_COL_NAME ='FTARGETOBJID') 
 ALTER TABLE T_EB_INTEGRATION ADD (FTARGETOBJID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VERSIONCOPYRECORD' AND KSQL_COL_NAME ='FLASTTIME') 
 ALTER TABLE T_EB_VERSIONCOPYRECORD ADD (FLASTTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VERSIONCOPYRECORD' AND KSQL_COL_NAME ='FISCANCEL') 
 ALTER TABLE T_EB_VERSIONCOPYRECORD ADD (FISCANCEL CHAR(1) DEFAULT '0' NOT NULL );
   IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_MODEL' AND KSQL_COL_NAME ='FDATASOURCE') 
 ALTER TABLE T_EB_MODEL ADD (FDATASOURCE BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_EB_MODEL', 'FDATASOURCE', 'BIGINT', 'NOT NULL', '0010', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BIZRULERPTCALRESULT') 
 CREATE TABLE T_EB_BIZRULERPTCALRESULT (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FTEMPID BIGINT DEFAULT 0 NOT NULL,
FRULEGROUPID BIGINT DEFAULT 0 NOT NULL,
FCELLKEY NVARCHAR(20) DEFAULT ' ' NOT NULL,
FRULEID BIGINT DEFAULT 0 NOT NULL,
FLEFTRULE BIGINT DEFAULT 0 NOT NULL,
FDATASET BIGINT DEFAULT 0 NOT NULL,
FCELLDIMSCOPE NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FSAVEDATE DATETIME,
FHANDDATE DATETIME,
FSAVESEQ INT DEFAULT 0 NOT NULL,
FEXECSEQ INT DEFAULT 0 NOT NULL,
FCALMETHOD INT DEFAULT 0 NOT NULL,
FOLAPDIMSCOPE NCLOB,
FOLAPVALUE NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_STRUCTOFMETRIC_ENUM') 
 CREATE TABLE T_EB_STRUCTOFMETRIC_ENUM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENUMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENUMNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FDIMID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMPROPERTYENTRY' AND KSQL_COL_NAME ='FSEQ') 
 ALTER TABLE T_EB_DIMPROPERTYENTRY ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMPROPERTYSUBENTRY' AND KSQL_COL_NAME ='FSEQ') 
 ALTER TABLE T_EB_DIMPROPERTYSUBENTRY ADD (FSEQ INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION_MAPDIM' AND KSQL_COL_NAME ='FFIXEDMEMBER') 
 ALTER TABLE T_EB_INTEGRATION_MAPDIM ADD (FFIXEDMEMBER CHAR(1) DEFAULT '0' NOT NULL );

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