/**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_DATAPERM' AND KSQL_COL_NAME ='FBUSINESSMODEL') 
 ALTER TABLE T_EB_DATAPERM ADD (FBUSINESSMODEL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_OFFSETENTRY' AND KSQL_COL_NAME ='FBUSMODELID') 
 ALTER TABLE T_EB_OFFSETENTRY ADD (FBUSMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_OFFSETRULE' AND KSQL_COL_NAME ='FBUSMODELID') 
 ALTER TABLE T_EB_OFFSETRULE ADD (FBUSMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_OFFSETRULECATALOG' AND KSQL_COL_NAME ='FBUSMODELID') 
 ALTER TABLE T_EB_OFFSETRULECATALOG ADD (FBUSMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_OFFSETRULECATALOG' AND KSQL_COL_NAME ='FASSISTDIM') 
 ALTER TABLE T_EB_OFFSETRULECATALOG ADD (FASSISTDIM NVARCHAR(200) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_OFFSETRULECATALOG' AND KSQL_COL_NAME ='FISPRESET') 
 ALTER TABLE T_EB_OFFSETRULECATALOG ADD (FISPRESET CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_ACCOUNTMAPPING') 
 CREATE TABLE T_EB_ACCOUNTMAPPING (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRYSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTARTDATE BIGINT DEFAULT 0 NOT NULL,
FENDDATE BIGINT DEFAULT 0 NOT NULL,
FSRCACCOUNT BIGINT DEFAULT 0 NOT NULL,
FTRGACCOUNT BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DATAUPLOADDIMMAP') 
 CREATE TABLE T_EB_DATAUPLOADDIMMAP (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSRCDIMTEXT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGDIMTEXT NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCDIMMEMSHOW BIGINT DEFAULT 0 NOT NULL,
FTRGDIMMEMSHOW BIGINT DEFAULT 0 NOT NULL,
FSRCDIMMEMBERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGDIMMEMBERTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCDIMMEMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGDIMMEMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCDIMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGDIMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCDIMVIEW NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTRGDIMVIEW NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DATAUPLOADLOG') 
 CREATE TABLE T_EB_DATAUPLOADLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUPLOADPARAMS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDATATYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUDGETPERIOD NCLOB,
FUPLOADSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
FUPLOADUSER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FUPLOADDATE DATETIME,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FENTITY BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DATAUPLOADLOG_L') 
 CREATE TABLE T_EB_DATAUPLOADLOG_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DATAUPLOADSCHEME') 
 CREATE TABLE T_EB_DATAUPLOADSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FENABLE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMASTERID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCBUSINESSMODELID BIGINT DEFAULT 0 NOT NULL,
FTRGBUSINESSMODELID BIGINT DEFAULT 0 NOT NULL,
FSTATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODELBD NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_BIZRULESETREF') 
 CREATE TABLE T_EB_BIZRULESETREF (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FREFDIMENSION BIGINT DEFAULT 0 NOT NULL,
FREFMEMBER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FMERGERNODE') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FMERGERNODE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FISINNERORG') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FISINNERORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FISOUTERORG') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FISOUTERORG CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_VIEWMEMBER' AND KSQL_COL_NAME ='FISOFFSETENTRY') 
 ALTER TABLE T_EB_VIEWMEMBER ADD (FISOFFSETENTRY CHAR(1) DEFAULT '0' NOT NULL );



IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION_MAP' AND KSQL_COL_NAME ='FDATASET') 
 ALTER TABLE T_EB_INTEGRATION_MAP ADD (FDATASET BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION_MAP' AND KSQL_COL_NAME ='FTARGETOBJID') 
 ALTER TABLE T_EB_INTEGRATION_MAP ADD (FTARGETOBJID BIGINT DEFAULT 0 NOT NULL );
 
  
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_INTEGRATION_MAP' AND KSQL_COL_NAME ='FDIMVIEW') 
 ALTER TABLE T_EB_INTEGRATION_MAP ADD (FDIMVIEW bigint DEFAULT 0 NOT NULL );

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