/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_BODYSYSMANAGE' AND KSQL_COL_NAME IN ('FSHREKSYNCSTATUS'))
ALTER TABLE T_FPM_BODYSYSMANAGE ADD (FSHREKSYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_BODYSYSMANAGE' AND KSQL_COL_NAME IN ('FSHREKDATAKEY'))
ALTER TABLE T_FPM_BODYSYSMANAGE ADD (FSHREKDATAKEY NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_DIMADD' AND KSQL_COL_NAME IN ('FSHREKSYNCSTATUS'))
ALTER TABLE T_FPM_DIMADD ADD (FSHREKSYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_DIMADD' AND KSQL_COL_NAME IN ('FSHREKDATAKEY'))
ALTER TABLE T_FPM_DIMADD ADD (FSHREKDATAKEY NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_MEMBER' AND KSQL_COL_NAME IN ('FSHREKSYNCSTATUS'))
ALTER TABLE T_FPM_MEMBER ADD (FSHREKSYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_MEMBER' AND KSQL_COL_NAME IN ('FSHREKDATAKEY'))
ALTER TABLE T_FPM_MEMBER ADD (FSHREKDATAKEY NVARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_CURRENCY_BAK')
CREATE TABLE T_FPM_REPORT_CURRENCY_BAK (
                                           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_REPORT_BAK_L')
CREATE TABLE T_FPM_REPORT_BAK_L (
                                    FPKID VARCHAR(18) DEFAULT ' ' NOT NULL,
                                    FID BIGINT DEFAULT 0 NOT NULL,
                                    FLOCALEID VARCHAR(10) DEFAULT ' ' NOT NULL,
                                    FDESCRIPTION VARCHAR(255) DEFAULT ' ' NOT NULL,
                                    FNAME VARCHAR(255) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORTDATAMAIN_BAK')
CREATE TABLE T_FPM_REPORTDATAMAIN_BAK (
                                          FID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FSEQ INT DEFAULT 0 NOT NULL,
                                          FSYSTEMID BIGINT DEFAULT 0 NOT NULL,
                                          FORGMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FCURRENCYMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FPERIODMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FSUBJECTMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FCOMPANYMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FSETTLETYPEMEMID BIGINT DEFAULT 0 NOT NULL,
                                          FEXTMEM1ID BIGINT DEFAULT 0 NOT NULL,
                                          FEXTMEM2ID BIGINT DEFAULT 0 NOT NULL,
                                          FEXTMEM3ID BIGINT DEFAULT 0 NOT NULL,
                                          FPLANAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FLOCKAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FREALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FVERSION INT DEFAULT 0 NOT NULL,
                                          FORIGINDATAROW INT DEFAULT 0 NOT NULL,
                                          FORIGINDATACOL INT DEFAULT 0 NOT NULL,
                                          FEFFECTFLAG CHAR(1) DEFAULT '0' NOT NULL,
                                          FREPORTPERIOD BIGINT DEFAULT 0 NOT NULL,
                                          FMAINTABLE CHAR(1) DEFAULT '0' NOT NULL,
                                          FAMOUNTUNIT VARCHAR(50) DEFAULT ' ' NOT NULL,
                                          FORGPLANAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FPLANREFERENCEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FREPORTPLANAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FSOURCEID VARCHAR(255) DEFAULT ' ' NOT NULL,
                                          FSOURCEID_TAG NCLOB,
                                          FOFFSETAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FHOLDLOCKAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                          FHOLDREALAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORTDATADETAILBAK')
CREATE TABLE T_FPM_REPORTDATADETAILBAK (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FMAINDIMDATAID BIGINT DEFAULT 0 NOT NULL,
                                           FOPUSERTYPE NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                           FOPUSERID BIGINT DEFAULT 0 NOT NULL,
                                           FBANKCATEID BIGINT DEFAULT 0 NOT NULL,
                                           FCONTRACTNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FCONTRACTNAME NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FPLANDATE DATETIME,
                                           FBANKACCOUNTID BIGINT DEFAULT 0 NOT NULL,
                                           FDETAILEXT1 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FDETAILEXT5 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FDETAILEXT3 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FDETAILEXT2 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FDETAILEXT4 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FDETAILEXT6 NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                           FREMARK NVARCHAR(500) DEFAULT ' ' NOT NULL,
                                           FBUSINESSPARTNER BIGINT DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_SUMRECORDBAK')
CREATE TABLE T_FPM_REPORT_SUMRECORDBAK (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FSUMORGREPORTID BIGINT DEFAULT 0 NOT NULL,
                                           FSUMSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_AUXILIARYBAK')
CREATE TABLE T_FPM_REPORT_AUXILIARYBAK (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FREPORTDATAID BIGINT DEFAULT 0 NOT NULL,
                                           FBDTYPE BIGINT DEFAULT 0 NOT NULL,
                                           FCONTENT NVARCHAR(250) DEFAULT ' ' NOT NULL
);


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


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_PERIOD_BAK')
CREATE TABLE T_FPM_REPORT_PERIOD_BAK (
                                         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_OLAPSYNCLOG')
CREATE TABLE T_FPM_OLAPSYNCLOG (
                                   FID BIGINT DEFAULT 0 NOT NULL,
                                   FNUMBER NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                   FNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                   FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                   FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                   FENABLE NVARCHAR(50) 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,
                                   FSYNCTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FENTITYID BIGINT DEFAULT 0 NOT NULL,
                                   FENTITYNAME NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                   FSYNCSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                   FBODYSYSTEMID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REPORT_BAK')
CREATE TABLE T_FPM_REPORT_BAK (
                                  FID BIGINT DEFAULT 0 NOT NULL,
                                  FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FBILLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                  FCREATORID BIGINT DEFAULT 0 NOT NULL,
                                  FMODIFIERID BIGINT DEFAULT 0 NOT NULL,
                                  FAUDITORID BIGINT DEFAULT 0 NOT NULL,
                                  FAUDITDATE DATETIME,
                                  FMODIFYTIME DATETIME,
                                  FBIZDATE DATETIME,
                                  FCREATETIME DATETIME,
                                  FSOURCEBILLID BIGINT DEFAULT 0 NOT NULL,
                                  FDESCRIPTION NVARCHAR(255) DEFAULT ' ' NOT NULL,
                                  FCOMPANYID BIGINT DEFAULT 0 NOT NULL,
                                  FBODYSYS BIGINT DEFAULT 0 NOT NULL,
                                  FNAME NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FDECLARESTARTDATE DATETIME,
                                  FDECLAREDEADLINE DATETIME,
                                  FPLANSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                  FCURRPROCESSOR BIGINT DEFAULT 0 NOT NULL,
                                  FREPORTPERIOD BIGINT DEFAULT 0 NOT NULL,
                                  FREPORTORG BIGINT DEFAULT 0 NOT NULL,
                                  FTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
                                  FTEMPLATEBAKID BIGINT DEFAULT 0 NOT NULL,
                                  FEXRATETABLE BIGINT DEFAULT 0 NOT NULL,
                                  FEXCHANGERATEDATE DATETIME,
                                  FROLLNUM INT DEFAULT 0 NOT NULL,
                                  FINITFLAG CHAR(1) DEFAULT '0' NOT NULL,
                                  FPARENTTEMPLATEID BIGINT DEFAULT 0 NOT NULL,
                                  FATTACHINFO BIGINT DEFAULT 0 NOT NULL,
                                  FINFORMANT BIGINT DEFAULT 0 NOT NULL,
                                  FCHANGESTATUS NVARCHAR(50) DEFAULT 'unchange' NOT NULL,
                                  FREFERENCEPERIOD BIGINT DEFAULT 0 NOT NULL,
                                  FRETURNCOMMENTS NVARCHAR(100) DEFAULT ' ' NOT NULL,
                                  FREPORTPLANTYPE NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FISINNEROFFSET CHAR(1) DEFAULT '0' NOT NULL,
                                  FENABLE CHAR(1) DEFAULT '1' NOT NULL,
                                  FSTATUS NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                  FMASTERID BIGINT DEFAULT 0 NOT NULL,
                                  FISEXECBIASANALYS CHAR(1) DEFAULT '0' NOT NULL
);



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