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

Applications allow system administrators and performance optimization experts to track 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 the name of a new module.

READ_CLIENT_INFO

Syntax

DBMS_APPLICATION_INFO.READ_CLIENT_INFO (
   client_info OUT VARCHAR2);

Parameters

Parameter Description
client_info Specifies the information of the last client. The information is provided by the current session for the SET_CLIENT_INFO stored procedure.

READ_MODULE

Syntax

DBMS_APPLICATION_INFO.READ_MODULE ( 
   module_name OUT VARCHAR2, 
   action_name OUT VARCHAR2);

Parameters

Parameter Description
module_name Specifies the last value to which the module name is set after the current session calls SET_MODULE.
action_name Specifies the last value to which the module name is set 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 Specifies the name of the action that is being executed in the current module. When the current action is terminated, the name of the next action is used to call the stored procedure if the next action exists. If the next action does not exist, call NULL.
Note Bytes in excess of 64 bytes are truncated for the action name.

SET_CLIENT_INFO

Syntax

DBMS_APPLICATION_INFO.SET_CLIENT_INFO (
   client_info IN VARCHAR2);

Parameters

Parameter Description
client_info Specifies the 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 Specifies the name of the running module. When the current module is terminated, the name of the next module is used to call the stored procedure if the next action exists. If the next module does not exist, call NULL.
Note Bytes in excess of 64 bytes are truncated for the module name.
action_name Specifies 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.
Note Bytes in excess of 64 bytes are truncated for the action name.

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;