#!/usr/bin/ksh
# whatdba_option ()
#------------------------------------------------------------------------------#
#    Module Name:  whatdba_option   (c) May 2012                               #
#                                                                              #
#    Purpose:      Report on the v\$option Features                            #
#                  Oracle Audit and Oracle Licensed Management Services (LMS)  #
#                  will compare the v\$option View and                         #
#                  the Oracle-Customer's License Agreement in order to         #
#                  evauluate some of the License/Feature violations.           #
#                                                                              #
#    Maintenance                                                               #
#    Date          Author        Description                                   #
#    -----------   ------------  --------------------------------------------  #
#    12-Apr-2019   M.Barone      Module design/creation                        #
#------------------------------------------------------------------------------#
{
        DIRNAM=$(dirname $0)
        ORASID=$(echo $CONTEXT_NAME | cut -f1 -d'_')
        HNAME=$(uname -n)

        clear
        #----------------------------------------------------------------------#
        #  TEST:  Number ($#) of arguments passed to this function?            #
        #----------------------------------------------------------------------#
        if      [ $# = 0 ]
        then
            clear
            echo
            echo  " #--------------------------------------------------------#"
            echo  " # whatdba_option:               Oracle v\$option Features #"
            echo  " #--------------------------------------------------------#"
            echo

            print
            echo  " Connecting as SYSDBA"
            sleep 2

            clear
        else
            SEARCH=$1
            clear
        fi

        ORANAM=${ORASID}

#------------------------------------------------------------------------------#
#  SQL*Plus ("Here-Document")                                                  #
#------------------------------------------------------------------------------#
sqlplus  -s  /nolog  <<-END_FILE

	CONNECT  /  as  SYSDBA

        clear   BREAKS
        clear   BUFFER
        clear   COLUMNS
        clear   COMPUTES
        clear   SCREEN
        clear   SQL
        clear   TIMING

        set     feedback        off
        set     flush           on
        set     heading         on
        set     pause           off
        set     space           1
        set     termout         on
        set     verify          on
        set     linesize        80
        set     pagesize        999

        SPOOL /tmp/whatdba_option$$.txt


	PROMPT	#--------------------------------------------------------#
	PROMPT	# Oracle Diagnostic Package and Oracle Tuning Package:   #
	PROMPT	#   DIAGNOSTICS License is needed for AWR-Reports.       #
	PROMPT	#   TUNING      License is needed for ASH-Reports.       #
	PROMPT	#--------------------------------------------------------#
        TTITLE  CENTER  '${ORANAM} (${HNAME}) Diagnostics and Tuning Packages' -
									skip 2

        COLUMN  NAME_COL_PLUS_SHOW_PARAM	FORMAT A30  Heading 'Parameter'
        COLUMN  TYPE				FORMAT A6   Heading 'Type'
        COLUMN  VALUE_COL_PLUS_SHOW_PARAM	FORMAT A38  Heading 'Value'

	SHOW PARAMETER PACK

	PROMPT
	PROMPT
	PROMPT	#--------------------------------------------------------#
	PROMPT	# Oracle DBA Feature Usage Statistics:                   #
	PROMPT	#   Oracle Audit and Oracle Licensed Management Services #
	PROMPT	#   compares the v\$option View and                       #
	PROMPT	#   the Oracle-Customer's License Agreement in order to  #
	PROMPT	#   evaulate some of the License/Feature violations.     #
	PROMPT	#--------------------------------------------------------#
        TTITLE  CENTER  '${ORANAM} (${HNAME}) Oracle DB V\$Option Features'   -
									skip 2

        COLUMN  NAME			FORMAT A55    Heading 'DB FeatureName'
        COLUMN  VALUE  			FORMAT A6     Heading 'Value'

        SELECT	PARAMETER  name,
		VALUE
        FROM	v\$option
        ORDER BY  PARAMETER;

EXIT;

END_FILE


print
print "Please see /tmp/whatdba_option$$.txt"
print
}