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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CARRYENTITY' AND KSQL_COL_NAME IN ('FLASTPERIOD')) 
 ALTER TABLE T_BCM_CARRYENTITY ADD (FLASTPERIOD BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CARRYENTITY' AND KSQL_COL_NAME IN ('FLASTSCENE')) 
 ALTER TABLE T_BCM_CARRYENTITY ADD (FLASTSCENE BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_BIZRULE' AND KSQL_COL_NAME IN ('FTYPE')) 
 ALTER TABLE T_BCM_BIZRULE ADD (FTYPE CHAR(1) DEFAULT '1' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CARRYACCOUNT' AND KSQL_COL_NAME IN ('FSOURCEPERIOD')) 
 ALTER TABLE T_BCM_CARRYACCOUNT ADD (FSOURCEPERIOD BIGINT DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CARRYSETTING') 
 CREATE TABLE T_BCM_CARRYSETTING (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSOURCEYEAR BIGINT DEFAULT 0 NOT NULL,
FACCOUNTSCOPE VARCHAR(2000) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_RULECONFIGLOGIC') 
 CREATE TABLE T_BCM_RULECONFIGLOGIC (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FLOGICNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FLOGICNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLOGICCONDITION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FLOGICSCOPE VARCHAR(2000) DEFAULT ' ' NOT NULL,
FLOGICEXPRESSION VARCHAR(2000) DEFAULT ' ' NOT NULL,
FLOGICJS NCLOB,
FLOGICLOG CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_RULECONFIGLOGIC_L') 
 CREATE TABLE T_BCM_RULECONFIGLOGIC_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FLOGICNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);



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