/**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_CONVERDIFFTEMPLATE') 
 CREATE TABLE T_BCM_CONVERDIFFTEMPLATE (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID BIGINT DEFAULT 0 NOT NULL,
FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVCHANGEENTRY') 
 CREATE TABLE T_BCM_INVCHANGEENTRY (
ID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSHAREHOLDERID BIGINT DEFAULT 0 NOT NULL,
FINVESTEECOMPANYID BIGINT DEFAULT 0 NOT NULL,
FHOLDERCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FINVCOMPANYCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FCHANGEDATE DATETIME,
FCHANGETYPE BIGINT DEFAULT 0 NOT NULL,
FCHANGEAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCVT1CURRENYID BIGINT DEFAULT 0 NOT NULL,
FRATE1ID DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCHANGE1AMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCVT2CURRENYID BIGINT DEFAULT 0 NOT NULL,
FRATE2ID DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCHANGE2AMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCVT3CURRENYID BIGINT DEFAULT 0 NOT NULL,
FRATE3ID DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCHANGE3AMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCVT4CURRENYID BIGINT DEFAULT 0 NOT NULL,
FRATE4ID DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCHANGE4AMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCVT5CURRENYID BIGINT DEFAULT 0 NOT NULL,
FRATE5ID DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCHANGE5AMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVCHANGESTATUS') 
 CREATE TABLE T_BCM_INVCHANGESTATUS (
ID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FFYID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FSTARTTIME DATETIME,
FENDTIME DATETIME,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVRELATION') 
 CREATE TABLE T_BCM_INVRELATION (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FFYID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FORGUNITID BIGINT DEFAULT 0 NOT NULL,
FSHAREHOLDERID BIGINT DEFAULT 0 NOT NULL,
FINVESTEECOMPANYID BIGINT DEFAULT 0 NOT NULL,
FEQUVSCALE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FCONFIRMSCALE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FMINCONFIRMSCALE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FISUSEDINVRULE CHAR(1) DEFAULT '1' NOT NULL,
FINVRELATYPE CHAR(1) DEFAULT '1' NOT NULL,
FCREATORID 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_INVSHARERELA_L') 
 CREATE TABLE T_BCM_INVSHARERELA_L (
FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME IN ('FISMERGE')) 
 ALTER TABLE T_BCM_STRUCTOFCHANGETYPE ADD (FISMERGE CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME IN ('FDATAFROM')) 
 ALTER TABLE T_BCM_STRUCTOFCHANGETYPE ADD (FDATAFROM CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CONDIFFMEMBRANGE') 
 CREATE TABLE T_BCM_CONDIFFMEMBRANGE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMEMBERID BIGINT DEFAULT 0 NOT NULL,
FMEMBBOUND BIGINT DEFAULT 0 NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FPROPERTYID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_CONVERTDIFFENTITY') 
 CREATE TABLE T_BCM_CONVERTDIFFENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENARIOID BIGINT DEFAULT 0 NOT NULL,
FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FDESCRIPTION NVARCHAR(200) DEFAULT ' ' NOT NULL,
FLEFTFORMULA NCLOB,
FRIGHTFORMULA NCLOB,
FLFORMULATEMP NCLOB,
FRFORMULATEMP NCLOB,
FVFORMULA NCLOB,
FCHINESEFORMULA NCLOB,
FRANGETXT NCLOB
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVSHARERELA') 
 CREATE TABLE T_BCM_INVSHARERELA (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSHAREHOLDERID BIGINT DEFAULT 0 NOT NULL,
FINVESTEECOMPANYID BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPE CHAR(1) DEFAULT '1' NOT NULL,
FSHARESCALE DECIMAL(19,6) DEFAULT 0 NOT NULL,
FINVESTDATE DATETIME,
FISOUT CHAR(1) DEFAULT '0' NOT NULL,
FINVESTAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL,
FHOLDERCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FINVCOMPANYCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FREMARK NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCREATORID 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_CARRYENTITY') 
 CREATE TABLE T_BCM_CARRYENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FSCENEID BIGINT DEFAULT 0 NOT NULL,
FYEARID BIGINT DEFAULT 0 NOT NULL,
FPERIODID BIGINT DEFAULT 0 NOT NULL,
FORGID BIGINT DEFAULT 0 NOT NULL,
FCARRAYSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVELIMTEMPLATEENTRY') 
 CREATE TABLE T_BCM_INVELIMTEMPLATEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FDATAFROM CHAR(1) DEFAULT '1' NOT NULL,
FDC INT DEFAULT 0 NOT NULL,
FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FINTERCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FMYCOMPANYID BIGINT DEFAULT 0 NOT NULL,
FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FPROCESSID BIGINT DEFAULT 0 NOT NULL,
FCHANGETYPEID BIGINT DEFAULT 0 NOT NULL,
FAUDITTRAILID BIGINT DEFAULT 0 NOT NULL,
FDATASOURCEID BIGINT DEFAULT 0 NOT NULL,
FMULTIGAAP BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE1 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE2 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE3 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE4 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE5 BIGINT DEFAULT 0 NOT NULL,
FUSERDEFINE6 BIGINT DEFAULT 0 NOT NULL,
FRULEEXPR VARCHAR(1000) DEFAULT ' ' NOT NULL,
FRULEEXPRDEPT VARCHAR(1000) DEFAULT ' ' NOT NULL,
FSEGCALCULATE VARCHAR(1000) DEFAULT ' ' NOT NULL,
FRULEEXPRSOURCE VARCHAR(1000) DEFAULT ' ' NOT NULL
);



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