/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_SUBJECTANG') 
 CREATE TABLE T_EB_SUBJECTANG (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CURRCONVERTUPDATE') 
 CREATE TABLE T_EB_CURRCONVERTUPDATE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCHEME BIGINT DEFAULT 0 NOT NULL,
FENTITYS NCLOB,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CURRENCYCONVERTSCHEM' AND KSQL_COL_NAME ='FNAME') 
 ALTER TABLE T_EB_CURRENCYCONVERTSCHEM ADD (FNAME NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIMENSIONRELATION') 
 CREATE TABLE T_EB_DIMENSIONRELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FDSEQ BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDIMENSION1 BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONVIEW1 BIGINT DEFAULT 0 NOT NULL,
FDIMENSION2 BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONVIEW2 BIGINT DEFAULT 0 NOT NULL,
FAFFECTRANGE CHAR(1) DEFAULT '1' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FBILLSTATUS CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIMMEMBERRELATION') 
 CREATE TABLE T_EB_DIMMEMBERRELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FDSEQ BIGINT DEFAULT 0 NOT NULL,
FRELATIONID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FENTITY BIGINT DEFAULT 0 NOT NULL,
FACCOUNT BIGINT DEFAULT 0 NOT NULL,
FYEAR BIGINT DEFAULT 0 NOT NULL,
FPERIOD BIGINT DEFAULT 0 NOT NULL,
FBUDGETPERIOD BIGINT DEFAULT 0 NOT NULL,
FVERSION BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FDATATYPE BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPE BIGINT DEFAULT 0 NOT NULL,
FAUDITTRAIL BIGINT DEFAULT 0 NOT NULL,
FMETRIC BIGINT DEFAULT 0 NOT NULL,
FINTERNALCOMPANY BIGINT DEFAULT 0 NOT NULL,
FSCENARIO BIGINT DEFAULT 0 NOT NULL,
FPROCESS BIGINT DEFAULT 0 NOT NULL,
FCUSTOMDIMNUMBER1 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCUSTOMDIM1 BIGINT DEFAULT 0 NOT NULL,
FCUSTOMDIMNUMBER2 NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCUSTOMDIM2 BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FBILLSTATUS CHAR(1) DEFAULT 'A' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TEMPLATE' AND KSQL_COL_NAME ='FISRELATION') 
 ALTER TABLE T_EB_TEMPLATE ADD (FISRELATION CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TEMPLATE' AND KSQL_COL_NAME ='FDIMRELATIONID') 
 ALTER TABLE T_EB_TEMPLATE ADD (FDIMRELATIONID BIGINT DEFAULT 0 NOT NULL );

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