Rem
Rem $Header: javavm/install/jvmpsui.sql /st_javavm_12.2.0.1.0ojvmbp/3 2017/09/01 08:04:35 sbusa Exp $
Rem
Rem jvmpsui.sql
Rem
Rem Copyright (c) 2014, 2017, Oracle and/or its affiliates. 
Rem All rights reserved.
Rem
Rem    NAME
Rem      jvmpsui.sql - OJVM PSU internal 
Rem
Rem    DESCRIPTION
Rem
Rem    NOTES
Rem      This script does the steps that jvmpsu.sql was doing earlier.
Rem      It is invoked by jvmpsu.sql if JAVAVM is installed in the database.
Rem
Rem    BEGIN SQL_FILE_METADATA 
Rem    SQL_SOURCE_FILE: javavm/install/jvmpsui.sql 
Rem    SQL_SHIPPED_FILE: javavm/install/jvmpsui.sql
Rem    SQL_PHASE: INSTALL
Rem    SQL_STARTUP_MODE: NORMAL 
Rem    SQL_IGNORABLE_ERRORS: NONE 
Rem    SQL_CALLING_FILE: 
Rem    END SQL_FILE_METADATA
Rem
Rem    MODIFIED   (MM/DD/YY)
Rem       sbusa    08/28/17 - Backport sbusa_oct_17_12.2.0.1_jdk8 from
Rem                           st_javavm_12.2.0.1.0ojvmbp
Rem       sbusa    05/29/17 - Backport sbusa_l_july17_12.2.0.1_jdk8 from
Rem                           st_javavm_12.2.0.1.0ojvmbp
Rem

SET ECHO ON
SET FEEDBACK 1
SET NUMWIDTH 10
SET LINESIZE 80
SET TRIMSPOOL ON
SET TAB OFF
SET PAGESIZE 100

-- do CJS, etc.

BEGIN

  initjvmaux.validate_javavm; -- Make sure it does not SEGV, when Java is in
                              -- inconsistent state.

  IF dbms_registry.is_valid('JAVAVM', dbms_registry.release_version) != 1 THEN
  
    initjvmaux.drop_sros();

    EXECUTE IMMEDIATE 'create or replace java system';

    update dependency$
      set p_timestamp=(select stime from obj$ where obj#=p_obj#)
      where (select stime from obj$ where obj#=p_obj#)!=p_timestamp and
            (select type# from obj$ where obj#=p_obj#)=29  and
            (select owner# from obj$ where obj#=p_obj#)=0;

-- Check the validity of JAVAVM and let the registry be updated accordingly.

    initjvmaux.validate_javavm;

-- Add a row in registry$history to indicate this script was run.

    EXECUTE IMMEDIATE 'insert into registry$history
                       (action_time, action, namespace, version, id, comments)
                       values(SYSTIMESTAMP, ''jvmpsu.sql'', ''SERVER'',
                              ''12.2.0.1.171017OJVMPSU'', 0, ''RAN jvmpsu.sql'')';

  END IF;

END;
/

commit;

