IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATE_LAYOUT' AND KSQL_COL_NAME IN ('FMEMBERSCOPE'))
ALTER TABLE T_FPM_TEMPLATE_LAYOUT ADD (FMEMBERSCOPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATE_LAYOUT' AND KSQL_COL_NAME IN ('FFILTERDIM'))
ALTER TABLE T_FPM_TEMPLATE_LAYOUT ADD (FFILTERDIM CHAR(1) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEBAK_LAYOUT' AND KSQL_COL_NAME IN ('FMEMBERSCOPE'))
ALTER TABLE T_FPM_TEMPLATEBAK_LAYOUT ADD (FMEMBERSCOPE VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEBAK_LAYOUT' AND KSQL_COL_NAME IN ('FFILTERDIM'))
ALTER TABLE T_FPM_TEMPLATEBAK_LAYOUT ADD (FFILTERDIM CHAR(1) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEINFO' AND KSQL_COL_NAME IN ('FTEMPLATEUSES'))
ALTER TABLE T_FPM_TEMPLATEINFO ADD (FTEMPLATEUSES VARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEINFO_BAK' AND KSQL_COL_NAME IN ('FTEMPLATEUSES'))
ALTER TABLE T_FPM_TEMPLATEINFO_BAK ADD (FTEMPLATEUSES VARCHAR(50) DEFAULT ' ' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_STATANALYSISTEMP')
CREATE TABLE T_FPM_STATANALYSISTEMP (
                                        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_FPM_STATANALYSISTEMPBAK')
CREATE TABLE T_FPM_STATANALYSISTEMPBAK (
                                           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_FPM_SUMMARYCONFIG')
CREATE TABLE T_FPM_SUMMARYCONFIG (
                                     FID BIGINT DEFAULT 0 NOT NULL,
                                     FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                     FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                     FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                     FENABLEDATE DATETIME,
                                     FDISABLEDATE DATETIME,
                                     FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                     FSUMREPULSESTATUS VARCHAR(50) DEFAULT ' ' NOT NULL,
                                     FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                     FSTATUS VARCHAR(50) 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
);



IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_SUMREPORTTYPE')
CREATE TABLE T_FPM_SUMREPORTTYPE (
                                     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_FPM_SUMMARYMAINPARAM')
CREATE TABLE T_FPM_SUMMARYMAINPARAM (
                                        FID BIGINT DEFAULT 0 NOT NULL,
                                        FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FSEQ INT DEFAULT 0 NOT NULL,
                                        FPARENTENTRYID BIGINT DEFAULT 0 NOT NULL,
                                        FREPORTORGID BIGINT DEFAULT 0 NOT NULL,
                                        FISSUMAUDIT CHAR(1) DEFAULT ' ' NOT NULL,
                                        FISCHECKSUBLIMIT VARCHAR(50) DEFAULT ' ' NOT NULL,
                                        FCURRENCYMAPCASE VARCHAR(125) DEFAULT ' ' NOT NULL,
                                        FCURRENCYMAPCASEREAL NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                        FCURRENCYMAPCASEREAL_TAG NCLOB
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_INTERNALCANCELRULE')
CREATE TABLE T_FPM_INTERNALCANCELRULE (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FNUMBER VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FDISABLERID BIGINT DEFAULT 0 NOT NULL,
                                          FENABLERID BIGINT DEFAULT 0 NOT NULL,
                                          FENABLEDATE DATETIME,
                                          FDISABLEDATE DATETIME,
                                          FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                          FDIFFPROCESSMODE VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FNAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FSTATUS VARCHAR(50) 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
);


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


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_APPLYREPORTTYPE')
CREATE TABLE T_FPM_APPLYREPORTTYPE (
                                       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_FPM_APPLYCURRENCY')
CREATE TABLE T_FPM_APPLYCURRENCY (
                                     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_FPM_APPLYOPTIONALDIM')
CREATE TABLE T_FPM_APPLYOPTIONALDIM (
                                        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_FPM_APPLYOPTIONALDIM1')
CREATE TABLE T_FPM_APPLYOPTIONALDIM1 (
                                         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_FPM_APPLYOPTIONALDIM2')
CREATE TABLE T_FPM_APPLYOPTIONALDIM2 (
                                         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_FPM_SUBJECTCANCELCONFIG')
CREATE TABLE T_FPM_SUBJECTCANCELCONFIG (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FRULENAME VARCHAR(50) DEFAULT ' ' NOT NULL,
                                           FINCONFIG VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                           FINSUBJECTCONFIGREAL VARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FINSUBJECTCONFIGREAL_TAG NCLOB,
                                           FOUTCONFIG VARCHAR(1024) DEFAULT ' ' NOT NULL,
                                           FOUTCONFIGREAL VARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FOUTCONFIGREAL_TAG NCLOB
);


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