Oracle Inventory | Ageing Analysis

Quite often auditors could come with some strange requirements (especially when they do not understand the business) & we had to formalize on foot couple of years back. From those days, I always wanted to put together few things and post this, which is happening today.

Our requirements were to list the receipts in 6 buckets, ie, within last 120 days, between 121-180 days, beween 181-1 year, between 1-2 Years, between 2-3 Years and 3 Years + (and still in stock!)

Please note, I am using a custom function “omsconcorgqty_f (code provided below, that concatenates the subinventory quantities into a single column. This function could raise an exception when the column length exceeds 4000 characters.

Minimum requirements: Your EBS instance must be using Oracle database 11gR2 to use “LISTAGG” that is used with the custom function. In addition to, I am using PIVOT, that is supported from 11g.

The below example considers a situation where business has a WMS enabled organization. You can pass NULL to :P_WAREHOUSE_ID when not applicable.

If your organization uses multiple UOM for items, you must adjust the below query accordingly, especially for the cost part.

The average cost for the item is picked using the following logic.

If the :P_ORG_ID has item quantities, then the cost for the item will be picked from the same organization. If the :P_ORG_ID organization doesn’t have quantities and warehouse has, then the cost from :P_WAREHOUSE_ID organization will be picked. So there could be inventory value differences and you shouldn’t use the inventory values derived from this exercises if the above said conditions apply.

WITH dataset AS (
    SELECT
        pivot_data.*
    FROM
        (
            SELECT
                inv_data.inventory_item_id,
                inv_data.transaction_quantity,
                inv_data.age_in_days
            FROM
                ( (
                    SELECT
                        moq.inventory_item_id,
                        moq.organization_id,
                        moq.transaction_quantity,
                        CASE
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) <= 120                        THEN
                                1
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) BETWEEN 121 AND 180           THEN
                                2
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) BETWEEN 181 AND 365           THEN
                                3
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) BETWEEN 366 AND 730           THEN
                                4
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) BETWEEN 731 AND 1095          THEN
                                5
                            WHEN ( trunc(sysdate) - trunc(moq.date_received) ) > 1096                        THEN
                                6
                        END age_in_days
                    FROM
                        mtl_onhand_quantities moq
                    WHERE
                        moq.organization_id IN ( :p_org_id, :p_warehouse_id )
                ) inv_data )
        ) PIVOT (
            SUM ( transaction_quantity )
            FOR age_in_days
            IN ( 1 AS "120 Days", 2 "121-180 Days", 3 "181-365 Days", 4 "1Yr-2Yr", 5 "2Yr-3Yr", 6 "3Yrs+" )
        )
        pivot_data
)
SELECT
    msi.concatenated_segments,
    msi.description,
    msi.primary_uom_code,
    CASE
        WHEN nvl((
            SELECT
                SUM(transaction_quantity)
            FROM
                mtl_onhand_quantities moq
            WHERE
                    moq.inventory_item_id = msi.inventory_item_id
                AND moq.organization_id = :p_org_id
            GROUP BY
                moq.inventory_item_id,
                moq.organization_id
        ),
                 0) > 0 THEN
            (
                SELECT
                    item_cost
                FROM
                    cst_item_costs cic
                WHERE
                        cic.inventory_item_id = msi.inventory_item_id
                    AND cic.organization_id = msi.organization_id
                    AND cic.cost_type_id = 2
            )
        ELSE
            (
                SELECT
                    item_cost
                FROM
                    cst_item_costs cic
                WHERE
                        cic.inventory_item_id = msi.inventory_item_id
                    AND cic.organization_id = :p_warehouse_id
                    AND cic.cost_type_id = 2
            )
    END                                                                                                       item_cost,
    dataset.*,
    omsconcorgqty_f(:p_org_id, :p_warehouse_id, dataset.inventory_item_id, msi.primary_uom_code)              org_quantity
FROM
         dataset
    INNER JOIN mtl_system_items_kfv msi ON msi.inventory_item_id = dataset.inventory_item_id
                                           AND msi.organization_id = :p_org_id
ORDER BY
    msi.concatenated_segments;

omsconcorgqty_f function

This function adds (W) before the subinventories from :P_WAREHOUSE_ID organization for easier identification.

CREATE OR REPLACE FUNCTION omsconcorgqty_f (
    p_org_id        IN  NUMBER,
    p_warehouse_id  IN  NUMBER,
    p_item_id       IN  NUMBER,
    p_uom           IN  VARCHAR2
) RETURN VARCHAR2 IS
    l_qty_string VARCHAR2(4000);
