Rem    BEGIN SQL_FILE_METADATA
Rem    SQL_SOURCE_FILE: javavm/install/jvmdwgrd.sql
Rem    SQL_SHIPPED_FILE: javavm/install/jvmdwgrd.sql
Rem    SQL_PHASE: DOWNGRADE
Rem    SQL_STARTUP_MODE: UPGRADE
Rem    SQL_IGNORABLE_ERRORS: NONE
Rem    END SQL_FILE_METADATA


variable jvmudaction varchar2(30)
execute :jvmudaction := 'DOWNGRADE';

variable jvmdownto varchar2(30)
execute select prv_version into :jvmdownto from registry$ where cid='CATPROC';

select 'JVMDOWNTO is '||:jvmdownto,initjvmaux.registrystatus,:jvmudaction from dual;

variable jvmpatchset varchar2(30)

call initjvmaux.startaction('DOWNGRADE_TO_'||:jvmdownto);

rem If downgrade specific changes not handled by jvmrm need to be introduced
rem they should go here conditionalized in terms of
rem initjvmaux.compare_releases(:jvmdownto, 'nn.mm') tests similar to those
rem done in jvmrm

variable jvmrmaction varchar2(30)
execute :jvmrmaction := 'DOWNGRADE';

begin
  if initjvmaux.compare_releases(:jvmdownto, '19.0') = 'FIRST IS OLDER' then
    --- drop jakarta.mail.jar on downgrade for lower versions.
    initjvmaux.exec('begin
        dbms_java.dropjava(''-v -install -synonym jlib/jakarta.mail.jar'');
        end;');

    -- remove jakarta.activation.jar resources
    initjvmaux.drop_sys_resource('META-INF/SUN_MICR.SF');
    initjvmaux.drop_sys_resource('META-INF/SUN_MICR.RSA');        
    initjvmaux.drop_sys_resource('META-INF/mailcap.default');
    initjvmaux.drop_sys_resource('META-INF/mimetypes.default');

    -- remove http_client.jar because it may be the old version in use after
    -- downgrade
    initjvmaux.exec('begin
        dbms_java.dropjava(''-v -install -synonym lib/http_client.jar'');
        end;');
  end if;
end;
/

@@jvmrm

@@udjvmrm
