/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_GUIDEMENU') 
 CREATE TABLE T_BCM_GUIDEMENU (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FDESCRIPTION VARCHAR(500) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL,
FMENUID VARCHAR(50) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_GUIDEMENUENTRY') 
 CREATE TABLE T_BCM_GUIDEMENUENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSTYPE CHAR(1) DEFAULT '0' NOT NULL,
FOPENID BIGINT DEFAULT 0 NOT NULL,
FOPENTYPEID VARCHAR(50) DEFAULT ' ' NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_GUIDEMENUPERM') 
 CREATE TABLE T_BCM_GUIDEMENUPERM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FETYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FUSERS BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MODELOLAP_DIMRANGE') 
 CREATE TABLE T_BCM_MODELOLAP_DIMRANGE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSCOPE INT DEFAULT 0 NOT NULL,
FDIMENSIONPROPERTY INT DEFAULT 0 NOT NULL,
FDIMEMNUM VARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMENSIONMEM BIGINT DEFAULT 0 NOT NULL,
FDIMENSION VARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMEMNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MODELOLAP_RECORD_L') 
 CREATE TABLE T_BCM_MODELOLAP_RECORD_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODELOLAP_RECORD' AND KSQL_COL_NAME ='FSTORAGETYPE') 
 ALTER TABLE T_BCM_MODELOLAP_RECORD ADD (FSTORAGETYPE INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODELOLAP_RECORD' AND KSQL_COL_NAME ='FNUMBER') 
 ALTER TABLE T_BCM_MODELOLAP_RECORD ADD (FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODELOLAP_RECORD' AND KSQL_COL_NAME ='FREMARK') 
 ALTER TABLE T_BCM_MODELOLAP_RECORD ADD (FREMARK VARCHAR(600) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODELOLAP_RECORD' AND KSQL_COL_NAME ='FMODIFIER') 
 ALTER TABLE T_BCM_MODELOLAP_RECORD ADD (FMODIFIER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_MODELOLAP_RECORD' AND KSQL_COL_NAME ='FMODIFYDATE') 
 ALTER TABLE T_BCM_MODELOLAP_RECORD ADD (FMODIFYDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MENUBASE') 
 CREATE TABLE T_BCM_MENUBASE (
FID VARCHAR(200) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FCUSTOMSETTING VARCHAR(2000) DEFAULT ' ' NOT NULL,
FORMID VARCHAR(200) DEFAULT ' ' NOT NULL,
FMENUID VARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MENUBASE_L') 
 CREATE TABLE T_BCM_MENUBASE_L (
FPKID VARCHAR(200) DEFAULT ' ' NOT NULL,
FID VARCHAR(50) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_STATUS') 
 CREATE TABLE T_BCM_STATUS (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FORG BIGINT DEFAULT 0 NOT NULL,
FSCENARIO BIGINT DEFAULT 0 NOT NULL,
FYEAR BIGINT DEFAULT 0 NOT NULL,
FPERIOD BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FPROCESS BIGINT DEFAULT 0 NOT NULL,
FAUDITTRAIL BIGINT DEFAULT 0 NOT NULL,
FCHECKEDSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BREXECINFO' AND KSQL_COL_NAME ='FSCENARIO') 
 ALTER TABLE T_BCM_BREXECINFO ADD (FSCENARIO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BREXECINFO' AND KSQL_COL_NAME ='FYEAR') 
 ALTER TABLE T_BCM_BREXECINFO ADD (FYEAR BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BREXECINFO' AND KSQL_COL_NAME ='FPERIOD') 
 ALTER TABLE T_BCM_BREXECINFO ADD (FPERIOD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BREXECINFO' AND KSQL_COL_NAME ='FCURRENCY') 
 ALTER TABLE T_BCM_BREXECINFO ADD (FCURRENCY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BREXECINFO' AND KSQL_COL_NAME ='FBIZRULECATALOG') 
 ALTER TABLE T_BCM_BREXECINFO ADD (FBIZRULECATALOG BIGINT DEFAULT 0 NOT NULL );

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