BEGIN
    SELECT
        LISTAGG(subqty, ',') WITHIN GROUP(
            ORDER BY
                subqty
        )
    INTO l_qty_string
    FROM
        (
            SELECT
                inventory_item_id,
                CASE
                    WHEN organization_id = p_warehouse_id THEN
                        '(W)'
                        || subinventory_code
                        || '('
                        || to_char(SUM(transaction_quantity))
                        || ')'
                    ELSE
                        subinventory_code
                        || '('
                        || to_char(SUM(transaction_quantity))
                        || ')'
                END subqty
            FROM
                mtl_onhand_quantities_detail moq
            WHERE
                    moq.inventory_item_id = p_item_id
                AND moq.transaction_uom_code = p_uom
                AND organization_id IN ( p_org_id, p_warehouse_id )
            GROUP BY
                inventory_item_id,
                subinventory_code,
                organization_id
        )
    GROUP BY
        inventory_item_id;

    RETURN l_qty_string;
END;

Hope this helps

Windows | Upgrade Oracle Database 12c to 19c

Our business application is hosted on Linux. I love the way the OS is fine tuned by Oracle for the database & without arguments, I must say, Oracle is perfect on Linux.

Does that stop me from installing the latest Oracle database & experimenting them on Windows? Nay, from the known days I’ve used Windows OS for PC & I am sure, will be retiring using one. I’ve made many attempts to install and configure many unsupported Oracle products on Windows & have a VERY good success record ;)

Yet, I never ever upgraded Oracle databases on Windows to next version as I never had a database that needed to be backed up or restored when a new version was tried out. This time I decided to change that habit and to upgrade my existing 12c CDB database to 19c following some documents specifically written for Linux!

Well, regardless whether you are a Linux or Windows person, trust me, the instructions provided for either platform is 99% applicable on both. So, translating the instructions on Linux for Windows are NOT truly difficult, in case if you are IN for some geeky stuffs.

So let us quickly assess my environment. I had 12c CDB with one PDB, which I don’t remember whether I created during the software installation or later. As usual, the following instructions are for a lab setup. That means, you must make sure that you make proper backups prior moving them to a Production environment. My TEST database didn’t have any data, just the sample schemas.

Install Oracle Database 19c. Choose “Software Only” option. That means do not create a database along with the installation. You may refer my earlier post for Oracle 19c installation here.

Now, let us see how to upgrade our 12c database to 19c. There are many prerequisites for a successful upgrade. Oracle provides many tools to insure a successful upgrade.

Start your 12c database and open an elevated command prompt.

From your 12c database home aka %ORACLE_HOME%\bin folder execute prerequisites collection program. Example

D:\Oracle\product\12.2.0\dbhome_1\bin>java -jar D:\Oracle\product\19.3.0\rdbms\admin\preupgrade.jar TEXT TERMINAL

TEXT TERMINAL will force the program to output all the instructions to the current console. You should copy the output to a text file & go through the findings. Against the pre-upgrade instructions, you must satisfy each one of them & re-run the prerequisites collection once again. If you are upgrading a Container database with pluggable databases, the post-upgrade activities will be listed per database.

A Sample output as below:

