create or replace procedure prc_ipdate_test
is
cursor cur_temp is
select distinct test.name from test;
begin
FOR cur_1 in cur_temp LOOP
update test m
set m.id =
(
select sortnum
from (select -rownum sortnum ,id,name from test where name = cur_1.name) n
where m.id = n.id
and m.name = n.name
)
where m.name = cur_1.name;
end loop;
commit;
end prc_ipdate_test;