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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DATACOLLECT' AND KSQL_COL_NAME IN ('FGROUPID'))
 ALTER TABLE T_BCM_DATACOLLECT ADD (FGROUPID BIGINT DEFAULT 0 NOT NULL );


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DATACOLLECTPLAN') 
 CREATE TABLE T_BCM_DATACOLLECTPLAN (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FPLANNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FMULENTITY NCLOB,
FMULTEMPLATE NCLOB,
FMULCATALOG NCLOB,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DATACOLLECTPLAN_L') 
 CREATE TABLE T_BCM_DATACOLLECTPLAN_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FPLANNAME NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_DATACOLLECTRECORD')
 CREATE TABLE T_BCM_DATACOLLECTRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FGROUP BIGINT DEFAULT 0 NOT NULL,
FCOUNT INT DEFAULT 0 NOT NULL,
FREMAINDER INT DEFAULT 0 NOT NULL,
FENDTIME DATETIME,
FCREATETIME DATETIME,
FCREATOR BIGINT DEFAULT 0 NOT NULL,
FSCENARIO BIGINT DEFAULT 0 NOT NULL,
FYEAR BIGINT DEFAULT 0 NOT NULL,
FPERIOD BIGINT DEFAULT 0 NOT NULL
);





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