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

Locks applied on tables in an update statement


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts JOIN STATEMENT PERFORMANCE. DFSORT/ICETOOL 12
No new posts Read a flat file and update DB2 table JCL & VSAM 2
No new posts how to update an ISR appl var from an... TSO/ISPF 8
No new posts Relate COBOL statements to EGL statement All Other Mainframe Topics 0
Search our Forums:

Back to Top