D:\Oracle\product\12.2.0\dbhome_1\bin>java -jar D:\Oracle\product\19.3.0\rdbms\admin\preupgrade.jar TEXT TERMINAL
Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 1 on 2020-11-20T17:45:58

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  CDB12C
     Container Name:  CDB$ROOT
       Container ID:  1
            Version:  12.2.0.1.0
     DB Patch Level:  No Patch Bundle applied
         Compatible:  12.2.0
          Blocksize:  8192
           Platform:  Microsoft Windows x86 64-bit
      Timezone File:  26
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  2.  (AUTOFIXUP) Gather statistics on fixed objects prior the upgrade.

      None of the fixed object tables have had stats collected.

      Gathering statistics on fixed objects, if none have been gathered yet, is
      recommended prior to upgrading.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
  3.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             470 MB       500 MB
      SYSTEM                             800 MB       915 MB
      TEMP                                33 MB       150 MB

      Minimum tablespace sizes for upgrade are estimates.

  4.  No action needed.

      Using default parallel upgrade options, this CDB with 2 PDBs will first
      upgrade the CDB$ROOT, and then upgrade at most 2 PDBs at a time using 2
      parallel processes per PDB.

      The number of PDBs upgraded in parallel and the number of parallel
      processes per PDB can be adjusted as described in Database Upgrade Guide.

  5.  Check the Oracle Backup and Recovery User's Guide for information on how
      to manage an RMAN recovery catalog schema.

      If you are using a version of the recovery catalog schema that is older
      than that required by the RMAN client version, then you must upgrade the
      catalog schema.

      It is good practice to have the catalog schema the same or higher version
      than the RMAN client version you are using.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container CDB$ROOT
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  6.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 26 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  7.  To identify directory objects with symbolic links in the path name, run
      $ORACLE_HOME/rdbms/admin/utldirsymlink.sql AS SYSDBA after upgrade.
      Recreate any directory objects listed, using path names that contain no
      symbolic links.

      Some directory object path names may currently contain symbolic links.

      Starting in Release 18c, symbolic links are not allowed in directory
      object path names used with BFILE data types, the UTL_FILE package, or
      external tables.

  8.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  9.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container CDB$ROOT
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/postupgrade_fixups.sql


Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 1 on 2020-11-20T17:46:22

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  CDB12C
     Container Name:  PDB$SEED
       Container ID:  2
            Version:  12.2.0.1.0
     DB Patch Level:  No Patch Bundle applied
         Compatible:  12.2.0
          Blocksize:  8192
           Platform:  Microsoft Windows x86 64-bit
      Timezone File:  26
  Database log mode:  NOARCHIVELOG
           Readonly:  TRUE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  2.  (AUTOFIXUP) Gather statistics on fixed objects prior the upgrade.

      None of the fixed object tables have had stats collected.

      Gathering statistics on fixed objects, if none have been gathered yet, is
      recommended prior to upgrading.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
  3.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             330 MB       500 MB
      SYSTEM                             250 MB       358 MB
      TEMP                                64 MB       150 MB
      UNDOTBS1                           100 MB       439 MB

      Minimum tablespace sizes for upgrade are estimates.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container PDB$SEED
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  4.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 26 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  5.  To identify directory objects with symbolic links in the path name, run
      $ORACLE_HOME/rdbms/admin/utldirsymlink.sql AS SYSDBA after upgrade.
      Recreate any directory objects listed, using path names that contain no
      symbolic links.

      Some directory object path names may currently contain symbolic links.

      Starting in Release 18c, symbolic links are not allowed in directory
      object path names used with BFILE data types, the UTL_FILE package, or
      external tables.

  6.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  7.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container PDB$SEED
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/postupgrade_fixups.sql


Report generated by Oracle Database Pre-Upgrade Information Tool Version
19.0.0.0.0 Build: 1 on 2020-11-20T17:46:22

Upgrade-To version: 19.0.0.0.0

