/**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_WHITEBILL') 
 CREATE TABLE T_EB_WHITEBILL (
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_DIMMEMBERMAPPING' AND KSQL_COL_NAME ='FISFREETYPE') 
 ALTER TABLE T_EB_DIMMEMBERMAPPING ADD (FISFREETYPE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_WHITECHANGELOG') 
 CREATE TABLE T_EB_WHITECHANGELOG (
FID BIGINT DEFAULT 0 NOT NULL,
FOPERATE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION NCLOB,
FTIME DATETIME,
FUSER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLRULEMAIN' AND KSQL_COL_NAME ='FISFREETYPE') 
 ALTER TABLE T_EB_CONTROLRULEMAIN ADD (FISFREETYPE CHAR(1) DEFAULT '0' NOT NULL );
 EXEC p_AlterColumn 'T_EB_ROLLCONFIG', 'FMASTERID', 'NVARCHAR(19)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_EB_DATAUPLOADSCHEME', 'FNUMBER', 'NVARCHAR(100)', 'NOT NULL', '0100', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CURRENCYCONVERTLOG') 
 CREATE TABLE T_EB_CURRENCYCONVERTLOG (
FID BIGINT DEFAULT 0 NOT NULL,
FCONVERTTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONVERTRANGE NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONVERTLOG NCLOB,
FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FEXECUTOR BIGINT DEFAULT 0 NOT NULL,
FEXECUTEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CURRENCYCONVERTLIST') 
 CREATE TABLE T_EB_CURRENCYCONVERTLIST (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FBUDGETDATE DATETIME,
FMEANPARITIES DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADDMEANPARITIES DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENDPARITIES DECIMAL(23,10) DEFAULT 0 NOT NULL,
FENDMODIFIER BIGINT DEFAULT 0 NOT NULL,
FENDMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CURRENCYCONVERTSCHEM') 
 CREATE TABLE T_EB_CURRENCYCONVERTSCHEM (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FBEGINDATE DATETIME,
FENDDATE DATETIME,
FPARITIESPRECISION NVARCHAR(100) DEFAULT ' ' NOT NULL,
FPARITIESOVERTURN CHAR(1) DEFAULT '0' NOT NULL,
FCURRENCYRAW BIGINT DEFAULT 0 NOT NULL,
FCURRENCYRATE BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
FENTITYRANG NVARCHAR(50) DEFAULT ' ' NOT NULL
);
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CURRENCYCONVERTSCHEM' AND KSQL_COL_NAME ='FENTITYRANG_TAG') 
 ALTER TABLE T_EB_CURRENCYCONVERTSCHEM ADD (FENTITYRANG_TAG NCLOB);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_REPORTATTACHMENT' AND KSQL_COL_NAME ='FMEMBERSKEY') 
 ALTER TABLE T_EB_REPORTATTACHMENT ADD (FMEMBERSKEY NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_REPORTATTACHMENT' AND KSQL_COL_NAME ='FATTACHMENTCOUNT') 
 ALTER TABLE T_EB_REPORTATTACHMENT ADD (FATTACHMENTCOUNT BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_REPORTATTACHMENT_L') 
 CREATE TABLE T_EB_REPORTATTACHMENT_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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DIMENSIONVIEW' AND KSQL_COL_NAME ='FUSAGE') 
 ALTER TABLE T_EB_DIMENSIONVIEW ADD (FUSAGE  CHAR(1) DEFAULT ' ' NOT NULL);



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