/**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_INVCHANGESTATUS' AND KSQL_COL_NAME IN ('FID')) 
 ALTER TABLE T_BCM_INVCHANGESTATUS ADD (FID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_INVCHANGESTATUS', 'ID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVELIMTEMPLATE') 
 CREATE TABLE T_BCM_INVELIMTEMPLATE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL,
FREMARK VARCHAR(200) DEFAULT ' ' NOT NULL,
FINVRELATYPE CHAR(1) DEFAULT '1' 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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVCHANGEENTRY' AND KSQL_COL_NAME IN ('FID')) 
 ALTER TABLE T_BCM_INVCHANGEENTRY ADD (FID BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_INVCHANGEENTRY', 'ID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CONVERTDIFFENTITY_L' AND KSQL_COL_NAME IN ('FPKID')) 
 ALTER TABLE T_BCM_CONVERTDIFFENTITY_L ADD (FPKID VARCHAR(100) DEFAULT ' ' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_CONVERTDIFFENTITY_L', 'PKID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUSTDATA' AND KSQL_COL_NAME IN ('FSUMMONEY')) 
 ALTER TABLE T_BCM_RPTADJUSTDATA ADD (FSUMMONEY DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME IN ('FBELONGORG')) 
 ALTER TABLE T_BCM_RPTADJUST ADD (FBELONGORG BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_RPTADJUST' AND KSQL_COL_NAME IN ('FINPUTMODE')) 
 ALTER TABLE T_BCM_RPTADJUST ADD (FINPUTMODE VARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME IN ('FVARBASEFOREB')) 
 ALTER TABLE T_BCM_TEMPLATE ADD (FVARBASEFOREB NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_TEMPLATE' AND KSQL_COL_NAME IN ('FVARJSONFOREB')) 
 ALTER TABLE T_BCM_TEMPLATE ADD (FVARJSONFOREB NCLOB );

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