=======================================
Status of the database prior to upgrade
=======================================
      Database Name:  CDB12C
     Container Name:  SCT
       Container ID:  3
            Version:  12.2.0.1.0
     DB Patch Level:  No Patch Bundle applied
         Compatible:  12.2.0
          Blocksize:  8192
           Platform:  Microsoft Windows x86 64-bit
      Timezone File:  26
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  EE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  OPTION OFF
  Oracle Workspace Manager               [to be upgraded]  VALID
  OLAP Analytic Workspace                [to be upgraded]  VALID
  Oracle Label Security                  [to be upgraded]  VALID
  Oracle Database Vault                  [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Spatial                         [to be upgraded]  VALID
  Oracle OLAP API                        [to be upgraded]  VALID

==============
BEFORE UPGRADE
==============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  1.  (AUTOFIXUP) Gather stale data dictionary statistics prior to database
      upgrade in off-peak time using:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Dictionary statistics do not exist or are stale (not up-to-date).

      Dictionary statistics help the Oracle optimizer find efficient SQL
      execution plans and are essential for proper upgrade timing. Oracle
      recommends gathering dictionary statistics in the last 24 hours before
      database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  2.  (AUTOFIXUP) Gather statistics on fixed objects prior the upgrade.

      None of the fixed object tables have had stats collected.

      Gathering statistics on fixed objects, if none have been gathered yet, is
      recommended prior to upgrading.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
  3.  To help you keep track of your tablespace allocations, the following
      AUTOEXTEND tablespaces are expected to successfully EXTEND during the
      upgrade process.

                                                 Min Size
      Tablespace                        Size     For Upgrade
      ----------                     ----------  -----------
      SYSAUX                             350 MB       500 MB
      SYSTEM                             250 MB       358 MB
      TEMP                                64 MB       150 MB
      UNDOTBS1                           100 MB       439 MB

      Minimum tablespace sizes for upgrade are estimates.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container SCT
  which are identified above as BEFORE UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/preupgrade_fixups.sql

=============
AFTER UPGRADE
=============

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
  4.  Upgrade the database time zone file using the DBMS_DST package.

      The database is using time zone file version 26 and the target 19 release
      ships with time zone file version 32.

      Oracle recommends upgrading to the desired (latest) version of the time
      zone file.  For more information, refer to "Upgrading the Time Zone File
      and Timestamp with Time Zone Data" in the 19 Oracle Database
      Globalization Support Guide.

  5.  To identify directory objects with symbolic links in the path name, run
      $ORACLE_HOME/rdbms/admin/utldirsymlink.sql AS SYSDBA after upgrade.
      Recreate any directory objects listed, using path names that contain no
      symbolic links.

      Some directory object path names may currently contain symbolic links.

      Starting in Release 18c, symbolic links are not allowed in directory
      object path names used with BFILE data types, the UTL_FILE package, or
      external tables.

  6.  (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
      command:

        EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

      Oracle recommends gathering dictionary statistics after upgrade.

      Dictionary statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans. After a database
      upgrade, statistics need to be re-gathered as there can now be tables
      that have significantly changed during the upgrade or new tables that do
      not have statistics gathered yet.

  7.  Gather statistics on fixed objects after the upgrade and when there is a
      representative workload on the system using the command:

        EXECUTE DBMS_STATS.GATHER_FIXED_OBJECTS_STATS;

      This recommendation is given for all preupgrade runs.

      Fixed object statistics provide essential information to the Oracle
      optimizer to help it find efficient SQL execution plans.  Those
      statistics are specific to the Oracle Database release that generates
      them, and can be stale upon database upgrade.

      For information on managing optimizer statistics, refer to the 12.2.0.1
      Oracle Database SQL Tuning Guide.

  ORACLE GENERATED FIXUP SCRIPT
  =============================
  All of the issues in database CDB12C container SCT
  which are identified above as AFTER UPGRADE "(AUTOFIXUP)" can be resolved by
  executing the following from within the container

    SQL>@D:\Oracle\cfgtoollogs\cdb12c\preupgrade\/postupgrade_fixups.sql


==================
PREUPGRADE SUMMARY
==================
  D:\Oracle\cfgtoollogs\cdb12c\preupgrade\preupgrade.log
  D:\Oracle\cfgtoollogs\cdb12c\preupgrade\preupgrade_fixups.sql
  D:\Oracle\cfgtoollogs\cdb12c\preupgrade\postupgrade_fixups.sql

Execute fixup scripts across the entire CDB:

Before upgrade:

1. Execute preupgrade fixups with the below command
%ORACLE_HOME%\perl\bin\perl -I%ORACLE_HOME%\perl\lib -I%ORACLE_HOME%\rdbms\admin %ORACLE_HOME%\rdbms\admin\catcon.pl -l D:\Oracle\cfgtoollogs\cdb12c\preupgrade\ -b preup_cdb12c D:\Oracle\cfgtoollogs\cdb12c\preupgrade\preupgrade_fixups.sql

2. Review logs under D:\Oracle\cfgtoollogs\cdb12c\preupgrade\

After the upgrade:

1. Execute postupgrade fixups with the below command
%ORACLE_HOME%\perl\bin\perl -I%ORACLE_HOME%\perl\lib -I%ORACLE_HOME%\rdbms\admin %ORACLE_HOME%\rdbms\admin\catcon.pl -l D:\Oracle\cfgtoollogs\cdb12c\preupgrade\ -b postup_cdb12c D:\Oracle\cfgtoollogs\cdb12c\preupgrade\postupgrade_fixups.sql

2. Review logs under D:\Oracle\cfgtoollogs\cdb12c\preupgrade\

Preupgrade complete: 2020-11-20T17:46:32

D:\Oracle\product\12.2.0\dbhome_1\bin>

Once all the prerequisites are met, we can use the GUI tool “Database Upgrade Assistant” to upgrade our existing database(s). For this exercise, I will be upgrading my 12c Container database with one PDB

Select the 12c database that you want to upgrade. Please note, my database hardly had any data & was not on archive log mode. If you are planning to upgrade a production database that has archive log enabled, take proper backups prior proceeding.

I’ve an exclusive user account “oracle” for all Oracle installations. If you have used another user account, provide it at this step.

As my database doesn’t have archive logging, my best choice is to create an Offline RMAN backup. You may choose another option from the available.

My 12c database had a LISTENER that is listening to 1521 & by mistake I have selected a PORT 5500. Please adjust your PORT number.

Above I said how I wrongly selected a PORT number for LISTENER, I’ve selected the same PORT number for the Enterprise Manager also. Well, later I corrected the mistake. So be careful while you select PORT numbers.

Sit back, watch a movie or go for a walk. The following activities are going to take considerable time. Bigger your database, more time needed to complete the upgrade. I’ve pretty a beast as desktop and whole upgrade took almost couple of hours. Based on your available resources, the upgrade might take longer times.

Okay, I missed taking the last Screenshot. Once the upgrade finished, you can start with post-upgrade activities as they are listed with the prerequisites output.

That’s all folks. Have comments? Please send them to me.

Install Oracle Database 19c on Windows 10

This time let us see how to install Oracle database 19c on Windows 10. This installation is not much different from Oracle 18c installation.

You can download the 19c Installation media for Windows from the below link.

Database Software Downloads | Oracle

Once downloaded, you have to extract the package to a folder. Please note, the extracted folder or the folder from which you will execute “Setup.exe” is going to be 19c Oracle Home. So, name the folder wisely. For example, I have extracted the files to a folder D:\Oracle\19c

You can start the installation by right clicking the Setup.exe and running as “Administrator”.

This will kick start the installation.

We will not create a database along with the software installation. Hence select “Set Up Software Only”

I suggest you to create a normal user (no administrator privileges) “oracle”, that will be used for all your future Oracle software installations. If you don’t have an account explicitly created yet for Oracle, the installation gives you an interface to create one. It’s your choice.

Please remember, earlier I said, the folder where you have extracted the installation media is going to be Oracle 19c home, aka Oracle Home. Rename the folder with an appropriate name before going ahead with the installation.

You will be asked to provide a location for Oracle Base. To content within the Oracle Home, you can specify a path like “D:\Oracle\19c\database” or “D:\Oracle\19c\db” or a folder name of your choice.

After few basic checks, the installation will proceed now. I strongly suggest you to assign a STATIC IP for your computer, prior continuing.

That’s it. No hacks, no modifications to config files or anything such to get the software installed on Windows!.

You can use “Database Configuration Assistant” for creating new database. We will see how to create a new database now. This time we will be creating a CDB (Container Database) and one PDB (Pluggable Database). You may go ahead with creating a single instance database when asked to choose between.

Select “Advanced Configuration”

You can choose between a normal database or Container database with PDB at next step. If you don’t wish to create the database as a container, uncheck the option “Create as Container database”. If you chose to continue with creating your database as container, I suggest you to leave the defaults as it is, other than the PDB name. If you need more PDBs, may add later to the container.

Leave the defaults, unless you know what you are doing.

If you are setting up the database for the LAB/Learning purposes, you may ignore these. However, for production instances, you must configure the Recovery area & setup archiving.

You can create a LISTENER for your database now. If you other Oracle database LISTENERs already running, choose a port number that wouldn’t raise a conflict.

Optionally you can setup Database Vault & Label Security at this step ;)

Okay, we need your attention here. Oracle automatically allocates 40% of total available physical memory for the newly created database. As I mentioned in the previous step, if you have more than one database running from the same computer, you must adjust the available memory to avoid choking the resources.

You may leave the defaults untouched here & you can change this value as sys admin when needed.

WebLogic Repos insist upon “AL32UTF8” Character Set & unless you have specific reasons to change the Character set, leave the defaults. If you are planning to migrate a legacy application that uses a different character set like Arabic (AR8MSWIN1256), please read this post

As per the post, you can use a different character set for a PDB starting from Oracle database versions 12.2.

We do love Scott bit too much, if yes, go with sample schemas (Trust me, you need it)

Enterprise Manager configuration is totally optional. If you choose to, will install an Express edition of Oracle Enterprise Manager (means more resources)

As usual, for a LAB environment I will go with same password for all accounts.

I would suggest you to accept the defaults at next step & change the passwords and unlock accounts as and when needed.

That should complete the installation and creation of database for 19c. Have comments? Please post them to me.

Windows 10 | Uninstall pre-installed/bundled software & apps

Windows 10 comes with a number of apps, usually we call them as bloatware in the mobile phones segments. Today we will see how to get rid of most of those pre-installed or bundled apps and a method to re-install the Microsoft Store app. By uninstalling the bundled software, trust me, you are going to save hell loads of bandwidth and storage.

Prerequisites: I am expecting you to have moderate experiences with Windows OS, as the below instructions might require you to open PowerShell as an administrator. For a fail safe situation, I will ask you to have minimum one more user account created and signed on prior you try to remove the pre-installed apps from your user account.

Once PowerShell console opens, you should able to see something like this on top of the console window “Administrator: Windows PowerShell”.

Before uninstalling the pre-installed apps, that includes “Microsoft Store”, we have to make a note of the Store application package name. Please note, the package name changes between builds, hence you must run the below command from your own Windows 10 machine, ie, do not copy from this post.

Get-AppxPackage -AllUsers -Name "Microsoft.WindowsStore"

So for my Windows 10 box, I need to copy the value for “PackageFullName”, that is

Microsoft.WindowsStore_12011.1001.1.0_x64__8wekyb3d8bbwe

Side note: Please give extra attention to “PackageUserInformation”. This element lists all the user accounts those already have the “Microsoft Store” app installed. My work laptop (this machine) has four User accounts (default Administrator account disabled) including the domain user account. For my local and domain accounts, the store app is already installed and for other two accounts the app has been staged. Ie, not yet installed.

Please copy the “PackageFullName” element value to a notepad and save the file on the desktop with a name that you could remember.

In the same PowerShell console issue the below command

Get-AppxPackage -AllUsers | Remove-AppxPackage

This is going to start uninstalling the pre-installed apps. There will be some funny Red color texts, highlighted bars over the PowerShell prompt. Don’t get panicked. Based on the resources available this might take a while to finish. Once the PowerShell prompt returned, you will see that all the pre-installed apps are gone… for good!

However we need the Microsoft Store app back for downloading the most essential apps like Calculator, Mail client & few other. In the same PowerShell console, construct a command like below. Please make sure you will replace the package name with the one you have copied to the text file earlier.

Add-AppxPackage -register "C:\Program Files\WindowsApps\Microsoft.WindowsStore_12011.1001.1.0_x64__8wekyb3d8bbwe\appxmanifest.xml" –DisableDevelopmentMode

Microsoft Store app should be installed instantly and you can proceed with installing your essential apps from the store now.

Like all other times, I ask you not to proceed, if you don’t know what you are going to end up with!

One much detailed information you can find here [Guide] How to Uninstall and Remove All Built-in Apps in Windows 10 – AskVG

VirtualBox | Windows 10 Guests too slow

I’m a huge fan of Oracle VirtualBox. Actually I have almost 10 different VMs (many of them were never used over years) scattered everywhere within my home network. Then I had this Windows 10 VM, that always had troubles.

Environment: HOST (HP PROBOOK 440 G7

Windows 10 Pro 64Bit, i7-10th Generation Processor with 8 CPUs, 32GB RAM, NVMe disk for OS and Crucial MX500 series 1TB SSD for data/Virtual Machines & Windows 10 guest has the configurations as seen with the image.

In addition to, for the VDI with fixed size, I have exclusively set “Solid-state Drive” flag. If you have a keen observation, I have selected “Hyper-V Paravirtualization” for “Acceleration” and I don’t have Hyper-V enabled :). Well, I didn’t hear any complaints (yet)!

After reviewing many posts and answers over VirtualBox forum, I have made few changes those I felt could make some differences, and I feel my VM responds much better after those changes.

Disable Transparency. This makes your Windows 10 VM respond much faster (not just “seems faster®” ;) )

