REM This file updates the Meta Data tables for 6i 4.5

DECLARE

BEGIN



-- M90.004

DECLARE
  CURSOR get_use_of IS
    SELECT cat.short_name sname
         , 'I$'||ciiexp.get_table_name(cat.use_of_short_name) tname
    FROM ciue_association_types cat
    WHERE cat.is_user_type = 'Y';
BEGIN
  FOR i IN get_use_of LOOP
    EXECUTE IMMEDIATE ' delete from i$sdd_ues ues '||
                      ' where ues.element_type_name = '||''''||i.sname||''''||
                      ' and not exists (select null from '||i.tname||' on_tab '||
                      ' where ues.use_of_ref = on_tab.irid) ';
  END LOOP;
END;



  -- Register 4_5 Upgrade in the RM$PATCHES RM$PATCHES table
  rmpatch.install('CI04012.4_5_UPGRADE');

  rmpatch.installed_ok;



  commit;



EXCEPTION

  WHEN OTHERS THEN
    dbms_output.put_line('* Exception Raised  ');
    dbms_output.put_line('...ERROR: '||substrb(sqlerrm,1,240));
    rollback work;
    RAISE;

END;
/
