/**Begin D:\PDM\PDM_UPGRADE\pdm1\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BATCHEXPORTDETAIL') 
 CREATE TABLE T_BCM_BATCHEXPORTDETAIL (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FSTARTYEAR BIGINT DEFAULT 0 NOT NULL,
FSTARTPERIOD BIGINT DEFAULT 0 NOT NULL,
FENDYEAR BIGINT DEFAULT 0 NOT NULL,
FENDPERIOD BIGINT DEFAULT 0 NOT NULL,
FSCENARIO BIGINT DEFAULT 0 NOT NULL,
FCURRENCY BIGINT DEFAULT 0 NOT NULL,
FREPORTDATA VARCHAR(4) DEFAULT ' ' NOT NULL,
FBOXALL CHAR(1) DEFAULT '0' NOT NULL,
FBOXUNWEAVE CHAR(1) DEFAULT '0' NOT NULL,
FBOXWEAVING CHAR(1) DEFAULT '0' NOT NULL,
FBOXCOMPLETE CHAR(1) DEFAULT '0' NOT NULL,
FBOXCOMMIT CHAR(1) DEFAULT '0' NOT NULL,
FBOXBACK CHAR(1) DEFAULT '0' NOT NULL,
FEXCELFILETYPE CHAR(1) DEFAULT '0' NOT NULL,
FSHEETNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FFILENAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FFILEPOSITION VARCHAR(255) DEFAULT ' ' NOT NULL,
FFILETYPE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BATCHEXPORTDETAIL_L') 
 CREATE TABLE T_BCM_BATCHEXPORTDETAIL_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BMC_BATCHEXPORTPLAN') 
 CREATE TABLE T_BMC_BATCHEXPORTPLAN (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FMASTERID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(255) DEFAULT ' ' NOT NULL,
FAPPLICATIONSCOPE CHAR(1) DEFAULT '1' NOT NULL,
FISDEFAULTPLAN CHAR(1) DEFAULT '0' NOT NULL,
FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FPLANID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BMC_BATCHEXPORTPLAN_L') 
 CREATE TABLE T_BMC_BATCHEXPORTPLAN_L (
FPKID VARCHAR(36) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(20) DEFAULT ' ' NOT NULL,
FNAME VARCHAR(100) DEFAULT ' ' NOT NULL
);


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

/**End D:\PDM\PDM_UPGRADE\pdm1\BCM_table.sql **/
