PROMPT Updating sequence_within_uid on unqiue identifier entries if null...

DECLARE
   bug_no varchar2(9) := 'CK1013924';
   counter number;
BEGIN

  update ck_migration_objects set ci_created = 'N' where ci_stage = 'CKPREMIG' and ci_name = bug_no;

  counter:= 10;

  for rec in
  (
    select uie.id id
    from  ci_unique_identifier_entries@r212 uie
    where uie.sequence_within_uid is null
    and   uie.application_system_owned_by in ( select ci_appid
	    					           from ck_migration_objects
						           where ci_stage = 'APPSEL' )
    order by uie.id
  )
  loop
    update ci_unique_identifier_entries@r212 
    set sequence_within_uid = counter
    where id = rec.id;
 
    counter:= counter + 10;
   
  end loop;

  update ck_migration_objects set ci_created = 'Y' where ci_stage = 'CKPREMIG' and ci_name = bug_no;
   
  commit;
  
EXCEPTION 
  when others then
     dbms_output.put_line (' ** Exception Raised ** ');
     dbms_output.put_line ('...ERROR: '||substrb(sqlerrm, 1, 200));
     raise;
	 
end;
/
