/**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_EXCHANGERATE' AND KSQL_COL_NAME ='FTRIANGLE') 
 ALTER TABLE T_BCM_EXCHANGERATE ADD (FTRIANGLE NVARCHAR(200) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFPROCESS' AND KSQL_COL_NAME ='FLOCKCURR') 
 ALTER TABLE T_BCM_STRUCTOFPROCESS ADD (FLOCKCURR BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFPROCESS' AND KSQL_COL_NAME ='FPRIORITY') 
 ALTER TABLE T_BCM_STRUCTOFPROCESS ADD (FPRIORITY BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FSEQ', 'INT', 'NOT NULL', '0010', '0';

 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FID', 'BIGINT', 'NOT NULL', '0010', '0';

 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FEFFECTIVEYEAR', 'BIGINT', 'NOT NULL', '0010', '0';

 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FEFFECTIVEPERIOD', 'BIGINT', 'NOT NULL', '0010', '0';

 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FAPPLYTYPE', 'CHAR(1)', 'NOT NULL', '0010', '''1''';

 EXEC p_AlterColumn 'T_BCM_RATEEFFECTIVE', 'FYEARSCOPE', 'CHAR(1)', 'NOT NULL', '0010', '''1''';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFACCOUNT_S' AND KSQL_COL_NAME ='FISCALTYPE') 
 ALTER TABLE T_BCM_STRUCTOFACCOUNT_S ADD (FISCALTYPE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_STRUCTOFACCOUNT_DM') 
 CREATE TABLE T_BCM_STRUCTOFACCOUNT_DM (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIM BIGINT DEFAULT 0 NOT NULL,
FVAL NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FCREATORID') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FCREATETIME') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FMODIFIER') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FMODIFIER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FMODIFYTIME') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FMODIFYTIME DATETIME );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BASECVTFORMULA' AND KSQL_COL_NAME ='FCREATORID') 
 ALTER TABLE T_BCM_BASECVTFORMULA ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BASECVTFORMULA' AND KSQL_COL_NAME ='FCREATETIME') 
 ALTER TABLE T_BCM_BASECVTFORMULA ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SPECIALRATE' AND KSQL_COL_NAME ='FCREATORID') 
 ALTER TABLE T_BCM_SPECIALRATE ADD (FCREATORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SPECIALRATE' AND KSQL_COL_NAME ='FCREATETIME') 
 ALTER TABLE T_BCM_SPECIALRATE ADD (FCREATETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SPECIALRATE' AND KSQL_COL_NAME ='FMODIFIER') 
 ALTER TABLE T_BCM_SPECIALRATE ADD (FMODIFIER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SPECIALRATE' AND KSQL_COL_NAME ='FMODIFYTIME') 
 ALTER TABLE T_BCM_SPECIALRATE ADD (FMODIFYTIME DATETIME );

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