DELIMITER $$ CREATE OR REPLACE DEFINER=`dbadmin`@`%` PROCEDURE `FAR_STAGE_BP_IMPACT`() BEGIN UPDATE FAR_BREAKS_STAGE cod INNER JOIN FAR_IBOR_BP_IMPACT_DATA tna ON (cod.FUND_SYMBOL = tna.ACCT_CD_FMRID) SET cod.IBOR_TOTAL_NET_ASSETS_USD = tna.MKT_VAL_USD, cod.BREAK_BP_IMPACT = CASE WHEN IFNULL(cod.IBOR_TOTAL_NET_ASSETS_USD,0) = 0 THEN 0 WHEN cod.DEBIT_CREDIT = 'Debit' THEN CAST(IFNULL(((cod.USD_EQ_Amount / cod.IBOR_TOTAL_NET_ASSETS_USD) * -10000), 0) AS DOUBLE(10, 4)) ELSE CAST(IFNULL(((cod.USD_EQ_Amount / cod.IBOR_TOTAL_NET_ASSETS_USD) * 10000), 0) AS DOUBLE(10, 4)) END WHERE tna.ACCT_CD_FMRID IS NOT NULL and cod.REC_TYPE = 'IBOR'; UPDATE FAR_BREAKS_STAGE cod INNER JOIN FAR_ABOR_BP_IMPACT_DATA tna ON (cod.FUND_NUMBER = tna.ACCOUNT_NUMBER_IO) SET cod.ABOR_TOTAL_NET_ASSETS_USD = tna.TOTAL_NET_ASSETS_USD, cod.BREAK_BP_IMPACT = CASE WHEN IFNULL(cod.ABOR_TOTAL_NET_ASSETS_USD,0) = 0 THEN 0 WHEN cod.DEBIT_CREDIT = 'Debit' THEN CAST(IFNULL(((cod.USD_EQ_Amount / cod.ABOR_TOTAL_NET_ASSETS_USD) * -10000), 0) AS DOUBLE(10, 4)) ELSE CAST(IFNULL(((cod.USD_EQ_Amount / cod.ABOR_TOTAL_NET_ASSETS_USD) * 10000), 0) AS DOUBLE(10, 4)) END WHERE tna.ACCOUNT_NUMBER_IO IS NOT NULL and cod.REC_TYPE = 'ABOR'; UPDATE FAR_BREAKS_STAGE bs SET bs.FUND_BP_IMPACT = CASE WHEN bs.REC_TYPE= 'IBOR' THEN fn_get_sum(bs.FUND_SYMBOL, 'IBOR') ELSE fn_get_sum(bs.FUND_SYMBOL, 'ABOR') END; END$$ DELIMITER ;
This stored procedure which is updating same table thrice with joins with other table is not running properly. sometimes it is only updating ABOR data and sometimes it is updating only IBOR data. sometimes it update FUND_IMPACT column, other times don't execute it at all. Please suggest why it is behaving like that. Timeout is set as 600 ms.
Discussion posts and replies are publicly visible
hi Swati Sharda my thought would be Null or Missing Join Conditions could result in updates being skipped if there are no matching records in the joined tables. Ensure that the join conditions are correct and that the joined tables have the expected data. You can also temporarily replace the INNER JOIN with a LEFT JOIN to see if any rows are being filtered out due to missing matches.
INNER JOIN
LEFT JOIN