/**Begin D:\PDM_UPGRADE\PDM_UPGRADE_1.1\PDM_UPGRADE\PDM1\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYTICSSOLUTIONS' AND KSQL_COL_NAME ='FSCOPE') 
 ALTER TABLE T_BCM_ANALYTICSSOLUTIONS ADD (FSCOPE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ANALYTICSSOLUTIONS' AND KSQL_COL_NAME ='FEXPLANATION') 
 ALTER TABLE T_BCM_ANALYTICSSOLUTIONS ADD (FEXPLANATION NVARCHAR(255) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_UDCFEFFECTIVE') 
 CREATE TABLE T_BCM_UDCFEFFECTIVE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEYEAR BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEPERIOD BIGINT DEFAULT 0 NOT NULL,
FAPPLYTYPE CHAR(1) DEFAULT '1' NOT NULL,
FYEARSCOPE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FEXECUTIONORDER') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FEXECUTIONORDER INT DEFAULT 1 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_USERDEFCVTFORMULA' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BCM_USERDEFCVTFORMULA ADD (FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_UDCFROWCOLMEMB' AND KSQL_COL_NAME ='FPROPERTYVALUEID') 
 ALTER TABLE T_BCM_UDCFROWCOLMEMB ADD (FPROPERTYVALUEID BIGINT DEFAULT 0 NOT NULL );
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 );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_RATEEFFECTIVE') 
 CREATE TABLE T_BCM_RATEEFFECTIVE (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEYEAR BIGINT DEFAULT 0 NOT NULL,
FEFFECTIVEPERIOD BIGINT DEFAULT 0 NOT NULL,
FAPPLYTYPE CHAR(1) DEFAULT '1' NOT NULL,
FYEARSCOPE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BASECVTFORMULA' AND KSQL_COL_NAME ='FEXCHAGERATEID') 
 ALTER TABLE T_BCM_BASECVTFORMULA ADD (FEXCHAGERATEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BASECVTFORMULA' AND KSQL_COL_NAME ='FISAUTOCONVERT') 
 ALTER TABLE T_BCM_BASECVTFORMULA ADD (FISAUTOCONVERT CHAR(1) DEFAULT '1' 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_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_RATEMEMBENTRY') 
 CREATE TABLE T_BCM_RATEMEMBENTRY (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FRANGE VARCHAR(20) DEFAULT ' ' NOT NULL,
FPROPERTYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SPECIALRATE') 
 CREATE TABLE T_BCM_SPECIALRATE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FEXCHAGERATEID BIGINT DEFAULT 0 NOT NULL,
FEXECUTIONORDER INT DEFAULT 1 NOT NULL,
FISAUTOCONVERT CHAR(1) DEFAULT '1' NOT NULL,
FDESCRIPTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);



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