If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > lock promotion in db2

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-20-07, 15:54
poorviparikh poorviparikh is offline
Registered User
 
Join Date: Jul 2005
Posts: 12
lock promotion in db2

hi,
This is what im trying to do. Need to archive data from daily table to archive table. While I do the export from the base table and successfully import data into the archive table I want to ensure that no new records are added to the base table. Also upon successfully import i need to truncate the base table.
In order to see that the lock promotion work correctly, wrote a sample test script.

db2 connect to mydb;

db2 lock table test.daily in share mode;

db2 "import from /dev/null of del replace into test.daily";

db2 connect reset;

From what I assumed, the command "db2 import from /dev/null..." should be locked out. However since autocommit is on it doesnt work.
I tried to add : db2 "update command options using c off"; it doesnt work.

Any ideas anybody??

Thank you in advance.

Best,
Poorvi
Reply With Quote
  #2 (permalink)  
Old 11-20-07, 17:06
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You cannot lock yourself out. If you put a lock on something, you own it, so you get to continue playing.

If you want to prevent others from accessing the table you should lock in EXCLUSIVE MODE.

You should use LOAD instead of IMPORT to truncate the table. Less overhead involved.

And yes, you need to turn auto-commit off to get this to work.

Andy
Reply With Quote
  #3 (permalink)  
Old 11-20-07, 18:13
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Put this in a SQL script and run it with "db2 -f -c- <script>". The "-c-" (or "+c") option turns auto-commit off.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On