/**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_ROLLINIT' AND KSQL_COL_NAME ='FMODELID') 
 ALTER TABLE T_EB_ROLLINIT ADD (FMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_ROLLINIT' AND KSQL_COL_NAME ='FLASTMODIFYTIME') 
 ALTER TABLE T_EB_ROLLINIT ADD (FLASTMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_ROLLINIT' AND KSQL_COL_NAME ='FMSG') 
 ALTER TABLE T_EB_ROLLINIT ADD (FMSG NVARCHAR(2000) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_ROLLINIT' AND KSQL_COL_NAME ='FISCANCEL') 
 ALTER TABLE T_EB_ROLLINIT ADD (FISCANCEL CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_SHAREDIMENSION_L') 
 CREATE TABLE T_EB_SHAREDIMENSION_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_SHAREDIMENSION') 
 CREATE TABLE T_EB_SHAREDIMENSION (
FID BIGINT DEFAULT 0 NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FBILLID BIGINT DEFAULT 0 NOT NULL,
FFIELD NVARCHAR(255) DEFAULT ' ' NOT NULL,
FFIELDNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FAPPID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FCLOUDID NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FBIZMODELID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONRANGEJSON NCLOB,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FSTATUS VARCHAR(10) DEFAULT 'A' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_SHAREDIMENSIONENTRY') 
 CREATE TABLE T_EB_SHAREDIMENSIONENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FMEMBERNUMBER NVARCHAR(255) DEFAULT ' ' NOT NULL,
FMEMBERNAME NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BGMCONTROLDIMENSION' AND KSQL_COL_NAME ='FORGRANGE') 
 ALTER TABLE T_EB_BGMCONTROLDIMENSION ADD (FORGRANGE NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMMATERULEBILL' AND KSQL_COL_NAME ='FCHANGETYPEFIELD') 
 ALTER TABLE T_EB_DIMMATERULEBILL ADD (FCHANGETYPEFIELD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMMATERULEBILL' AND KSQL_COL_NAME ='FCHANGETYPEFIELDEXTID') 
 ALTER TABLE T_EB_DIMMATERULEBILL ADD (FCHANGETYPEFIELDEXTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMMATERULEBILL' AND KSQL_COL_NAME ='FCHANGETYPEDIMSIONMAPID') 
 ALTER TABLE T_EB_DIMMATERULEBILL ADD (FCHANGETYPEDIMSIONMAPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID1') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID1 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID2') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID2 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID3') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID3 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID4') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID4 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID5') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID5 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID6') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID6 BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEDEFINEDS' AND KSQL_COL_NAME ='FUSERDEFINEDDIMID7') 
 ALTER TABLE T_EB_CONTROLRULEDEFINEDS ADD (FUSERDEFINEDDIMID7 BIGINT DEFAULT 0 NOT NULL );

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