• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Update resturns zero rows updated without throwing errors.

 
ajay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In one of our application code, we are performing executeUpdate on a prepared statement object. This is done in a loop on a large number of records, say 20000.
On some occasions, the update fails to update the table with relevant information and returns without throwing any errors.

We need to know the reason why it is not updating the table even though the query is right?

Also, under what conditions does the update return zero rows ?

Steps taken :

1. Create and populate the preapred statement with values.

2. Lock the particular row for update.

3. executeUpdate on this prepared statement object.

4. release the lock.
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
austraind,
You asked:

under what conditions does the update return zero rows ?

When no rows satisfy the "WHERE" clause of your UPDATE statement, for example:

If there is no employee named "Paris Hilton" in your EMP table, the above statement will update 0 (zero) rows and will not throw any errors.

Good Luck,
Avi.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65335
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"austraind",

There aren't may rules that you need to worry about here on the Ranch, but one that we take very seriously regards the use of proper names. Please take a look at the JavaRanch Naming Policy and adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Thanks!
bear
Forum Bartender
 
ajay
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks avi,But all the conditions are satisfied. The where clause is right and i have the matching parameters in the DB. Still it fails consistently.

This is a serious issue for us, since it is affecting the performance of our code badly.

Anyone out there who has faced such an issue before ?
 
Shailesh Chandra
Ranch Hand
Posts: 1082
Java Oracle Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
might be there is something wrong in your query and your query is failing....put your code here

Shailesh
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"ajay",

Please read Bear's post more closely:
In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Please fix your display name soon, accounts with invalid display names get deleted, often without warning.

Dave
 
Avi Abrami
Ranch Hand
Posts: 1141
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ajay (or Austraind?),
You said:

The where clause is right and ... Still it fails consistently.

Well then something is wrong, so post your code (like Shailesh suggested) so that we can debug it for you.

By the way, I am currently looking for new employment -- since my current position is only temporary. Perhaps if I solve your problem for you, your employer would consider employing me (instead of you)? Just kidding

Good Luck,
Avi.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic