/**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_CHECKRECORD' AND KSQL_COL_NAME IN ('FDATASORTID')) 
 ALTER TABLE T_BCM_CHECKRECORD ADD (FDATASORTID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHECKRECORDENTRY' AND KSQL_COL_NAME IN ('FENTRYDATASORT')) 
 ALTER TABLE T_BCM_CHECKRECORDENTRY ADD (FENTRYDATASORT BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISBASEENTLIST') 
 CREATE TABLE T_BCM_ISBASEENTLIST (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FENTITYNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 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_ISDIMMAP') 
 CREATE TABLE T_BCM_ISDIMMAP (
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FMAPPEDTYPE CHAR(1) DEFAULT '1' NOT NULL,
FSCHEMEID BIGINT DEFAULT 0 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_ISPRODUCT') 
 CREATE TABLE T_BCM_ISPRODUCT (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) 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_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMCOMBMAPPING' AND KSQL_COL_NAME IN ('FISAGE')) 
 ALTER TABLE T_BCM_DIMCOMBMAPPING ADD (FISAGE CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISDIMMAPSRCDEFVAL') 
 CREATE TABLE T_BCM_ISDIMMAPSRCDEFVAL (
FDETAILID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FMEMBID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISDIMMAPSRCENTRY') 
 CREATE TABLE T_BCM_ISDIMMAPSRCENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FBYFROM CHAR(1) DEFAULT '1' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISDIMMAPTARGENTRY') 
 CREATE TABLE T_BCM_ISDIMMAPTARGENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FDIMTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FDIMENSIONID BIGINT DEFAULT 0 NOT NULL,
FBYFROM CHAR(1) DEFAULT '1' NOT NULL
);


 EXEC p_AlterColumn 'T_BCM_DIMMEMBCOMBENTRY', 'FFLOATITEM', 'BIGINT', 'NOT NULL', '1111', '0';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMEMBCOMBENTRY' AND KSQL_COL_NAME IN ('FACCESSFORMULA')) 
 ALTER TABLE T_BCM_DIMMEMBCOMBENTRY ADD (FACCESSFORMULA NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_DIMMEMBCOMBENTRY' AND KSQL_COL_NAME IN ('FTEXTSPREAD')) 
 ALTER TABLE T_BCM_DIMMEMBCOMBENTRY ADD (FTEXTSPREAD BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_SCENECURRENCYSCALE') 
 CREATE TABLE T_BCM_SCENECURRENCYSCALE (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FSCALE INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FCOPYEXEID')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FCOPYEXEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_SCHEMEEXECUTEREC' AND KSQL_COL_NAME IN ('FPARAMJSON')) 
 ALTER TABLE T_BCM_SCHEMEEXECUTEREC ADD (FPARAMJSON NCLOB );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFCHANGETYPE' AND KSQL_COL_NAME IN ('FVALUE')) 
 ALTER TABLE T_BCM_STRUCTOFCHANGETYPE ADD (FVALUE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_STRUCTOFSCENE' AND KSQL_COL_NAME IN ('FVALUE')) 
 ALTER TABLE T_BCM_STRUCTOFSCENE ADD (FVALUE BIGINT DEFAULT 0 NOT NULL );
 EXEC p_AlterColumn 'T_BCM_CHKFORMULASETTING', 'FLEFTFORMULA', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_BCM_CHKFORMULASETTING', 'FRIGHTFORMULA', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_BCM_CHKFORMULASETTING', 'FLFORMULATMP', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_BCM_CHKFORMULASETTING', 'FRFORMULATMP', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_BCM_CHKREPORT', 'FCALCRESULTEXPR', 'VARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_CHKREPORT', 'FFULLLFORMULA', 'NCLOB', 'NULL', '1111', 'NULL';

 EXEC p_AlterColumn 'T_BCM_CHKREPORT', 'FFULLRFORMULA', 'NCLOB', 'NULL', '1111', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKREPORT' AND KSQL_COL_NAME IN ('FMODIFYTIME')) 
 ALTER TABLE T_BCM_CHKREPORT ADD (FMODIFYTIME DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BCM_CHKREPORT' AND KSQL_COL_NAME IN ('FMODIFIERID')) 
 ALTER TABLE T_BCM_CHKREPORT ADD (FMODIFIERID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISBASEENTLIST_L') 
 CREATE TABLE T_BCM_ISBASEENTLIST_L (
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(36) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISDIMMAPSRCDEFVAL_L') 
 CREATE TABLE T_BCM_ISDIMMAPSRCDEFVAL_L (
FSRCMEMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(36) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISDIMMAPTARGDEFVAL_L') 
 CREATE TABLE T_BCM_ISDIMMAPTARGDEFVAL_L (
FTAGMEMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FPKID VARCHAR(30) DEFAULT ' ' NOT NULL,
FLOCALEID VARCHAR(36) DEFAULT ' ' NOT NULL
);


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


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


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


 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_STRUCTOFCURRENCY', 'FSCALE', 'NULL', 'NULL', '1001', 'NULL';

 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BCM_RPTADJUSTDATA', 'FMAPPINGENTRYID', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_BCM_ISSCHEME') 
 CREATE TABLE T_BCM_ISSCHEME (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FISSRCID BIGINT DEFAULT 0 NOT NULL,
FISTARGID BIGINT DEFAULT 0 NOT NULL,
FISSCHEMEID BIGINT DEFAULT 0 NOT NULL,
FSCHEMECATALOGID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FDESCRIPTION NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FENABLE CHAR(1) DEFAULT '0' NOT NULL
);








 EXEC p_AlterColumn 'T_BCM_STRUCTOFPROJECT_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_STRUCTOFVERSION_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';



 EXEC p_AlterColumn 'T_BCM_STRUCTOFDATETYPE_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_USERSELECT', 'FAPPLICATION', 'VARCHAR(2)', 'NOT NULL', '1111', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFACCOUNT_L', 'FLOCALEID', 'VARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFCHANGETYPE_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFAUDITTRIAL_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFFY_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFPERIOD_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFPROCESS_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFRULE_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFCURRENCY_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFSCENE_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFDEFINED_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFPROJECT_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFVERSION_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFDATASORT_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_MEMBOFDATETYPE_L', 'FNAME', 'NVARCHAR(200)', 'NOT NULL', '0100', ''' ''';

 EXEC p_AlterColumn 'T_BCM_STRUCTOFACCOUNT', 'FDATATYPE', 'CHAR(1)', 'NOT NULL', '0001', '''0''';

 EXEC p_AlterColumn 'T_BCM_STRUCTOFDEFINED', 'FDATATYPE', 'CHAR(1)', 'NOT NULL', '0001', '''0''';


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