/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\BCM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_INVELIMTEMPLATE' AND KSQL_COL_NAME ='FBILLSTATUS') 
 ALTER TABLE T_BCM_INVELIMTEMPLATE ADD (FBILLSTATUS CHAR(1) DEFAULT 'A' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVELIMTPLENTRY') 
 CREATE TABLE T_BCM_INVELIMTPLENTRY (
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,
FCBINTERCOMPANY CHAR(1) DEFAULT '3' NOT NULL,
FCBMYCOMPANY CHAR(1) DEFAULT '3' 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,
FSEQ INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPACCOUNTENTRY') 
 CREATE TABLE T_BCM_TEMPACCOUNTENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FACCOUNTMEMBER BIGINT DEFAULT 0 NOT NULL,
FISOTHER CHAR(1) DEFAULT '0' NOT NULL,
FACCHANGETYPE BIGINT DEFAULT 0 NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPFORMULAENTRY') 
 CREATE TABLE T_BCM_TEMPFORMULAENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCLCHANGETYPE BIGINT DEFAULT 0 NOT NULL,
FCLYEAR INT DEFAULT 0 NOT NULL,
FCLPERIOD INT DEFAULT 0 NOT NULL,
FFETCHTYPE VARCHAR(10) DEFAULT 'Y' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPSTYLESCHEME') 
 CREATE TABLE T_BCM_TEMPSTYLESCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT 'A' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FCREATETIME DATETIME,
FMODIFYTIME DATETIME,
FSCHEMETYPE CHAR(1) DEFAULT '1' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FFORMULATYPE VARCHAR(30) DEFAULT ' ' NOT NULL,
FACCOUNTBOOKSTYPE BIGINT DEFAULT 0 NOT NULL,
FCLCURRENCY BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_TEMPSTYLESCHEME_L') 
 CREATE TABLE T_BCM_TEMPSTYLESCHEME_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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CONVERTDIFFENTITY' AND KSQL_COL_NAME ='FPRIORITY') 
 ALTER TABLE T_BCM_CONVERTDIFFENTITY ADD (FPRIORITY INT DEFAULT 1 NOT NULL );
 EXEC p_AlterColumn 'T_BCM_MEMBERPERM_L', 'FMEMBERNAME', 'NVARCHAR(200)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBERPERM_L', 'FUSERNAME', 'NVARCHAR(200)', 'NOT NULL', '1111', ''' ''';

 --- drop TABLE --------- 请认真检查该脚本 ------------------- 
IF EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_INVELIMTEMPLATEENTRY') 
 DROP TABLE T_BCM_INVELIMTEMPLATEENTRY;


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