PROMPT Update module component reference on data bound item

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

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

  update ci_data_bound_items@r212 dbi
  set dbi.module_component_reference = ( select dtu.module_component_reference
	     				           from   ci_module_detail_table_usages@r212 dtu
					           where  dbi.detail_table_usage_reference = dtu.id )
  where exists ( select 1
                 from  ci_module_detail_table_usages@r212 dtu2
	             where dbi.detail_table_usage_reference = dtu2.id
                 and   dbi.module_component_reference != dtu2.module_component_reference )
  and  dbi.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;
/

