/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONDEFINE_L') 
 CREATE TABLE T_BCM_INVRELATIONDEFINE_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONSET') 
 CREATE TABLE T_BCM_INVRELATIONSET (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDIRECTEOWN INT DEFAULT 0 NOT NULL,
FINDIREOWNSUM INT DEFAULT 0 NOT NULL,
FINDIREOWNMUL INT DEFAULT 0 NOT NULL,
FINSHAREEOWN INT DEFAULT 0 NOT NULL,
FINTRASHAREEOWN INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MERGECONFIG_L') 
 CREATE TABLE T_BCM_MERGECONFIG_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHECKTMPLENTRY' AND KSQL_COL_NAME ='FELIMACCOUNTID') 
 ALTER TABLE T_BCM_CHECKTMPLENTRY ADD (FELIMACCOUNTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHECKTMPLENTRY' AND KSQL_COL_NAME ='FELIMCHANGETYPEID') 
 ALTER TABLE T_BCM_CHECKTMPLENTRY ADD (FELIMCHANGETYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHECKTMPLENTRY' AND KSQL_COL_NAME ='FELIMDC') 
 ALTER TABLE T_BCM_CHECKTMPLENTRY ADD (FELIMDC CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVRELATION' AND KSQL_COL_NAME ='FISCONFIRMED') 
 ALTER TABLE T_BCM_INVRELATION ADD (FISCONFIRMED CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_ISGROUPSRCMAPENTRY' AND KSQL_COL_NAME ='FSRCPROPERTYID') 
 ALTER TABLE T_BCM_ISGROUPSRCMAPENTRY ADD (FSRCPROPERTYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATIONDEFINE') 
 CREATE TABLE T_BCM_INVRELATIONDEFINE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDEFINEEOWN NVARCHAR(100) DEFAULT ' ' NOT NULL,
FISSELECTED INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MERGECONFIG') 
 CREATE TABLE T_BCM_MERGECONFIG (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCONFIGWAY CHAR(1) DEFAULT '1' NOT NULL,
FISUSE CHAR(1) DEFAULT '1' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FMODEL BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_MERGECONFIGENTRY') 
 CREATE TABLE T_BCM_MERGECONFIGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FUSESTATUS CHAR(1) DEFAULT '0' NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME
);



/**End E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
