/**Begin D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_BIZ_CLASS')
CREATE TABLE T_FAH_BIZ_CLASS (
                                 FID BIGINT DEFAULT 0 NOT NULL,
                                 FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                 FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                 FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                 FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                 FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                 FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                 FCREATETIME DATETIME,
                                 FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                 FMODIFYTIME DATETIME,
                                 FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_BIZ_TYPE')
CREATE TABLE T_FAH_BIZ_TYPE (
                                FID BIGINT DEFAULT 0 NOT NULL,
                                FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                FCREATETIME DATETIME,
                                FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                FMODIFYTIME DATETIME,
                                FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_GEN_RULE')
CREATE TABLE T_FAH_EVT_GEN_RULE (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                    FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                    FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                    FBIZCLASSID BIGINT DEFAULT 0 NOT NULL,
                                    FBIZTYPEID BIGINT DEFAULT 0 NOT NULL,
                                    FSOURCEBILL VARCHAR(36) DEFAULT ' ' NOT NULL,
                                    FSOURCEENTRY VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FBIZORG VARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FBIZDATE VARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FBOOKEDDATE VARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FNEEDACCT CHAR(1) DEFAULT '0' NOT NULL,
                                    FCREATETIME DATETIME,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFYTIME DATETIME,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                    FENABLEDBYID BIGINT DEFAULT 0 NOT NULL,
                                    FDISABLEDBYID BIGINT DEFAULT 0 NOT NULL,
                                    FENABLEDTIME DATETIME,
                                    FDISABLEDTIME DATETIME
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_LINETYPE')
CREATE TABLE T_FAH_EVT_LINETYPE (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                    FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FDESC NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                    FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                    FISSYSRESERVED CHAR(1) DEFAULT '0' NOT NULL,
                                    FALLOW_FORWARDACCT CHAR(1) DEFAULT ' ' NOT NULL,
                                    FPOSTGL_ONACCTCONSOLIDATE CHAR(1) DEFAULT ' ' NOT NULL,
                                    FCREATETIME DATETIME,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFYTIME DATETIME,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVTLINE_GEN_RULE')
CREATE TABLE T_FAH_EVTLINE_GEN_RULE (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                        FEVTLINETYPEID BIGINT DEFAULT 0 NOT NULL,
                                        FAMOUNTID BIGINT DEFAULT 0 NOT NULL,
                                        FCURRENCYID BIGINT DEFAULT 0 NOT NULL,
                                        FDIMGRPTYPEID BIGINT DEFAULT 0 NOT NULL,
                                        FRELATIONDISPLAYINFO NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DYN_EXTFLD')
CREATE TABLE T_FAH_DYN_EXTFLD (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                  FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
                                  FSOURCEFIELD VARCHAR(100) DEFAULT ' ' NOT NULL,
                                  FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FSOURCEPAGE VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FOUTPUTDATATYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                  FENABLEFUNCTION VARCHAR(30) DEFAULT ' ' NOT NULL,
                                  FBASEPROP VARCHAR(36) DEFAULT ' ' NOT NULL,
                                  FASSISTPROP BIGINT DEFAULT 0 NOT NULL,
                                  FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                  FCREATETIME DATETIME,
                                  FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                  FMODIFYTIME DATETIME,
                                  FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DYN_EXTFLD_CUSTRULE')
CREATE TABLE T_FAH_DYN_EXTFLD_CUSTRULE (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FCUSTVALEXTRRULEID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                           FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                           FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                           FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DYN_EXTFLD_ENTRY')
CREATE TABLE T_FAH_DYN_EXTFLD_ENTRY (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FSOURCETYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                        FCONSTANT NCLOB,
                                        FSOURCEFIELD VARCHAR(100) DEFAULT ' ' NOT NULL,
                                        FEXPRESSION NCLOB,
                                        FEXPRESSIONDESC NCLOB,
                                        FEXPRESSIONDESC_TAG NCLOB,
                                        FOUTPUTDATATYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                        FENABLE CHAR(1) DEFAULT '0' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DYNEXTFLD_MAPEN')
CREATE TABLE T_FAH_DYNEXTFLD_MAPEN (
                                       FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FSEQ INT DEFAULT 0 NOT NULL,
                                       FPARAMDATATYPE VARCHAR(2) DEFAULT ' ' NOT NULL,
                                       FGETVALUETYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                       FTEXTVALUE NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FREFPROPVALUE BIGINT DEFAULT 0 NOT NULL,
                                       FDATEVALUE DATETIME,
                                       FEXPRESSIONVALUE NCLOB,
                                       FBILLTYPE NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                       FPARAM NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FMAPPINGRULEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DYNEXTFLD_VALSET')
CREATE TABLE T_FAH_DYNEXTFLD_VALSET (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FBRANCHID BIGINT DEFAULT 0 NOT NULL,
                                        FDYNEXTFLDID BIGINT DEFAULT 0 NOT NULL,
                                        FRULEID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FFILTERRULE NCLOB,
                                        FGETVALUETYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                        FTEXTVALUE NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                        FREFPROPVALUE BIGINT DEFAULT 0 NOT NULL,
                                        FDATEVALUE DATETIME,
                                        FEXPRESSIONVALUE NCLOB,
                                        FGROUPSEQ INT DEFAULT 0 NOT NULL,
                                        FMAPPINGGROUPID BIGINT DEFAULT 0 NOT NULL,
                                        FASSTACTID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_ACCOUNTPURPOSE')
CREATE TABLE T_FAH_EVT_ACCOUNTPURPOSE (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                          FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                          FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                          FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                          FCREATETIME DATETIME,
                                          FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                          FMODIFYTIME DATETIME,
                                          FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                          FACCOUNTSOURCE CHAR(1) DEFAULT ' ' NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_ACCTLINE')
CREATE TABLE T_FAH_EVT_ACCTLINE (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FSEQ INT DEFAULT 0 NOT NULL,
                                    FACCTRULEID BIGINT DEFAULT 0 NOT NULL,
                                    FACCTGROUPID BIGINT DEFAULT 0 NOT NULL,
                                    FEVENTLINERULEID BIGINT DEFAULT 0 NOT NULL,
                                    FACCTDIRECTION CHAR(2) DEFAULT ' ' NOT NULL,
                                    FAMOUNT BIGINT DEFAULT 0 NOT NULL,
                                    FCURRENCY BIGINT DEFAULT 0 NOT NULL,
                                    FEXCHANGERATE BIGINT DEFAULT 0 NOT NULL,
                                    FACCOUNT BIGINT DEFAULT 0 NOT NULL,
                                    FASSGRP BIGINT DEFAULT 0 NOT NULL,
                                    FSUMMARY BIGINT DEFAULT 0 NOT NULL,
                                    FCASHFLOWITEM BIGINT DEFAULT 0 NOT NULL,
                                    FCASHFLOWSUPITEM BIGINT DEFAULT 0 NOT NULL,
                                    FCASHFLOWITEMASSGRP BIGINT DEFAULT 0 NOT NULL,
                                    FQUANTITY BIGINT DEFAULT 0 NOT NULL,
                                    FMEASUREMENT BIGINT DEFAULT 0 NOT NULL,
                                    FUNITPRICE BIGINT DEFAULT 0 NOT NULL,
                                    FBIZNUMBER BIGINT DEFAULT 0 NOT NULL,
                                    FEXPIREDATE BIGINT DEFAULT 0 NOT NULL,
                                    FISNEEDMERGE CHAR(1) DEFAULT '0' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_ACCTPUBLICINFO')
CREATE TABLE T_FAH_EVT_ACCTPUBLICINFO (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FACCTRULEID BIGINT DEFAULT 0 NOT NULL,
                                          FACCTGROUPID BIGINT DEFAULT 0 NOT NULL,
                                          FACCTORG BIGINT DEFAULT 0 NOT NULL,
                                          FACCTBOOK BIGINT DEFAULT 0 NOT NULL,
                                          FACCTDATE BIGINT DEFAULT 0 NOT NULL,
                                          FACCTPERIOD BIGINT DEFAULT 0 NOT NULL,
                                          FVOUCHERTYPE BIGINT DEFAULT 0 NOT NULL,
                                          FCREATOR BIGINT DEFAULT 0 NOT NULL,
                                          FBIZDATE BIGINT DEFAULT 0 NOT NULL,
                                          FATTACHMENT BIGINT DEFAULT 0 NOT NULL,
                                          FREFERENCEINFORMATION BIGINT DEFAULT 0 NOT NULL,
                                          FGROUPMERGERULEID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_ACCTRULE')
CREATE TABLE T_FAH_EVT_ACCTRULE (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                    FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                    FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                    FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                    FCREATETIME DATETIME,
                                    FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                    FMODIFYTIME DATETIME,
                                    FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                    FEVENTRULEID BIGINT DEFAULT 0 NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_DISP_EN')
CREATE TABLE T_FAH_EVT_DISP_EN (
                                   FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                   FFULLNUMBER NVARCHAR(500) DEFAULT ' ' NOT NULL,
                                   FORGID BIGINT DEFAULT 0 NOT NULL,
                                   FVALUEZONE VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_DISP_PARAMCFG')
CREATE TABLE T_FAH_EVT_DISP_PARAMCFG (
                                         FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FPARAMFIELD VARCHAR(15) DEFAULT ' ' NOT NULL,
                                         FPARAMVALUESOURCE NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                         FORGID BIGINT DEFAULT 0 NOT NULL,
                                         FVALUEZONE VARCHAR(100) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_DISP_RULE')
CREATE TABLE T_FAH_EVT_DISP_RULE (
                                     FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FORGID BIGINT DEFAULT 0 NOT NULL,
                                     FVALUEZONE VARCHAR(100) DEFAULT ' ' NOT NULL,
                                     FDISPGRP BIGINT DEFAULT 0 NOT NULL,
                                     FHASHCODE BIGINT DEFAULT 0 NOT NULL,
                                     FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                     FEFFECTDATE DATETIME,
                                     FEXPIREDATE DATETIME,
                                     FSERIALNUMBER INT DEFAULT 0 NOT NULL,
                                     FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                     FTXTATTR1 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR2 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR3 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR4 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR5 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR6 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR7 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR8 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR9 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                     FTXTATTR10 NVARCHAR(150) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_DISP_RULE_TMP')
CREATE TABLE T_FAH_EVT_DISP_RULE_TMP (
                                         FDISPATCHID BIGINT DEFAULT 0 NOT NULL,
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FORGID BIGINT DEFAULT 0 NOT NULL,
                                         FVALUEZONE VARCHAR(100) DEFAULT ' ' NOT NULL,
                                         FDISPGRP BIGINT DEFAULT 0 NOT NULL,
                                         FHASHCODE BIGINT DEFAULT 0 NOT NULL,
                                         FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                         FEFFECTDATE DATETIME,
                                         FEXPIREDATE DATETIME,
                                         FSERIALNUMBER INT DEFAULT 0 NOT NULL,
                                         FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                         FTXTATTR1 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR2 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR3 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR4 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR5 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR6 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR7 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR8 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR9 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FTXTATTR10 NVARCHAR(150) DEFAULT ' ' NOT NULL,
                                         FBATCHID VARCHAR(30) DEFAULT ' ' NOT NULL,
                                         FCHANGETYPE CHAR(1) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVT_DISP_SCHEME')
CREATE TABLE T_FAH_EVT_DISP_SCHEME (
                                       FID BIGINT DEFAULT 0 NOT NULL,
                                       FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                       FNUMBER NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                       FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                       FSOURCEBILL VARCHAR(36) DEFAULT ' ' NOT NULL,
                                       FORGSRCFIELD VARCHAR(36) DEFAULT ' ' NOT NULL,
                                       FDEFINEDVALUEZONE VARCHAR(500) DEFAULT ' ' NOT NULL,
                                       FDISPATCHINPARAMS NCLOB,
                                       FCHECKSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                       FLASTCHECKTIME DATETIME,
                                       FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                       FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                       FCREATETIME DATETIME,
                                       FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                       FMODIFYTIME DATETIME,
                                       FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                       FCREATEORG BIGINT DEFAULT 0 NOT NULL
);


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


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


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DIMGRP_TYPE_EVTLNK')
CREATE TABLE T_FAH_DIMGRP_TYPE_EVTLNK (
                                          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_FAH_DIMGRP_TYPE_EN')
CREATE TABLE T_FAH_DIMGRP_TYPE_EN (
                                      FID BIGINT DEFAULT 0 NOT NULL,
                                      FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                      FSEQ INT DEFAULT 0 NOT NULL,
                                      FBIZDIMTYPEID BIGINT DEFAULT 0 NOT NULL,
                                      FBIZDIMTYPENUM NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                      FISREQUIRED CHAR(1) DEFAULT '0' NOT NULL,
                                      FISENABLED CHAR(1) DEFAULT '0' NOT NULL,
                                      FISSYSRESERVED CHAR(1) DEFAULT '0' NOT NULL,
                                      FCUSTGRPID BIGINT DEFAULT 0 NOT NULL,
                                      FDIMINNERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DIMGRP_TYPE_CUST')
CREATE TABLE T_FAH_DIMGRP_TYPE_CUST (
                                        FDIMGRPTYPEID BIGINT DEFAULT 0 NOT NULL,
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                        FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_DIMGRP_TYPE')
CREATE TABLE T_FAH_DIMGRP_TYPE (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                   FNUMBER NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                   FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FISSYSRESERVED CHAR(1) DEFAULT '0' NOT NULL,
                                   FSTATUS CHAR(1) DEFAULT ' ' NOT NULL,
                                   FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                                   FCREATETIME DATETIME,
                                   FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                   FMODIFYTIME DATETIME,
                                   FMODIFIERID BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_REGBILL')
CREATE TABLE T_FAH_REGBILL (
                               FID BIGINT DEFAULT 0 NOT NULL,
                               FENABLE CHAR(1) DEFAULT '0' NOT NULL,
                               FSRCAPPID VARCHAR(36) DEFAULT ' ' NOT NULL,
                               FSRCBILLTYPE VARCHAR(36) DEFAULT ' ' NOT NULL,
                               FSRCBILLORGFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
                               FSRCBILLDATEFIELD VARCHAR(50) DEFAULT ' ' NOT NULL,
                               FSRCBILLSTATUS VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FAH_EVTLINE_RELATION')
CREATE TABLE T_FAH_EVTLINE_RELATION (
                                        FDETAILID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FPARENT_EVTRULEID BIGINT DEFAULT 0 NOT NULL,
                                        FPARENT_BILLTYPEID VARCHAR(36) DEFAULT ' ' NOT NULL,
                                        FRELATIONTYPE CHAR(1) DEFAULT ' ' NOT NULL,
                                        FRELATIONDETAILS NCLOB
);



/**End D:\work\kuaijishijian\pdm\PDM_UPGRADE_1.4\PDM_UPGRADE\PDM1\AI_table.sql **/
