The DBMS_APPLICATION_INFO package can work with Trace and SQL trace tools to record the names of modules or transactions that are being executed in databases. You can trace the performance of the modules and debug the modules based on the records.

Applications allow system administrators and performance optimization experts to trace performance by module. System administrators can also use these records to track the resource usage of the modules.

PolarDB provides the following DBMS_APPLICATION_INFO subprograms:

  • READ_CLIENT_INFO: reads the value of the client_info field in the current session.
  • READ_MODULE: reads the values of the module and action fields in the current session.
  • SET_ACTION: sets the name of the action that is being executed in the current module.
  • SET_CLIENT_INFO: sets the client_info field in the session.
  • SET_MODULE: sets the name of the module that is running to a new module.

READ_CLIENT_INFO

Syntax
DBMS_APPLICATION_INFO.READ_CLIENT_INFO (
   client_info OUT VARCHAR2);
Parameters
Parameter Description
client_info The last client information value provided by the current session to the SET_CLIENT_INFO procedure.

READ_MODULE

Syntax
DBMS_APPLICATION_INFO.READ_MODULE ( 
   module_name OUT VARCHAR2, 
   action_name OUT VARCHAR2);
Parameters
Parameter Description
module_name The last value that the module name is set to after the current session calls SET_MODULE.
action_name The last value that the module name is set to after the current session calls SET_MODULE or SET_Action.

SET_ACTION

Syntax
DBMS_APPLICATION_INFO.SET_ACTION (
   action_name IN VARCHAR2);
Parameters
Parameter Description
action_name The name of the action that is being executed in the current module. When the current action terminates, if a next action follows, call this procedure by using the name of the next action. If no actions follow, call NULL.

A name whose length is longer than 64 bytes is truncated.

SET_CLIENT_INFO

Syntax
DBMS_APPLICATION_INFO.SET_CLIENT_INFO (
   client_info IN VARCHAR2);
Parameters
Parameter Description
client_info Additional information about the client application.

SET_MODULE

Syntax
DBMS_APPLICATION_INFO.SET_MODULE ( 
   module_name IN VARCHAR2, 
   action_name IN VARCHAR2);
Parameters
Parameter Description
module_name The name of the running module. When the module terminates, if a next module follows, call this procedure by using the name of the next module. If no modules follow, call NULL. A name whose length is longer than 64 bytes is truncated.
action_name The name of the action that is being executed in the current module. If you do not want to specify an action, set this parameter to NULL. A name whose length is longer than 64 bytes is truncated.

Examples

select pid  ,client_info,module,action from polar_get_app_info;

exec dbms_application_info.set_client_info('client2');
exec dbms_application_info.set_module('module2','action');
exec dbms_application_info.set_action('action2');

select pid  ,client_info,module,action from polar_get_app_info;

 DECLARE
 _clinent TEXT;
 _mod_name TEXT;
 _act_name TEXT;
 BEGIN

 dbms_application_info.read_client_info(_clinent);
 dbms_application_info.read_module(_mod_name,_act_name);
 raise notice 'client_info is : "%", module value is "%", action value is "%"', _clinent, _mod_name, _act_name;
 END;