oracle-databaseplsqlsql-updatecursororacle19c

Diffrenece between two pl/sql with cursor for update (oracle)


I got this working code:

declare
 cursor c1 is select * from a.testA;
 testA_record a.testA%rowtype;
begin
 
  open c1;
    loop fetch c1 into testA_record; 
      exit when c1%notfound;
      
      update a.testA set colA = 100;
    
    end loop;
  close c1;
  
end;

Then made litte changes:

declare
 cursor c1 is select * from a.testA k for update;
 testA_record a.testA%rowtype;
begin
 
  open c1;
    loop fetch c1 into testA_record; 
      exit when c1%notfound;      
      
       update k set colA = 100 where current of c1;--without this line code is running
    
    end loop;
  close c1;
  
end;

And getting error: ORA-00942.

What is wrong or missing?


Solution

  • This:

    update k set colA = 100 where current of c1;
    

    raised ORA-00942 (table or view doesn't exist).

    As the only table involved here is k, I'd say that there's no table named k available to you. Either you don't own it, there's no (public) synonym, ...

    Should've probably been

    update a.testA set ...