Oracle TKHCS_LOG_PKG
Version 21c

General Information
Library Note Morgan's Library Page Header
Which has the higher priority in your organization: Deploying a new database or securing the ones you already have? Looking for a website, and resources, dedicated solely to securing Oracle databases? Check out DBSecWorx.
Purpose The source code for the package specification and body are listed below but the origin of how it got into the 21.3 database, and what it is intended to accomplish, is still a mystery. That said, it doesn't look like especially robust well written code, unlike 'REDO_DIFF' and we expect will not be a permanent inhabitant of our domain.
AUTHID DEFINER
Dependencies
DBMS_SESSION TKHCS_LOG_CURRSESS_VIEW  
Documented No
First Available 21c
Security Model Owned by SYS with no privileges granted
Source: Formatted for clarity

Oracle ... please note ... you are still naming parameters with reserved words that are called out by your very own PL/SQL warnings. Please stop it!
cd $ORACLE_HOME
grep -ir "TKHCS_LOG_PKG"

did not identify a single file that contained this string.
CREATE OR REPLACE NONEDITIONABLE PACKAGE "SYS"."TKHCS_LOG_PKG" IS
 PROCEDURE init;
 PROCEDURE set_call(
  c1 IN VARCHAR2 DEFAULT NULL,
  c2 IN VARCHAR2 DEFAULT NULL,
  c3 IN VARCHAR2 DEFAULT NULL,
  c4 IN VARCHAR2 DEFAULT NULL,
  c5 IN VARCHAR2 DEFAULT NULL,
  c6 IN VARCHAR2 DEFAULT NULL,
  c7 IN VARCHAR2 DEFAULT NULL,
  c8 IN VARCHAR2 DEFAULT NULL);
 PROCEDURE include_allocs(inc IN NUMBER);
 PROCEDURE start_new_log;
 PROCEDURE set_sessionid(id IN NUMBER);
END;
/

CREATE OR REPLACE NONEDITIONABLE PACKAGE BODY "SYS"."TKHCS_LOG_PKG" IS
--=====================================================================
 PROCEDURE init IS
 BEGIN
   set_call();
   include_allocs(1);
 END;
--=====================================================================
 PROCEDURE set_call(
  c1 IN VARCHAR2 DEFAULT NULL,
  c2 IN VARCHAR2 DEFAULT NULL,
  c3 IN VARCHAR2 DEFAULT NULL,
  c4 IN VARCHAR2 DEFAULT NULL,
  c5 IN VARCHAR2 DEFAULT NULL,
  c6 IN VARCHAR2 DEFAULT NULL,
  c7 IN VARCHAR2 DEFAULT NULL,
  c8 IN VARCHAR2 DEFAULT NULL) IS
 BEGIN
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call1', c1);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call2', c2);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call3', c3);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call4', c4);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call5', c5);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call6', c6);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call7', c7);
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'call8', c8);
 END;
--=====================================================================
 PROCEDURE include_allocs(inc IN NUMBER) IS
 BEGIN
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'allocs', TO_CHAR(inc));
 END;
--=====================================================================
 PROCEDURE start_new_log IS
  max_order_num NUMBER;
 BEGIN
   -- Find the max order_num from tkhcs_log_currsess_view
   SELECT MAX(order_num)
   INTO max_order_num
   FROM tkhcs_log_currsess_view;

   -- If max_order_num is null it means that either there are no log
   -- entries for this session, or that there are no log entries for the
   -- session since the last call to this function. In either case, we
   -- want to keep the value that is there, so only set the context value when not null.
   IF max_order_num IS NOT NULL THEN
     -- Call set_context to set the max order number
     dbms_session.set_context('TKHCS_LOG_CTX_SYS','start_order_num', max_order_num);
   END IF;
 END;
--=====================================================================
 PROCEDURE set_sessionid(id IN NUMBER) IS
 BEGIN
   dbms_session.set_context('TKHCS_LOG_CTX_SYS', 'sessionid', id);
 END;
END;
/
Source {ORACLE_HOME}/rdbms/admin/
Subprograms
 
INCLUDE_ALLOCS (new 21c)
Sets a context tkhcs_log_pkg.include_allocs(inc IN NUMBER);
exec tkhcs_log_pkg.include_allocs(4);

PL/SQL procedure successfully completed.

SELECT sys_context('TKHCS_LOG_CTX_SYS', 'ALLOCS')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','ALLOCS')
------------------------------------------
4
 
INIT (new 21c)
Initializes the package tkhcs_log_pkg.init;
exec tkhcs_log_pkg.init;

PL/SQL procedure successfully completed.

SELECT sys_context('TKHCS_LOG_CTX_SYS', 'ALLOCS')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','ALLOCS')
------------------------------------------
1


SELECT sys_context('TKHCS_LOG_CTX_SYS', 'CALL1')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','CALL1')
-----------------------------------------


SELECT sys_context('TKHCS_LOG_CTX_SYS', 'CALL2')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','CALL2')
-----------------------------------------
 
 
SET_CALL (new 21c)
Sets contexts tkhcs_log_pkg.set_call(
  c1 IN VARCHAR2 DEFAULT NULL,
  c2 IN VARCHAR2 DEFAULT NULL,
  c3 IN VARCHAR2 DEFAULT NULL,
  c4 IN VARCHAR2 DEFAULT NULL,
  c5 IN VARCHAR2 DEFAULT NULL,
  c6 IN VARCHAR2 DEFAULT NULL,
  c7 IN VARCHAR2 DEFAULT NULL,
  c8 IN VARCHAR2 DEFAULT NULL);
exec tkhcs_log_pkg.set_call('ZZYZX');

PL/SQL procedure successfully completed.

SELECT sys_context('TKHCS_LOG_CTX_SYS', 'CALL1')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','CALL1')
-----------------------------------------
ZZYZX


SELECT sys_context('TKHCS_LOG_CTX_SYS', 'CALL2')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','CALL2')
-----------------------------------------
 
 
SET_SESSIONID (new 21c)
Sets a context tkhcs_log_pkg.set_sessionid(id IN NUMBER);
exec tkhcs_log_pkg.set_sessionid(42);

PL/SQL procedure successfully completed.

SELECT sys_context('TKHCS_LOG_CTX_SYS', 'SESSIONID')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','SESSIONID')
--------------------------------------------
42
 
START_NEW_LOG (new 21c)
Sets a context tkhcs_log_pkg.start_new_log;
exec tkhcs_log_pkg.start_new_log;

PL/SQL procedure successfully completed.

SELECT sys_context('TKHCS_LOG_CTX_SYS', 'START_ORDER_NUM')
FROM dual;

SYS_CONTEXT('TKHCS_LOG_CTX_SYS','START_ORDER_NUM')
---------------------------------------------------
 

Related Topics
Built-in Functions
Built-in Packages
Database Security
SYS_CONTEXT
What's New In 19c
What's New In 20c-21c

Morgan's Library Page Footer
This site is maintained by Dan Morgan. Last Updated: This site is protected by copyright and trademark laws under U.S. and International law. © 1998-2021 Daniel A. Morgan All Rights Reserved
  DBSecWorx