PROMPT Force delete text lines attached to 'app sys' element types

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

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

  delete from rm_text_lines@r212
  where txt_ref in ( select str_id
                     from sdd_structure_elements@r212
                     where str_type_of like 'APP%'
		         and   str_elem_owned_by in ( select ci_appid
	  	    					        from ck_migration_objects
							        where ci_stage = 'APPSEL' )
			  );

  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;
/
  

