View previous topic :: View next topic
|
Author |
Message |
sudip_mitra
New User
Joined: 05 Apr 2006 Posts: 5 Location: India
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
GuyC
Senior Member
Joined: 11 Aug 2009 Posts: 1281 Location: Belgium
|
|
|
|
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 |
|
|
|