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

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFICENTITY' AND KSQL_COL_NAME IN ('FSOURCE')) 
 ALTER TABLE T_BCM_STRUCTOFICENTITY ADD (FSOURCE VARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFDEFINED' AND KSQL_COL_NAME IN ('FSOURCE')) 
 ALTER TABLE T_BCM_STRUCTOFDEFINED ADD (FSOURCE VARCHAR(50) DEFAULT ' ' NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISINIRULE') 
 CREATE TABLE T_BCM_ISINIRULE (
FID BIGINT DEFAULT 0 NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
FVALUE VARCHAR(50) DEFAULT ' ' NOT NULL,
FORDERNUM INT DEFAULT 0 NOT NULL,
FCREATERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BDMAPPING') 
 CREATE TABLE T_BCM_BDMAPPING (
FID BIGINT DEFAULT 0 NOT NULL,
FREPORTTYPE CHAR(1) DEFAULT '1' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSOURCE VARCHAR(50) DEFAULT ' ' NOT NULL,
FOTHERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BDMAPPING_L') 
 CREATE TABLE T_BCM_BDMAPPING_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,
FOTHERNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BDCONFIG_L') 
 CREATE TABLE T_BCM_BDCONFIG_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
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BDCONFIG') 
 CREATE TABLE T_BCM_BDCONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FSOURCE VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_BDIMPORT') 
 CREATE TABLE T_BCM_BDIMPORT (
FID BIGINT DEFAULT 0 NOT NULL,
FTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FOPERATION VARCHAR(50) DEFAULT ' ' NOT NULL,
FENABLE VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSOURCE VARCHAR(50) DEFAULT ' ' NOT NULL,
FEXECSTATUS BIGINT DEFAULT 0 NOT NULL,
FSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL
);


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