View previous topic :: View next topic
|
Author |
Message |
Gopal Tripathi
New User
Joined: 16 Sep 2009 Posts: 15 Location: Hyd,Ind
|
|
|
|
Two process are trying to update the below query simultaeneously-
Update table name set col=col + 1;
The table is getting updated only once while the count should increase by two,
Can somebody please suggest if it is possible to update the table and how. |
|
Back to top |
|
|
Escapa
Senior Member
Joined: 16 Feb 2007 Posts: 1399 Location: IL, USA
|
|
|
|
Quote: |
The table is getting updated only once while the count should increase by two,
Can somebody please suggest if it is possible to update the table and how.
|
Thats silly.. Why you want to do so..
If you state your original requirement (not how to do way you want) .. folks here might help in better way... |
|
Back to top |
|
|
Gopal Tripathi
New User
Joined: 16 Sep 2009 Posts: 15 Location: Hyd,Ind
|
|
|
|
Actually , there is one more table and whenever a row is inserted into that table , one count is incremented in this table.what happening here is that two processes are inserting two rows and the count what is getting updated is only 1.My requirement is there a way so that when the two processes inserts two rows the count should increment by two here and not one. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
Quote: |
Two process are trying to update the below query simultaeneously- |
One of three possibilties comes to mind: (1) you have not stated what you're trying to do well, (2) you have no idea what record locking is and why it is used, or (3) you are insane.
Google is your friend. Googling database record locking returns 55,000,000 hits and on the very first page is a reference that contains this excellent quote:
Quote: |
Record locking is the technique of preventing simultaneous access to data in a database, to prevent inconsistent results. |
If you truly want to update a database value twice at the same time you have many, many, many problems. Hopefully you merely have not stated your requirement well. |
|
Back to top |
|
|
Peter Nancollis
New User
Joined: 15 Mar 2011 Posts: 47 Location: UK
|
|
|
|
Ahhh Google the new application programmer , the new DBA ....
but to matters in hand
"The table is getting updated only once while the count should increase by two,
Can somebody please suggest if it is possible to update the table and how.
"
DB2 will allow multiple updates to multiple columns in multiple tables ... all at the same time ....IF it can guarentee the integrity of the data
If you application [tables/code ] are correct this will happen ... if not it wont !
DB2 will tell you which bit hasnt worked ! |
|
Back to top |
|
|
anshul_gugnani
New User
Joined: 02 Nov 2009 Posts: 73 Location: Mumbai
|
|
|
|
This might be happening because your row is not getting locked once the program has accessed it. check your isloation level, if its CS, change it to RR. but do remember to commit frquently when you use RR to avoid -911 in the other simultaneous running program. |
|
Back to top |
|
|
|