Setup your box for best performance.

Reboot the Virtual Machine. I have seen slight gains with the booting time, however once logged in the VM is snappier than ever. I cannot help you, if you are using VM for something fancy that depends upon the Graphic processing. For a server side software like Oracle database where the performance matters, I think this is the only one go with current VirtualBox/Windows 10 setup.

If you are interested to see how long it takes for my VM to finally let me log in, watch the below video.

Leave me your comments!

Oracle Forms & Reports 12c | Publishing a sample application

After a long break, I am going to post about deploying Oracle Forms & Reports based application using Weblogic Server 12c (12.2.1.4).

With my previous posts about Weblogic 12c & Oracle Forms & Reports, I have provided most of the details about configuring the Forms and Reports environments for deploying Forms & Reports based application(S). Well, for a beginner this could post a challenge.

So the post is for beginners and those trying to setup an environment using Weblogic Server for the first time. Please note, you must adjust the paths listed below according to your installation/naming conversions.

To start with, I always install Weblogic Server & Oracle Forms & Reports software on the same HOME. Example: D:\Weblogic\Middleware\Oracle_Home

The advantage of following the same name throughout installations (of same version) is, I can copy the fine tuned configuration files from an existing installation and later use them when I am forced to remove and reconfigure the complete infrastructure.

