IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 Lock in exclusive mode


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sudip_mitra

New User


Joined: 05 Apr 2006
Posts: 5
Location: India

PostPosted: Thu Dec 09, 2010 7:11 pm
Reply with quote

Hi,

My requirement to hold a lock in table till last step in a JCL -
Step1, I need to lock a table.
Step2, some functionality exist on that table
Step3, other functionality based on updated table
Step4, I need to release the lock.

For locking I can use Exclusive LOCK comand but after program terminate it automatically release the lock due to RELEASE(COMMIT) in bind card.

Please sugest how can I hold lock in a table throughout a job.

Thanks,
Sudip Mitra
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Dec 09, 2010 8:32 pm
Reply with quote

DB2 does not recognize a JOB as a task.

so, you are going to have to use the scheduler (Jobs-started tasks) as a means of prohibiting access to the table.
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1281
Location: Belgium

PostPosted: Fri Dec 10, 2010 2:39 pm
Reply with quote

you might want to take a look at clone tables.

suppose : Table TB1 in database.Tablespace DB1,TS1

Preparation (one Time):
1) create a clone : ALTER TABLE TB1 ADD CLONE TB1_FOR_BATCH
you can leave it empty.
(your exclusibe batchprocess will have to SELECT/UPDATE/INSERT TB1_FOR_BATCH)
2) Make the clone unavailable : -STOP DATABASE(db1) SPACENAM(ts1) CLONE

now you have TB1 up and running and TB1_FOR_BATCH unavailable.

batch process :
1) EXCHANGE DATA FOR TABLE TB1 and TB1_FOR_BATCH
=> TB1 is unavailable (sort of an exclusive lock) and TB1_FOR_BATCH is available
2) run the programs against TB1_FOR_BATCH
3) EXCHANGE DATA FOR TABLE TB1 and TB1_FOR_BATCH
=> TB1 is back available for normal processing and TB1_FOR_BATCH is unavailable
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts HILITE on Browse mode? TSO/ISPF 2
No new posts Calling Java method from batch COBOL ... COBOL Programming 5
No new posts Lock Escalation DB2 3
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts Difference when accessing dataset in ... JCL & VSAM 7
Search our Forums:

Back to Top