/**Begin D:\PDM_UPGRADE\PDM_UPGRADE\PDM1\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CHECKTMPLPERIOD') 
 CREATE TABLE T_BCM_CHECKTMPLPERIOD (
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_BCM_STRUCTOFACCOUNT_S') 
 CREATE TABLE T_BCM_STRUCTOFACCOUNT_S (
FID BIGINT DEFAULT 0 NOT NULL,
FDATARESOURCE CHAR(1) DEFAULT '0' NOT NULL,
FACCTTABLEID BIGINT DEFAULT 0 NOT NULL,
FACCTFORMULA VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLCOLDIM' AND KSQL_COL_NAME IN ('FCOLGROUPID')) 
 ALTER TABLE T_BCM_TMPLCOLDIM ADD (FCOLGROUPID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLCOLDIM' AND KSQL_COL_NAME IN ('FCOLINDEX')) 
 ALTER TABLE T_BCM_TMPLCOLDIM ADD (FCOLINDEX INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLCOLDIM' AND KSQL_COL_NAME IN ('FDISPLAYCHILD')) 
 ALTER TABLE T_BCM_TMPLCOLDIM ADD (FDISPLAYCHILD CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTQUERYPLAN' AND KSQL_COL_NAME IN ('FORGUNIT')) 
 ALTER TABLE T_BCM_RPTADJUSTQUERYPLAN ADD (FORGUNIT BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTQUERYPLAN' AND KSQL_COL_NAME IN ('FENTITY')) 
 ALTER TABLE T_BCM_RPTADJUSTQUERYPLAN ADD (FENTITY BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTQUERYPLAN' AND KSQL_COL_NAME IN ('FBUSINESSTYPE')) 
 ALTER TABLE T_BCM_RPTADJUSTQUERYPLAN ADD (FBUSINESSTYPE VARCHAR(20) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMENSION' AND KSQL_COL_NAME IN ('FASSTACTTYPE')) 
 ALTER TABLE T_BCM_DIMENSION ADD (FASSTACTTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE1')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE1 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE2')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE2 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE3')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE3 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE4')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE4 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE5')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE5 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE6')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE6 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE7')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE7 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE8')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE8 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE9')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE9 DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_EXCHANGERATE' AND KSQL_COL_NAME IN ('FBOYUSERDEFINEDRATE10')) 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FBOYUSERDEFINEDRATE10 DECIMAL(23,10) DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE20', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE19', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE18', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE17', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE16', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE15', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE14', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE13', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE12', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_EXCHANGERATE', 'FUSERDEFINE11', 'NULL', 'NULL', '1001', 'NULL';

 EXEC p_AlterColumn 'T_BCM_STRUCTOFACCOUNT', 'FEXCHANGE', 'VARCHAR(30)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TMPLROWDIM' AND KSQL_COL_NAME IN ('FMEMBSCOPE')) 
 ALTER TABLE T_BCM_TMPLROWDIM ADD (FMEMBSCOPE INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TMPLCOLDIM_L') 
 CREATE TABLE T_BCM_TMPLCOLDIM_L (
FPKID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FHEADER VARCHAR(50) DEFAULT ' ' NOT NULL
);



/**End D:\PDM_UPGRADE\PDM_UPGRADE\PDM1\BCM_table.sql **/
