/**Begin E:\NextERP_PDM\PDM_UPGRADE\PDMS\branch_lastest\pdm\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_APPROVEBILL' AND KSQL_COL_NAME ='FAPPROVALTYPE') 
 ALTER TABLE T_EB_APPROVEBILL ADD (FAPPROVALTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TASK' AND KSQL_COL_NAME ='FAPPROVALTYPEID') 
 ALTER TABLE T_EB_TASK ADD (FAPPROVALTYPEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TASKLIST' AND KSQL_COL_NAME ='FCATALOG') 
 ALTER TABLE T_EB_TASKLIST ADD (FCATALOG NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_TASKLIST' AND KSQL_COL_NAME ='FBIZMODELID') 
 ALTER TABLE T_EB_TASKLIST ADD (FBIZMODELID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MODELUPLOAD_L') 
 CREATE TABLE T_EB_MODELUPLOAD_L (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(300) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MODELUPLOAD') 
 CREATE TABLE T_EB_MODELUPLOAD (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NCLOB,
FNAME NCLOB,
FSRCMODEL BIGINT DEFAULT 0 NOT NULL,
FSRCBIZ BIGINT DEFAULT 0 NOT NULL,
FTARMODEL BIGINT DEFAULT 0 NOT NULL,
FTARBIZ BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '1' NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MODELUPLOAD_DIMMAP') 
 CREATE TABLE T_EB_MODELUPLOAD_DIMMAP (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 1 NOT NULL,
FSRCDIM BIGINT DEFAULT 0 NOT NULL,
FSRCMEMBERID BIGINT DEFAULT 0 NOT NULL,
FSRCMEMBERTYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FTARDIM BIGINT DEFAULT 0 NOT NULL,
FTARMEMBERID BIGINT DEFAULT 0 NOT NULL,
FTARMEMBERTYPE VARCHAR(100) DEFAULT ' ' NOT NULL,
FONLYMAP CHAR(1) DEFAULT '0' NOT NULL,
FMEMBERMAP BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_APPROVALTYPE') 
 CREATE TABLE T_EB_APPROVALTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(1000) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME,
FCREATERID BIGINT DEFAULT 0 NOT NULL,
FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIM_MEMBERMAP') 
 CREATE TABLE T_EB_DIM_MEMBERMAP (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FSRCMODEL BIGINT DEFAULT 0 NOT NULL,
FSRCDIM BIGINT DEFAULT 0 NOT NULL,
FSRCDIMVIEW BIGINT DEFAULT 0 NOT NULL,
FTARMODEL BIGINT DEFAULT 0 NOT NULL,
FTARDIM BIGINT DEFAULT 0 NOT NULL,
FTARDIMVIEW BIGINT DEFAULT 0 NOT NULL,
FDESC NVARCHAR(300) DEFAULT ' ' NOT NULL,
FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATEFIELD DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_MODELUPLOAD_LOG') 
 CREATE TABLE T_EB_MODELUPLOAD_LOG (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELUPLOAD BIGINT DEFAULT 0 NOT NULL,
FSTATUS CHAR(1) DEFAULT '3' NOT NULL,
FORG NCLOB,
FBP NCLOB,
FSRCVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTARVERSION NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSUCCESSCOUNT INT DEFAULT 0 NOT NULL,
FFAILCOUNT INT DEFAULT 0 NOT NULL,
FFAILMSG NVARCHAR(200) DEFAULT ' ' NOT NULL,
FCREATEDATEFIELD DATETIME,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_BIZRULEGROUP' AND KSQL_COL_NAME ='FAPPLICATIONSCENARIO') 
 ALTER TABLE T_EB_BIZRULEGROUP ADD (FAPPLICATIONSCENARIO BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_DIM_MEMBERMAPVAL') 
 CREATE TABLE T_EB_DIM_MEMBERMAPVAL (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FSRCMEMBERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSRCMEMBERNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTARMEMBERNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FTARMEMBERNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FSTATE CHAR(1) DEFAULT '1' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_RECEIVEPARAMETER') 
 CREATE TABLE T_EB_RECEIVEPARAMETER (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FVERSIONID BIGINT DEFAULT 0 NOT NULL,
FSTARTDATE DATETIME,
FENDDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_PROJECTIMPL') 
 CREATE TABLE T_EB_PROJECTIMPL (
FID BIGINT DEFAULT 0 NOT NULL,
FDYN NCLOB,
FUSERID BIGINT DEFAULT 0 NOT NULL,
FNEWDIMMEMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FNEWDIMMEMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOLDDIMMEMBERID NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOLDDIMMEMNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FOLDDIMMEMNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FENTRYTITYNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUDGETMONEY NVARCHAR(50) DEFAULT ' ' NOT NULL,
FBUDGETITEM NVARCHAR(50) DEFAULT ' ' NOT NULL,
FRESTOREDATA NVARCHAR(50) DEFAULT ' ' NOT NULL,
FCREATTIME DATETIME,
FPARENTNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
FPARENTNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_RECEIVEPARAMETER_L') 
 CREATE TABLE T_EB_RECEIVEPARAMETER_L (
FID BIGINT DEFAULT 0 NOT NULL,
FPKID NVARCHAR(30) DEFAULT ' ' NOT NULL,
FLOCALEID NVARCHAR(10) DEFAULT ' ' NOT NULL,
FDESCRIPTION NVARCHAR(300) DEFAULT ' ' NOT NULL
);



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