/**Begin D:\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPL_METRIC' AND KSQL_COL_NAME IN ('FNEWMETRICTYPE'))
ALTER TABLE T_FPM_TPL_METRIC ADD (FNEWMETRICTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPL_REPORTTYPEENTRY' AND KSQL_COL_NAME IN ('FCONSULTSEAT'))
ALTER TABLE T_FPM_TPL_REPORTTYPEENTRY ADD (FCONSULTSEAT VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPL_REPORTTYPEENTRY' AND KSQL_COL_NAME IN ('FROLLCONTAINDETAIL'))
ALTER TABLE T_FPM_TPL_REPORTTYPEENTRY ADD (FROLLCONTAINDETAIL CHAR(1) DEFAULT '1' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPLBAK_METRIC' AND KSQL_COL_NAME IN ('FNEWMETRICTYPE'))
ALTER TABLE T_FPM_TPLBAK_METRIC ADD (FNEWMETRICTYPE BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPLBAK_RETYPEENTRY' AND KSQL_COL_NAME IN ('FCONSULTSEAT'))
ALTER TABLE T_FPM_TPLBAK_RETYPEENTRY ADD (FCONSULTSEAT VARCHAR(50) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TPLBAK_RETYPEENTRY' AND KSQL_COL_NAME IN ('FROLLCONTAINDETAIL'))
ALTER TABLE T_FPM_TPLBAK_RETYPEENTRY ADD (FROLLCONTAINDETAIL CHAR(1) DEFAULT '1' NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_REMARKFIELD')
CREATE TABLE T_FPM_REMARKFIELD (
                                   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_REMARKFIELDBAK')
CREATE TABLE T_FPM_REMARKFIELDBAK (
                                      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_NEWREFERENCEPOSBAK')
CREATE TABLE T_FPM_NEWREFERENCEPOSBAK (
                                          FPKID BIGINT DEFAULT 0 NOT NULL,
                                          FENTRYID BIGINT DEFAULT 0 NOT NULL,
                                          FBASEDATAID BIGINT DEFAULT 0 NOT NULL
);


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


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


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



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