PROMPT Updating invalid 'id' for element type 'DEU'

DECLARE
   bug_no varchar2(8) := 'CK942113';
   newDEUid number;

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

  for rec in 
  (
    select str.str_id id 
    from sdd_structure_elements@r212 str,
         sdd_elements@r212 sdd
    where str.str_type_of = 'DEU' 
    and str.str_id = sdd.el_id
    and str.str_elem_owned_by in ( select ci_appid
	    				     from ck_migration_objects
					     where ci_stage = 'APPSEL' )
    union 
    select str.str_id id 
    from sdd_structure_elements@r212 str,
         sdd_structure_elements@r212 str2
    where str.str_type_of = 'DEU' 
    and str.str_id = str2.str_id
    and str2.str_type_of != 'DEU'
    and str.str_elem_owned_by in ( select ci_appid
	       				         from ck_migration_objects
						         where ci_stage = 'APPSEL' )
  )
  loop
    --  Get new element ID for diagram element usage
    select   sdd_el_seq.nextval@r212
    into     newDEUid
    from     sys.dual;

    -- update sdd_elements with new el_id
    update sdd_elements@r212
    set el_id = newDEUid
    where el_id = rec.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;
/



 