PROMPT Populate missing name on Module Components...
PROMPT Populate missing name on General Modules...

DECLARE
   bug_no varchar2(8) := 'CK963339';
   new_name varchar2(28) := '<Detected null by Migration>';
BEGIN

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

  update ci_module_components@r212
  set name = new_name
  where name is null
  and   application_system_owned_by in ( select ci_appid
	    				 from ck_migration_objects
					 where ci_stage = 'APPSEL' );

-- Bug 1194710 Populate missing name on General Modules...
  update ci_general_modules@r212
  set name = nvl(short_name, to_char(id)) || new_name
  where name is null
  and   application_system_owned_by in ( select ci_appid
	    				 from ck_migration_objects
					 where ci_stage = 'APPSEL' );
					 					 
  -- Nullify sub_diagram_id property if not valid
  update ci_diagrams@r212
  set sub_diagram_id = null
  where sub_diagram_id is not null
  and sub_diagram_id != 0
  and not exists ( select 1
                   from sdd_elements@r212
                   where el_id = sub_diagram_id )
  and application_system_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;
/
