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
 

 

Locks applied on tables in an update statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
krish_mrt

New User


Joined: 15 Apr 2005
Posts: 12
Location: Chennai

PostPosted: Thu May 25, 2006 2:31 pm    Post subject: Locks applied on tables in an update statement
Reply with quote

Code:
UPDATE TAB1
SET COL1 = (SELECT   TAB2.COL1
   FROM   TAB2
   WHERE   TAB2.COL2 = 'XX');

In the code above, I would like to know the kind of locks applied on the tables TAB1 and TAB2.
And... I would also like to know what would be the effect on the update statement on specifying the clause- "WITH UR"
in the update statement as ...


Code:
UPDATE TAB1
SET COL1 = (   SELECT   TAB2.COL1
      FROM   TAB2
      WHERE   TAB2.COL2 = 'XX')
WITH UR;
Back to top
View user's profile Send private message

Gurmeet

New User


Joined: 22 Feb 2006
Posts: 46
Location: Pune

PostPosted: Thu May 25, 2006 8:27 pm    Post subject: Re: Locks applied on tables in an update statement
Reply with quote

[quote=
And... I would also like to know what would be the effect on the update statement on specifying the clause- "WITH UR"
in the update statement as ...


Code:
UPDATE TAB1
SET COL1 = (   SELECT   TAB2.COL1
      FROM   TAB2
      WHERE   TAB2.COL2 = 'XX')
WITH UR;
[/quote]

WITH UR is not allowed with a update clause...
Back to top
View user's profile Send private message
die7nadal

Active User


Joined: 23 Mar 2005
Posts: 156

PostPosted: Thu May 25, 2006 11:07 pm    Post subject:
Reply with quote

I am answering this from the top of my head. Generally locks are defined when they define a Table space.
So for your first question, it depends upon the TS the Tables are present in.
For the 2nd question, Gurmeet is right, u will get an SQL Code, u cannot update a table with UR.
Back to top
View user's profile Send private message
sumasudesh

New User


Joined: 25 May 2006
Posts: 1
Location: singapore

PostPosted: Tue May 30, 2006 2:08 pm    Post subject:
Reply with quote

In DB2, I just want to know that how can I apply lock when selecting a SINGLE ROW? (ROW-LEVEL)
Back to top
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue May 30, 2006 2:39 pm    Post subject: Re: Locks applied on tables in an update statement
Reply with quote

Hi,

i guess u r talking of four lock levels in db2 .

RR - REPEATABLE READ (locks whole db2 object u r accessing )
RS - READ STABILITY ( locks only rows or pages u scanned )
CS - CURSOR STABILITY (locks current row u r accessing )
UR - UNCOMITTED READ

in ur case use 'CS' for row level locking while scanning
i hope this fulfills ur question

Thanks ,
-Kapil .
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 Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm
No new posts IMS DB-How to update a record (a sing... Nic Clouston IMS DB/DC 9 Thu Mar 09, 2017 4:38 pm
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am


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