Skip to Main Content

Breadcrumb

May 4th

Question and Answer

Connor McDonald

Thanks for the question, Krishna.

Asked: May 29, 2016 - 8:46 pm UTC

Last updated: May 30, 2016 - 5:17 am UTC

Version: 9i

Viewed 1000+ times

You Asked

Hi,
If the following code causes a self dead lock, please explain how it occurs during execution

declare
cursor c1 is
select row_id,id,sts
from test
where ID = 'PF31'
order by row_id desc
for update of sts;
begin
for c1_rec in c1 loop
update test
set sts = 'Y'
where current of c1;
end loop;
end;

Thank you!

and Connor said...

When you say "If the following code causes a self dead lock" - are you saying you *are* seeing ora-60's or not ?

In any event, why not just do:

update test
set sts='Y'
where ID = 'PF31'

Easier to write, quicker to run...

Is this answer out of date? If it is, please let us know via a Comment