/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_MATCHRULE' AND KSQL_COL_NAME IN ('FLINKENTITY'))
ALTER TABLE T_FPM_MATCHRULE ADD (FLINKENTITY VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_MATCHRULE_RULE' AND KSQL_COL_NAME IN ('FMATCHPROP'))
ALTER TABLE T_FPM_MATCHRULE_RULE ADD (FMATCHPROP VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CONTROLWAYCONFIG')
CREATE TABLE T_FPM_CONTROLWAYCONFIG (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FSTATUS CHAR(5) DEFAULT ' ' NOT NULL,
                                        FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                        FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                        FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
                                        FCREATETIME DATETIME,
                                        FMODIFYTIME DATETIME,
                                        FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                        FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                        FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                        FENABLEDATE DATETIME,
                                        FDISABLEDATE DATETIME,
                                        FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                        FREPORTTYPE BIGINT DEFAULT 0 NOT NULL,
                                        FPERIODSTRATEGY VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FUNAVAILABLEWARN INT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CONTROL_STRATEGY')
CREATE TABLE T_FPM_CONTROL_STRATEGY (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSUBJECTID BIGINT DEFAULT 0 NOT NULL,
                                        FSUBJECTFLOW VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FCONTROLINTENSITY VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FCONTROLCOEFFICIENT DECIMAL(5,2) DEFAULT 0 NOT NULL,
                                        FDETAILCONTROL CHAR(1) DEFAULT ' ' NOT NULL,
                                        FDETAILCONTROLBASIS VARCHAR(1024) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_EXECUTETIME')
CREATE TABLE T_FPM_EXECUTETIME (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FNUMBER VARCHAR(30) DEFAULT ' ' NOT NULL,
                                   FSTATUS VARCHAR(5) DEFAULT ' ' NOT NULL,
                                   FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                   FENABLE CHAR(1) DEFAULT ' ' NOT NULL,
                                   FCREATETIME DATETIME,
                                   FMODIFYTIME DATETIME,
                                   FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                   FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                   FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                   FENABLEDATE DATETIME,
                                   FDISABLEDATE DATETIME,
                                   FBODYSYSID BIGINT DEFAULT 0 NOT NULL
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_ACLDEDUCTIONBILL')
CREATE TABLE T_FPM_ACLDEDUCTIONBILL (
                                        FPKID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FBASEDATAID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_PREEMPTEDBILL')
CREATE TABLE T_FPM_PREEMPTEDBILL (
                                     FPKID BIGINT DEFAULT 0 NOT NULL,
                                     FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FBASEDATAID VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_PREEMPTEDTIME')
CREATE TABLE T_FPM_PREEMPTEDTIME (
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                     FSEQ INT DEFAULT 0 NOT NULL,
                                     FBUSINESSBILLID VARCHAR(50) DEFAULT ' ' NOT NULL,
                                     FPREEMPTEDTIME VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                     FPREEMPTEDTIMECODE VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                     FUNPREEMPTED VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                     FUNPREEMPTEDCODE VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                     FRELEASE VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                     FRELEASECODE VARCHAR(1024) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_ACLDEDUCTION')
CREATE TABLE T_FPM_ACLDEDUCTION (
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                    FSEQ INT DEFAULT 0 NOT NULL,
                                    FACLBUSINESSBILL VARCHAR(50) DEFAULT ' ' NOT NULL,
                                    FACLDEDUCTION VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                    FACLDEDUCTIONCODE VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                    FUNACLDEDUCTION VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                    FUNACLDEDUCTIONCODE VARCHAR(1024) DEFAULT ' ' NOT NULL
);


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



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