/**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_DIMENSIONRELATION_L') 
 CREATE TABLE T_EB_DIMENSIONRELATION_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(500) DEFAULT ' ' NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULESET' AND KSQL_COL_NAME ='FSUCCESSORS') 
 ALTER TABLE T_EB_BIZRULESET ADD (FSUCCESSORS NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CENTRALIZED_RANGE' AND KSQL_COL_NAME ='FDIMRANGE') 
 ALTER TABLE T_EB_CENTRALIZED_RANGE ADD (FDIMRANGE NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CENTRALIZED_RANGE' AND KSQL_COL_NAME ='FENTITYRANGENUMBERS') 
 ALTER TABLE T_EB_CENTRALIZED_RANGE ADD (FENTITYRANGENUMBERS NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLVERSION' AND KSQL_COL_NAME ='FORGRANGE') 
 ALTER TABLE T_EB_CONTROLVERSION ADD (FORGRANGE NVARCHAR(100) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLVERSION' AND KSQL_COL_NAME ='FSTATE') 
 ALTER TABLE T_EB_CONTROLVERSION ADD (FSTATE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLVERSION' AND KSQL_COL_NAME ='FDATATYPE') 
 ALTER TABLE T_EB_CONTROLVERSION ADD (FDATATYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLVERSION' AND KSQL_COL_NAME ='FAUDITTRAIL') 
 ALTER TABLE T_EB_CONTROLVERSION ADD (FAUDITTRAIL BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_CONTROLVERSION' AND KSQL_COL_NAME ='FCHANGETYPE') 
 ALTER TABLE T_EB_CONTROLVERSION ADD (FCHANGETYPE BIGINT DEFAULT 0 NOT NULL );
 
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME ='FISPERIODDISTRIBUTION') 
 ALTER TABLE T_EB_STRUCTOFCHANGETYPE ADD (FISPERIODDISTRIBUTION CHAR(1) DEFAULT '0' NOT NULL );
 
   EXEC p_AlterColumn 'T_EB_DATAUPLOADLOG', 'FNUMBER', 'NVARCHAR(150)', 'NOT NULL', '0100', '0';
  
  IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULERELATION' AND KSQL_COL_NAME ='FSONRULEMEMBERKEY') 
 ALTER TABLE T_EB_BIZRULERELATION ADD (FSONRULEMEMBERKEY 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 );

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