IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTENTRY' AND KSQL_COL_NAME ='FORIRECAMOUNT') 
 ALTER TABLE T_ER_REPAYMENTENTRY ADD (FORIRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTENTRY' AND KSQL_COL_NAME ='FRECAMOUNT') 
 ALTER TABLE T_ER_REPAYMENTENTRY ADD (FRECAMOUNT DECIMAL(23,10) DEFAULT 0 NOT NULL );
 
IF NOT EXISTS (SELECT 1 FROM KSQL_USERTABLES WHERE KSQL_TABNAME = 'T_ER_REPAYRECENTRY') 
 CREATE TABLE T_ER_REPAYRECENTRY (
FID BIGINT DEFAULT 0 NOT NULL,
FENTRYID BIGINT DEFAULT 0 NOT NULL,
FSEQ INT DEFAULT 0 NOT NULL,
FRECBILLNO NVARCHAR(255) DEFAULT ' ' NOT NULL,
FPAYEEDATE DATETIME,
FRECEIVINGTYPE BIGINT DEFAULT 0 NOT NULL,
FPAYEEBANK BIGINT DEFAULT 0 NOT NULL,
FACCOUNTBANK BIGINT DEFAULT 0 NOT NULL,
FRECCURRENCY BIGINT DEFAULT 0 NOT NULL,
FRECEXCHANGERATE DECIMAL(23,10) DEFAULT 0 NOT NULL,
FORIACTRECAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FACTRECAMT DECIMAL(23,10) DEFAULT 0 NOT NULL,
FRECBILLID BIGINT DEFAULT 0 NOT NULL
);

IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTBILL' AND KSQL_COL_NAME ='FTOTALORIRECAMOUNT') 
 ALTER TABLE T_ER_REPAYMENTBILL ADD (FTOTALORIRECAMOUNT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTBILL' AND KSQL_COL_NAME ='FTOTALACTRECAMT') 
 ALTER TABLE T_ER_REPAYMENTBILL ADD (FTOTALACTRECAMT DECIMAL(19,6) DEFAULT 0 NOT NULL );
IF NOT EXISTS (SELECT 1 FROM KSQL_USERCOLUMNS WHERE KSQL_COL_TABNAME = 'T_ER_REPAYMENTBILL' AND KSQL_COL_NAME ='FBUILDRELATIONWAY') 
 ALTER TABLE T_ER_REPAYMENTBILL ADD (FBUILDRELATIONWAY CHAR(1) DEFAULT ' ' NOT NULL );

 
 

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_REPAYRECENTRY_FRECID') CREATE INDEX IDX_ER_REPAYRECENTRY_FRECID ON T_ER_REPAYRECENTRY ( FRECBILLID );

 IF NOT EXISTS (SELECT 1 FROM KSQL_INDEXES WHERE KSQL_INDNAME = 'IDX_ER_REPAYRECENTRY_FSEQ') CREATE INDEX IDX_ER_REPAYRECENTRY_FSEQ ON T_ER_REPAYRECENTRY ( FENTRYID ,FSEQ );


