/**Begin D:\PDM_UPGRADE\PDM1\IFM_table.sql **/
/** EXEC p_AlterColumn 'T_IFM_TRANSHANDLE_E', 'FVOUCHERNUM', 'NVARCHAR(100)', 'NOT NULL', '0011', ''' '''; **/

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INNERACCT' AND KSQL_COL_NAME IN ('FENDPREINSTDATE'))
 ALTER TABLE T_IFM_INNERACCT ADD (FENDPREINSTDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FBEGINDATE'))
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FBEGINDATE DATETIME );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FISINTEREST'))
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FISINTEREST CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FBIZTYPE'))
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FBIZTYPE NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_CURRENTINTBILL' AND KSQL_COL_NAME IN ('FISREVERSE'))
 ALTER TABLE T_IFM_CURRENTINTBILL ADD (FISREVERSE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH' AND KSQL_COL_NAME IN ('FOPERATETYPE'))
 ALTER TABLE T_IFM_INTBILL_BATCH ADD (FOPERATETYPE NVARCHAR(30) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FSUMPREINT'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FSUMPREINT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FNOTPREINT'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FNOTPREINT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FREVERSEINTAMT'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FREVERSEINTAMT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FISREVERSE'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FISREVERSE CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FREVERSENUM'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FREVERSENUM NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FISINTEREST'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FISINTEREST CHAR(1) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FINTSETNUM'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FINTSETNUM NVARCHAR(80) DEFAULT ' ' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FSOURCEENTRYID'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FSOURCEENTRYID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FINTSETTLEID'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FINTSETTLEID BIGINT DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH' AND KSQL_COL_NAME IN ('FISSETTLEADD'))
 ALTER TABLE T_IFM_INTBILL_BATCH ADD (FISSETTLEADD CHAR(1) DEFAULT '0' NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_IFM_INTBILL_BATCH_INT' AND KSQL_COL_NAME IN ('FACTUALINSTAMT'))
 ALTER TABLE T_IFM_INTBILL_BATCH_INT ADD (FACTUALINSTAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_CFM_PREINTERESTBILL' AND KSQL_COL_NAME ='FSETTLECENTERID')
 ALTER TABLE T_CFM_PREINTERESTBILL ADD (FSETTLECENTERID BIGINT DEFAULT 0 NOT NULL );

IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_IFM_INTCALCWAYSETTING')
 CREATE TABLE T_IFM_INTCALCWAYSETTING (
FID BIGINT DEFAULT 0 NOT NULL,
FINTCACLWAY CHAR(30) DEFAULT ' ' NOT NULL
);


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