/**Begin D:\PDM_UPGRADE\PDM1\EB_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_EB_STRUCTOFACCOUNT' AND KSQL_COL_NAME ='FAPPROVALTYPE') 
 ALTER TABLE T_EB_STRUCTOFACCOUNT ADD (FAPPROVALTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPADJRECORD') 
 CREATE TABLE T_EB_CENTRALAPPADJRECORD (
FID BIGINT DEFAULT 0 NOT NULL,
FAPPROVEBILLNO VARCHAR(60) DEFAULT ' ' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPADJENTITY') 
 CREATE TABLE T_EB_CENTRALAPPADJENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FREPORTBILLNO VARCHAR(60) DEFAULT ' ' NOT NULL,
FTEMPLATE BIGINT DEFAULT 0 NOT NULL,
FDIM1 VARCHAR(60) DEFAULT ' ' NOT NULL,
FDIM2 VARCHAR(60) DEFAULT ' ' NOT NULL,
FDIM3 VARCHAR(60) DEFAULT ' ' NOT NULL,
FDIM4 VARCHAR(60) DEFAULT ' ' NOT NULL,
FDIMRANGE NCLOB,
FADJUSTREPORT1 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTREPORT2 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTREPORT3 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FADJUSTREPORT4 DECIMAL(23,10) DEFAULT 0 NOT NULL,
FSUGGESTION NVARCHAR(150) DEFAULT ' ' NOT NULL,
FAPPROVER BIGINT DEFAULT 0 NOT NULL,
FAPPROVEDATE DATETIME
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPPLAN') 
 CREATE TABLE T_EB_CENTRALAPPPLAN (
FID BIGINT DEFAULT 0 NOT NULL,
FMODEL BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(80) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(160) DEFAULT ' ' NOT NULL,
FBUSIRANG BIGINT DEFAULT 0 NOT NULL,
FISAPPDETAIL CHAR(1) DEFAULT '0' NOT NULL,
FAPPRELATYPE VARCHAR(10) DEFAULT ' ' NOT NULL,
FBAPPRELA VARCHAR(10) DEFAULT ' ' NOT NULL,
FEFFECTSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FEXPLAIN NCLOB,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FMODIFYDATE DATETIME,
FAPPTEMPLATE NCLOB,
FBEFOREAPPTEMPLATETYPE VARCHAR(5) DEFAULT ' ' NOT NULL,
FAPPTEMPLATETYPE VARCHAR(5) DEFAULT ' ' NOT NULL
);


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


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


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


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


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPRECENTITY') 
 CREATE TABLE T_EB_CENTRALAPPRECENTITY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FCENTRALAPPTYPE BIGINT DEFAULT 0 NOT NULL,
FENTITY BIGINT DEFAULT 0 NOT NULL,
FAPPROVER BIGINT DEFAULT 0 NOT NULL,
FORDER NVARCHAR(20) DEFAULT ' ' NOT NULL,
FSTATUS NVARCHAR(20) DEFAULT ' ' NOT NULL,
FAPPROVEDATE DATETIME,
FSUGGESTION NVARCHAR(500) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPREL') 
 CREATE TABLE T_EB_CENTRALAPPREL (
FID BIGINT DEFAULT 0 NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FVIEWID NVARCHAR(100) DEFAULT ' ' NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FCENTRALENTITYORG NCLOB,
FCENTRALENTITYSUMMARY BIGINT DEFAULT 0 NOT NULL,
FCENTRALAPPENTITY BIGINT DEFAULT 0 NOT NULL,
FEFFECTSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FCREATER BIGINT DEFAULT 0 NOT NULL,
FMODIFIER BIGINT DEFAULT 0 NOT NULL,
FCREATEDATE DATETIME,
FMODIFYDATE DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_EB_CENTRALAPPTYPE') 
 CREATE TABLE T_EB_CENTRALAPPTYPE (
FID BIGINT DEFAULT 0 NOT NULL,
FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
FEFFECTSTATUS CHAR(1) DEFAULT '0' NOT NULL,
FMODELID BIGINT DEFAULT 0 NOT NULL,
FCREATERFIELD BIGINT DEFAULT 0 NOT NULL,
FMODIFIERFIELD BIGINT DEFAULT 0 NOT NULL,
FCREATEDATEFIELD DATETIME,
FMODIFYDATEFIELD DATETIME,
FBILLSTATUS VARCHAR(10) DEFAULT ' ' NOT NULL
);

 --- drop TABLE --------- 不允许删除表T_EB_DADASSDF，请恢复pdm ------------------- 

/**End D:\PDM_UPGRADE\PDM1\EB_table.sql **/