To host Oracle forms and reports based applications, we need to make few changes with existing configuration files for both Forms and Reports. Prior making those changes, let us run a quick errand for mandatory elements for successful deployment of applications.

HOST Name (aka your computer name). Make sure you have a meaningful name for your computer. If you have installed and configured Weblogic and other software components against a name that looks like a joke, then redo the installation and configurations against a new computer name (eg: RAJESH-PC, JOHN, MARTHA, ORASERVER or anything that is short and could easily be identified). Refer documents those explain you how to change your computer name.

You must have a STATIC IP address for your computer that is going to host your Forms & Reports application. If your computer is part of domain network & supported by a DNS server, you might take a risk of not having STATIC IP, however, please note, Oracle insists for a STATIC IP for the box on which you install database & other server software. Usually at home/small networks, you are connected to a wireless router/router or a computer that issues dynamic IP addresses. If you are at home, you may assign a IP address outside of DHCP scope for you computer. Please google for more details to know how to setup STATIC IP address. If you are new to these basic networking elements, consult someone who could help you.

HOST File modifications. As we are talking about Windows environments, regardless whether client or Server OS, you will find the HOST file under:

C:\Windows\System32\drivers\etc

You can use Notepad to open up this file and add an entry like below. If you are on Windows 7 or later, make sure that you are opening Notepad as Administrator (The whole exercises you have read until were only tested on Windows 10):

