Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 Lock in exclusive mode

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 Lock in exclusive mode
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: 6968
Location: porcelain throne

PostPosted: Thu Dec 09, 2010 8:32 pm    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts What is the command to check MODE of ... rohanthengal CLIST & REXX 7 Fri Nov 18, 2016 1:48 pm
No new posts Calling macro via rexx in batch mode. SanaR CLIST & REXX 15 Tue Mar 08, 2016 4:46 pm
No new posts Edit not allowing in dataset after Po... krsenthil85 TSO/ISPF 8 Mon Jul 13, 2015 10:27 pm
No new posts How to put exclusive lock on a file i... sudarshan.srivathsav JCL & VSAM 4 Fri Jun 05, 2015 10:36 pm
No new posts VSAM share mode ashim prodhan JCL & VSAM 7 Wed Jun 03, 2015 7:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us