PreparedStatement updatestmt1 = con.prepareStatement("update BASE_TX set tx_vl=replace(tx_vl,?,?)");
updatestmt1.setString( 1, "${parm:"+ stringToreplace.trim() +"}" );
updatestmt1.setString( 2, "${parm:" + replacedString.trim() + "}" );
int ifUpdated1 = updatestmt1.executeUpdate();
The ifUpdated1 is returning 14480 rather than number of affected rows which are none in the case that im running. So I'm not able to make a call if they r actually updated or not.
That's the correct behavior. Since you don't set the WHERE
, all rows are affected. The fact that your replace is an identity is not relevant to DB. If you really want to get affected rows, use where
like that:
"update BASE_TX set tx_vl=replace(tx_vl,?,?) where tx_vl != replace(tx_vl,?,?)"
Note that it will slow your query, but reduce IO, which actually may be better in your case.