Where 192.168.1.65 is the STATIC IP address assigned to my computer, erp-prod.my.home is the fully qualified domain name(FQDN) and erp-prod is the hostname.

At home you don’t need the FQDN, unless you have a DNS configured or you fancy a computer name like “mycomputer.mydomain.com” instead of just “mycomputer”

The above were the least amount of network related settings those you insure to make sure that your application can be accessed from your computer (and your network). Please note, you have to open port 7777 (default OHS) through the firewall so that other computers on the network can access your application. For local testing, you may skip this.

So, I guess we are good with the above mentioned and will move to setting up “stuffs” for our first application. I already have an application that was developed using 11g Forms & Reports and will be using the same for the rest of explanations.

Setup TNS Names. If you are not using environment variable TNS_ADMIN, you should set up the TNS names exclusively for your application deployment.

So, I said I always install Weblogic and other software components in the same place “D:\Weblogic\Middleware\Oracle_Home”. After configuring for a classic domain for Forms & Reports, I can find the tnsnames.ora file under the path:

D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain\config\fmwconfig

Where “base_domain” is the default domain name Oracle suggests during the configurations.

I suggest you to make a copy of your tnsnames.ora file prior making changes to the file. The best is, copy the tnsnames.ora file from your database network admin folder after renaming the existing tnsnames.ora file.

Once the TNS names are set, we can quickly setup “formsweb.cfg” file within which our application specific configurations will be defined.

Based on my installation path and classic domain naming, I should find the formsweb.cfg & default.env files under:

D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain\config\fmwconfig\servers\WLS_FORMS\applications\formsapp_12.2.1\config

Please make sure that each and every other configuration file that you are going to edit/alter is backed up, so that you can rollback to default configuration easily by replacing the wrongly configured files. I usually put “.original” by the end of backed up files!

Below is a sample configuration for my application & trust me, you need more than half of the parameters listed below

[balaji]
# 
# Entries from source Oracle FMW Domain
# added by the Forms Upgrade Assistant Plugin.
baseHTML=base.htm
baseHTMLjpi=basejpi.htm
HTMLdelimiter=%
envFile=default.env
serverArgs=%escapeparams% module=%form% userid=%userid% debug=%debug% host=%host% port=%port% %otherparams%
escapeparams=true
form=LOGIN.fmx
userid=APPS/APPS@orcl
debug=no
host=
port=
digitSubstitution=context
otherparams=obr=%obr% record=%record% tracegroup=%tracegroup% log=%log% term=%term% ssoProxyConnect=%ssoProxyConnect%
obr=no
record=
tracegroup=
log=
term=
HTMLbodyAttrs=
HTMLbeforeForm=
HTMLafterForm=
serverURL=/forms/lservlet
codebase=/forms/java
imageBase=codebase
mediaBase=codebase
width=750
height=600
separateFrame=true
splashScreen=false
allowAlertClipboard=true
disableValidateClipboard=false
highContrast=false
background=
lookAndFeel=Oracle
colorScheme=swan
customColorScheme=
logo=
guiMode=0
restrictedURLparams=pageTitle,HTMLbodyAttrs,HTMLbeforeForm,HTMLafterForm,log
formsMessageListener=
recordFileName=
serverApp=
archive=frmall.jar
networkRetries=0
java_version=1.7+
legacy_lifecycle=false
ssoDynamicResourceCreate=true
ssoErrorUrl=
ssoCancelUrl=
ssoMode=false
ssoProxyConnect=no
ssoLogOut=false
ssoLogOutRedirect=
logoutTargetURLParamname=
allow_debug=false
allowNewConnections=true
EndUserMonitoringEnabled=false
EndUserMonitoringURL=
applet_name=
enableJavascriptEvent=true
JavaScriptBlocksHeartBeat=false
idleTimeout=
separate_jvm=false

You will learn which parameters are not necessary over the long run. Just make sure that you will create all the new configurations by the dead end of “formsweb.cfg” file to avoid confusions. Please give extreme attention to the parameter “java_version=1.7+”. This means, you can only use JRE versions 1.7 and above (JRE7, 8 and other certified)

