MontyPython
MontyPython

Reputation: 2994

Why does a simple update cursor take so much time?

This script is running for the past 10 minutes. It is operating on a table with only 10 records. What is wrong with the script?

declare
  cursor cus is 
  select * from customers
  for update of salary;
begin
  for i in cus
  loop
    update customers
    set salary = salary * 0.15
    where current of cus;
  end loop;
end;

Upvotes: 0

Views: 619

Answers (1)

JM_developer
JM_developer

Reputation: 58

Kind of a simple cursor but I don't use the "where current of", rather I match on a key.

update customers
set salary = i.salary *.15
where cus_key = i.cus_key

Upvotes: 1

Related Questions