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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_OFFSETRULEACCOUNTS') 
 CREATE TABLE T_EB_OFFSETRULEACCOUNTS (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FSENDERACCOUNT CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_OFFSETRULE') 
 CREATE TABLE T_EB_OFFSETRULE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FENABLE CHAR(1) DEFAULT '1' NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FOFFSETRULECATALOGID BIGINT DEFAULT 0 NOT NULL,
FVARHANDLE NVARCHAR(30) DEFAULT ' ' NOT NULL,
FASSISTDIM NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
FMETRICID BIGINT DEFAULT 0 NOT NULL,
FVARACCOUNTID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FAUDITTRAILID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_OFFSETRULECATALOG') 
 CREATE TABLE T_EB_OFFSETRULECATALOG (
FID BIGINT DEFAULT 0 NOT NULL,
FCREATORID BIGINT DEFAULT 0 NOT NULL,
FCREATETIME DATETIME,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
FMODIFYTIME DATETIME,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(60) DEFAULT ' ' NOT NULL,
FLONGNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
FLEVEL BIGINT DEFAULT 0 NOT NULL,
FISLEAF CHAR(1) DEFAULT '1' NOT NULL,
FPARENTID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_OFFSETRULECATALOG_L') 
 CREATE TABLE T_EB_OFFSETRULECATALOG_L (
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FID BIGINT DEFAULT 0 NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FFULLNAME NVARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIMMEMBERHISTORY') 
 CREATE TABLE T_EB_DIMMEMBERHISTORY (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FBUSINESSDATA NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMENSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBIZNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDIMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_BIZRULETAXES' AND KSQL_COL_NAME ='FDESCRIPTION') 
 ALTER TABLE T_BGMD_BIZRULETAXES ADD (FDESCRIPTION NVARCHAR(510) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVETEMPENTRY') 
 CREATE TABLE T_EB_APPROVETEMPENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FTEMPID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DYNAMICREPORT' AND KSQL_COL_NAME ='FCREATER') 
 ALTER TABLE T_EB_DYNAMICREPORT ADD (FCREATER BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_DYNAMICREPORT' AND KSQL_COL_NAME ='FSTATUS') 
 ALTER TABLE T_EB_DYNAMICREPORT ADD (FSTATUS CHAR(1) DEFAULT '0' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_PLANRULEENTITY' AND KSQL_COL_NAME ='FENTITY') 
 ALTER TABLE T_BGMD_PLANRULEENTITY ADD (FENTITY BIGINT DEFAULT 0 NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BGMD_PLANRULEENTITY', 'FORG', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_PLANRULE' AND KSQL_COL_NAME ='FRULEFROM') 
 ALTER TABLE T_BGMD_PLANRULE ADD (FRULEFROM CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_PLANRULE' AND KSQL_COL_NAME ='FHELPDIMID') 
 ALTER TABLE T_BGMD_PLANRULE ADD (FHELPDIMID NVARCHAR(510) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_PLANRULE' AND KSQL_COL_NAME ='FHELPDIMNAME') 
 ALTER TABLE T_BGMD_PLANRULE ADD (FHELPDIMNAME NVARCHAR(510) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_BGMD_PLANRULE' AND KSQL_COL_NAME ='FTAXINCLUSIVE') 
 ALTER TABLE T_BGMD_PLANRULE ADD (FTAXINCLUSIVE CHAR(1) DEFAULT '0' NOT NULL );
 --- drop column --------- 请认真检查该脚本 ------------------- 
 EXEC p_AlterColumn 'T_BGMD_PLANRULE', 'FROOTIN', 'NULL', 'NULL', '1001', 'NULL';

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVETEMPLATE') 
 CREATE TABLE T_EB_APPROVETEMPLATE (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FDIMENSIONRANG NVARCHAR(100) DEFAULT ' ' NOT NULL,
FDIMENSION NCLOB,
FSTATE CHAR(1) DEFAULT '1' NOT NULL
);



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