create or replace procedure test
as
  type ref_cursor  is ref cursor;
  cursor_test      ref_cursor;
  my_id            number;
  my_my            number;
begin
  my_id := 1;
  open  cursor_test for
        select name
        from   table1
        where  id=my_id;
  loop
        fetch  cursor_test into my_my;
        exit   when cursor_test%notfound;
        update table2 set id=my_my;
  end loop;
  commit;
  close cursor_test;
end test;
/