Once the formsweb.cfg is saved, we can proceed with editing/altering default.env file, that is in the same path. You can tell the forms runtime to look in this file to locate the forms runtimes. For example, I’ve all the compiled runtimes available at D:\12c folder for the application that I am trying to deploy/publish. The FORMS_PATH is pointed to it & other paths wherever I have applications (eg: mapped path \\RT04\OPMAN12C\main). Make sure each path is separated using a “;”

FORMS_PATH=D:\Weblogic\Middleware\Oracle_Home\forms;D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain\config\fmwconfig\components\FORMS\instances\forms1;D:\12c;\\RT04\OPMAN12C\main;\\RT04\OPMAN12C\OPMAN

Finally we have to edit/alter one more file, “Registry.dat” which controls how the LOVs appear/behave and many other values for the runtime. We will only configure LOV appearance and required field background color settings this time.

You should able to find “Registry.dat” file here:

D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain\config\fmwconfig\servers\WLS_FORMS\applications\formsapp_12.2.1\config\oracle\forms\registry
#
# Application level settings to control UI features
#
# app.ui.lovButtons=false
app.ui.lovButtons=true
# app.ui.requiredFieldVA=false
app.ui.requiredFieldVA=true
#    The background color is specified as an RGB triple.
# app.ui.requiredFieldVABGColor=255,0,0
app.ui.requiredFieldVABGColor=255,242,203

Please note, you can make these whole changes using Weblogic EM console. For me this is the fastest way.

Once whole these changes are made, you can start Weblogic server, start Weblogic FORMS server and try to run the application by entering the following URL on Microsoft Internet Explorer. Please note, no browsers other than Internet Explorer allow you to load JRE NPAPI client. We will discuss about using Java Webstart method by the end of this post.

One most important element you should cross verify at this point is whether the JRE installed is 32Bit or 64Bit. If you have installed the complete JDK before Weblogic setup, you should uninstall the JRE 8/higher version that is installed and install JRE 32Bit 7 or higher. Internet explorer will not load 64Bit JRE

http://<hostname>:7777/forms/frmservlet?config=balaji
http://rt04:7777/forms/frmservlet?config=balaji

Now, we will see how to get reports from the application. If you are planning to migrate from Developer 6i to 12c, there is going to be a huge effort involved. I am working with Oracle Applications R12 from last 11 years and have adapted much of the ideas from the application (menu architecture, report submission and many other). You will have to design a totally new approach for your reports, to cut it short. Plus, 12.2.1.4 is the last version of Oracle Reports (according to sources). Hence please start planning for Oracle BI or Crystal Reports integration for your reporting requirements in the future.

If you are switching from Forms/Reports 6i, please note, you will start using Web.Show_Document method for calling reports from Forms. With the given example, I am allowing users to select a report from list of values and storing the report executable value in to :CTRL.REPORT_NAME column and the calling “Web.Show_Document” method.

if (:CTRL.REPORT_NAME IS NOT NULL) then
Web.Show_Document('/reports/rwservlet?usr&desformat=PDF&destype=cache&report='||:CTRL.REPORT_NAME||'&paramform=Yes','_new');

else
	NULL;
end if;

You can pass the report name (‘ABCD.rdf’) for example for the parameter report within the url specified in Web.show_document method.

How to OPEN Forms Developer and Reports 12c??

While Oracle Forms 12c is available within the menu

accessing Report Developer may not be that straight forward. Basically report builder windows executable is wrapped inside multiple windows batch files & you will find the rwbuilder.bat file here:

D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain\reports\bin

I suggest you not to try to open the executable, as the wrapper setup environment for the executable to run. Interested, the .bat file has the following content:

@REM
@REM Copyright (c) 1999, 2008, Oracle and/or its affiliates.
@REM All rights reserved. 
@REM

@echo off 
@echo Starting Reports 12c Builder...
setlocal

set DOMAIN_HOME=D:\Weblogic\Middleware\Oracle_Home\user_projects\domains\base_domain

call %DOMAIN_HOME%\reports\bin\reports.bat

set COMPONENT_NAME=rptools1
set COMPONENT_CONFIG_PATH=%DOMAIN_HOME%\config\fmwconfig\components\ReportsToolsComponent\%COMPONENT_NAME%

set REPORTS_INSTANCE=%COMPONENT_CONFIG_PATH%
set CA_GPREFS=%COMPONENT_CONFIG_PATH%\tools\admin
set CA_UPREFS=%COMPONENT_CONFIG_PATH%\tools\admin


@echo on
start %ORACLE_HOME%\bin\rwbuilder.exe %*

@echo off
endlocal
@echo on

I think I’ve made a decent attempt to make it easier for a sample application deployment using Weblogic Server 12.2.1.4 & always ready to develop and provide a sample application for entirely newbies using Oracle’s sample schemas. Feel free to let me know through the comments 🙏