/**Begin D:\PDM_UPGRADE\PDM1\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FSENDBACKERID')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FSENDBACKERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FSENDBACKTIME')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FSENDBACKTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FSENDBACKTIMES')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FSENDBACKTIMES INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCOMMITORID')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCOMMITORID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCOMMITTIME')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCOMMITTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FFIRSTCOMMITTIME')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FFIRSTCOMMITTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCOMMITTIMES')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCOMMITTIMES INT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCOMPLETERID')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCOMPLETERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCOMPLETETIME')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCOMPLETETIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCYCLETABLEID')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCYCLETABLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_REPORTLIST' AND KSQL_COL_NAME IN ('FCYCLETABLERPTID')) 
 ALTER TABLE T_BCM_REPORTLIST ADD (FCYCLETABLERPTID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CYCLETABLEREPORT_RT')
 CREATE TABLE T_BCM_CYCLETABLEREPORT_RT (
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FREPORTID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CYCLETABLE') 
 CREATE TABLE T_BCM_CYCLETABLE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSEQUENCE INT DEFAULT 0 NOT NULL,
FFINSTRUCTION NVARCHAR(200) DEFAULT ' ' NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FPERMCLASSID BIGINT DEFAULT 0 NOT NULL,
FBELONGTASK CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CYCLETABLE_L') 
 CREATE TABLE T_BCM_CYCLETABLE_L (
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FFINSTRUCTION NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPDISCYCLETABLE') 
 CREATE TABLE T_BCM_TEMPDISCYCLETABLE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCYCLETABLEID BIGINT DEFAULT 0 NOT NULL,
FTEMPLATEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CYCLETABLEDISENTITY') 
 CREATE TABLE T_BCM_CYCLETABLEDISENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCYCLETABLEID BIGINT DEFAULT 0 NOT NULL,
FENTITYID BIGINT DEFAULT 0 NOT NULL,
FORGRANGE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CYCLETABLEREPORT') 
 CREATE TABLE T_BCM_CYCLETABLEREPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FFYEARID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FSCENEID BIGINT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FENTITYID BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSENDBACKERID BIGINT DEFAULT 0 NOT NULL,
FSENDBACKTIME DATETIME,
FSENDBACKTIMES INT DEFAULT 0 NOT NULL,
FCOMMITORID BIGINT DEFAULT 0 NOT NULL,
FCOMMITTIME DATETIME,
FCOMMITTIMES INT DEFAULT 0 NOT NULL,
FFIRSTCOMMITTIME DATETIME,
FCOMPLETERID BIGINT DEFAULT 0 NOT NULL,
FCOMPLETETIME DATETIME,
FCYCLETABLEID BIGINT DEFAULT 0 NOT NULL
);



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