PROMPT Force delete preferences that have arc discriminator set to to 'EL'

DECLARE
   bug_no varchar2(8) := 'CK905620';
BEGIN

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

  for upr in 
  (
    select id id
    from ci_user_preferences@r212
    where preference_for = 'EL'    
    and   application_system_owned_by in ( select ci_appid
	    					       from ck_migration_objects
						       where ci_stage = 'APPSEL' ) 
  )
  loop
    ciiutl.delete_element@r212(upr.id, 'UPR');
  
    delete from sdd_elements@r212
    where el_id = upr.id;
   
  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;
/

