使用 Oracle SQL 更新记录会导致使用游标时出现无限循环

Updating record with Oracle SQL results in an infinite loop while using a cursor

我在使用游标更新记录时陷入无限循环。这是代码...对我应该做什么有什么建议吗?

CREATE OR REPLACE PROCEDURE SHADI.filling_conditional
as
  cursor filling_cursor is select * from deposits_table for update;
begin 
  for i in filling_cursor 
  loop       
       update deposits_table 
         set conditional_flag = case 
                                    when i.deposit_amount > 1000 and i.currency_code = 'JOD'
                                         and (select customer_info.sex 
                                              from customer_info 
                                              where customer_info.customer_number = i.customer_number) = 1 
                                       then 1
                                    else 0 
                                 end;

  end loop;
end filling_conditional;
/

请尝试以下程序代码:

CREATE OR REPLACE PROCEDURE SHADI.filling_conditional
as
   c_deposit_amount   deposits_table.deposit_amount%type; 
   c_currency_code deposits_table.currency_code%type; 
   c_customer_number deposits_table.customer_number%type; 
   cursor filling_cursor is select deposit_amount, currency_code, customer_number from deposits_table for update;
BEGIN 
   OPEN filling_cursor; 
   LOOP 
   FETCH filling_cursor into c_deposit_amount, c_currency_code, c_customer_number; 
      EXIT WHEN filling_cursor%notfound; 
      update deposits_table 
         set conditional_flag = case 
                                    when c_deposit_amount > 1000 and c_currency_code = 'JOD'
                                         and (select customer_info.sex 
                                              from customer_info 
                                              where customer_info.customer_number = c_customer_number) = 1 
                                       then 1
                                    else 0 
                                 end;
   END LOOP; 
   CLOSE filling_cursor; 
END filling_conditional;
/