• Post Reply Bookmark Topic Watch Topic
  • New Topic

int return on executeUpdate

 
Adam Sykes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a stored procedure on an oracle database to insert one row. I am expecting a result of 1 to return but am getting 0. I thought if there was an error I would get either -1 or if a serious error then an SQLException? Can anyone offer an explanation!
 
Abdul Samed
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Adam,
The method executeUpdate returns
0 if no rows are updated
1 if one row is inserted
n if n rows are updated
So if it returns 0 then it means that there is some error in your insert statement
Regards
Abdul
 
Adam Sykes
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, but if I have an error in the insert shouldn't I also be expecting to catch an SQLException in a try/catch block around the executeUpdate?
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depends on what exactly the stored procedure is doing.
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!