Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: executeUpdate always return 0
alonk_at_xor.co.il (Alon) wrote in message news:<ca2e4373.0208270611.4b3b79cd_at_posting.google.com>...
> hi ,
> i am running a simple stored procedure on oracle 8.1.7 from a java
> application,
> the update of the db works fine but the executeQuery() always return 0
> even if it updated a column.
> My java code is :
> String stmt = (
> "{call STP_UPDATE_MERCHANT_TERMINAL(?,?,?,?,?,?,?,?,?,?,?,?,?)}"
> );
>
> CallableStatement cs = this.m_oConn.prepareCall(stmt);
>
> cs.setString(1, xmlFormObj.getValueByName("xxxx"));
> cs.setString(2, xmlFormObj.getValueByName("yyyy"));
> cs.setInt (3, xmlFormObj.getIntValue("xxxx"));
> cs.setString(4, xmlFormObj.getValueByName("yyyy"));
> cs.setInt (5, xmlFormObj.getIntValue("ttttt"));
> cs.setString(6, xmlFormObj.getValueByName("uuuuu"));
> cs.setString(7, xmlFormObj.getValueByName("jjjjjj"));
> cs.setString(8, xmlFormObj.getValueByName("fffff"));
> cs.setString(9, xmlFormObj.getValueByName("sssss"));
> cs.setString(10,xmlFormObj.getValueByName("vvvvv"));
> cs.setString(11,xmlFormObj.getValueByName("mmmmm"));
> cs.setString(12,xmlFormObj.getValueByName("kkkkk"));
> cs.setString(13,xmlFormObj.getValueByName("bbbbb"));
>
> int nResult = cs.executeUpdate();
> System.out.println("Result : " + nResult );
> cs.close();
>
> does any one have any ideas ,
> Thanks in advanced
> Alon
Alon, I am not a JAVA coder but your code looks like it is executing an Oracle procedure call and the return code will always be 0 or an Oracle error number. If you want an updated row count you would need to add an out variable to the procedure and have the procedure put the number of rows updated into this variable.
I could be wrong being this is JAVA but that is what this looks like to me.