MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Minimize locking

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database
View previous topic :: View next topic  
Author Message
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Fri Mar 26, 2010 11:31 am    Post subject: Minimize locking Reply with quote

In the SQL table, I have 10 departments. In my program, I extract data from 3 join tables for all departments via a single SQL query, process each row then update one of the table (e.g. Time stamp and status). On the other hand, I can loop throught each department and issue 10 SQL query 10 times (i.e. with WHERE DEPT = :DEPT). Will the second approach minimize the chance of locking?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Fri Mar 26, 2010 12:32 pm    Post subject: Reply with quote

danm,

I would prefer the cursor JOIN on 2 tables(non update tables) and update table 3 with your join condition on where clause accordingly.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
danm
Intermediate


Joined: 29 Jun 2004
Posts: 170
Topics: 73

PostPosted: Tue Mar 30, 2010 8:35 am    Post subject: Reply with quote

Kolusu,

I do need to join the 3rd table because I need columns from all 3 tables to determine if the 3rd table need to be updated.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12375
Topics: 75
Location: San Jose

PostPosted: Tue Mar 30, 2010 10:09 am    Post subject: Reply with quote

danm,

Exactly my point. You can join the 2 tables and try updating the 3rd with the join keys. If found then you would update or else you would get a sqlcode of 100 and you would process the next. So you are not holding up any tables for a longer period of time.

Kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Database All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group