/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_EXECUTEPLAN_E' AND KSQL_COL_NAME IN ('FREQUESTID'))
ALTER TABLE T_FPM_EXECUTEPLAN_E ADD (FREQUESTID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CONTROLUPDATEINFO')
CREATE TABLE T_FPM_CONTROLUPDATEINFO (
                                         FID BIGINT DEFAULT 0 NOT NULL,
                                         FBILLNO NVARCHAR(50) DEFAULT ' ' NOT NULL,
                                         FBILLSTATUS NVARCHAR(50) 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,
                                         FCREATETIME DATETIME,
                                         FCONTROLSTATUS NVARCHAR(30) DEFAULT ' ' NOT NULL,
                                         FBODYSYSID BIGINT DEFAULT 0 NOT NULL,
                                         FEXECUTEOP NVARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CONTROLUPDATEDETAIL')
CREATE TABLE T_FPM_CONTROLUPDATEDETAIL (
                                           FID BIGINT DEFAULT 0 NOT NULL,
                                           FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                           FSEQ INT DEFAULT 0 NOT NULL,
                                           FREPORTDATAID BIGINT DEFAULT 0 NOT NULL,
                                           FREPORTID BIGINT DEFAULT 0 NOT NULL,
                                           FLOCKEXECUTEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
                                           FFACTEXECUTEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_CONTROLTRACEINFO')
CREATE TABLE T_FPM_CONTROLTRACEINFO (
                                        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,
                                        FCREATETIME DATETIME,
                                        FBUSINESSBILLID BIGINT DEFAULT 0 NOT NULL,
                                        FCONTROLTRACEID BIGINT DEFAULT 0 NOT NULL,
                                        FENTITYTYPE NVARCHAR(100) DEFAULT ' ' NOT NULL
);



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