/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ISDIMMAP' AND KSQL_COL_NAME IN ('FDATA')) 
 ALTER TABLE T_BCM_ISDIMMAP ADD (FDATA NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ISDIMMAP' AND KSQL_COL_NAME IN ('FSPREADJSON')) 
 ALTER TABLE T_BCM_ISDIMMAP ADD (FSPREADJSON NCLOB );
 EXEC p_AlterColumn 'T_BCM_ISSINGLEMAP_L', 'FPKID', 'NVARCHAR(30)', 'NOT NULL', '1111', ''' ''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ISGROUPMAP' AND KSQL_COL_NAME IN ('FID')) 
 ALTER TABLE T_BCM_ISGROUPMAP ADD (FID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_ISGROUPMAP', 'ID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BASECVTFORMULA') 
 CREATE TABLE T_BCM_BASECVTFORMULA (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FBALANCE INT DEFAULT 0 NOT NULL,
FPROFITLOSS INT DEFAULT 0 NOT NULL,
FRIGHTS INT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_USERDEFCVTFORMULA') 
 CREATE TABLE T_BCM_USERDEFCVTFORMULA (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FCONVERTFORMULA NVARCHAR(1000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME IN ('FBUSSNESSTYPE')) 
 ALTER TABLE T_BCM_RPTADJUST ADD (FBUSSNESSTYPE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME IN ('FUPDATECYCLE')) 
 ALTER TABLE T_BCM_RPTADJUST ADD (FUPDATECYCLE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_UDCFROWCOLMEMB') 
 CREATE TABLE T_BCM_UDCFROWCOLMEMB (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONNUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMEMBERNUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMEMBBOUND INT DEFAULT 0 NOT NULL
);



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