Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Clarification on SELECT for UPDATE

StephenJul 2 2010 — edited Jul 2 2010
HI All,

I am doing a SELECT FOR UPDATE using NOWAIT as well as SKIPLOCKED option. I have question regarding the general behavior.

Suppose let say , I have two tables (table1 and table 2 ).

TABLE 1
(
header_id NUMBER,
service_id NUMBER
)

TABLE 2
(
header_id NUMBER,
line_id NUMBER,
status VARCHAR2
)


And I run the following query

SELECT t2.header_id, t2.line_id
FROM table1 t1, table2 t2
WHERE t1.header_id = t2.header_id
AND t1.service_id = 1
AND t2.status = 'SUCCESS'
FOR UPDATE OF t2.status NOWAIT SKIP LOCKED;

Questions
1) Does adding both the NOWAIT and SKIP LOCKED in the sql help or just SKIP LOCKED would do fine.

2) Lets say this SQL is executed when there are no rows with status as 'SUCCESS' in table2. Would this cause any performance impact. Like for example since its joining with table1 with table 2 based on the header id .Would it lock any rows on table1?

( My understanding was that it would not lock any row until it finds out any row with status as 'SUCCESS' but getting some conflicting answers)


Thanks,
Vj
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 30 2010
Added on Jul 2 2010
1 comment
863 views