/**Begin D:\softwaresetup\PDM_UPGRADE\PDM1\FPM_table.sql **/
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEINFO' AND KSQL_COL_NAME IN ('FSMARTGETVALSET')) 
 ALTER TABLE T_FPM_TEMPLATEINFO ADD (FSMARTGETVALSET VARCHAR(50) DEFAULT 'fillplanamt' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_TEMPLATEINFO_BAK' AND KSQL_COL_NAME IN ('FSMARTGETVALSET')) 
 ALTER TABLE T_FPM_TEMPLATEINFO_BAK ADD (FSMARTGETVALSET VARCHAR(50) DEFAULT 'fillplanamt' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TPL_REPORTTYPEENTRY') 
 CREATE TABLE T_FPM_TPL_REPORTTYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FREPORTTYPE BIGINT DEFAULT 0 NOT NULL,
FREFRENCEORG BIGINT DEFAULT 0 NOT NULL,
FPERIODNUM INT DEFAULT 0 NOT NULL,
FREFRENCEPOSITION VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TPL_METRIC') 
 CREATE TABLE T_FPM_TPL_METRIC (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMETRICTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FPRESET CHAR(1) DEFAULT '0' NOT NULL,
FRETURNVAL CHAR(1) DEFAULT '0' NOT NULL,
FBIZFILED VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TPLBAK_RETYPEENTRY') 
 CREATE TABLE T_FPM_TPLBAK_RETYPEENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FREPORTTYPE BIGINT DEFAULT 0 NOT NULL,
FREFRENCEORG BIGINT DEFAULT 0 NOT NULL,
FPERIODNUM INT DEFAULT 0 NOT NULL,
FREFRENCEPOSITION VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_FPM_TPLBAK_METRIC') 
 CREATE TABLE T_FPM_TPLBAK_METRIC (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ BIGINT DEFAULT 0 NOT NULL,
FMETRICTYPE VARCHAR(50) DEFAULT ' ' NOT NULL,
FPRESET CHAR(1) DEFAULT '0' NOT NULL,
FRETURNVAL CHAR(1) DEFAULT '0' NOT NULL,
FBIZFILED VARCHAR(50) DEFAULT ' ' NOT NULL
);


IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_REPORTDATAMAIN' AND KSQL_COL_NAME IN ('FPLANREFERENCEAMT')) 
 ALTER TABLE T_FPM_REPORTDATAMAIN ADD (FPLANREFERENCEAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_FPM_REPORT' AND KSQL_COL_NAME IN ('FREFERENCEPERIOD')) 
 ALTER TABLE T_FPM_REPORT ADD (FREFERENCEPERIOD BIGINT DEFAULT 0 NOT NULL );

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