The ASH_REPORT_TEXT function is used to generate an ASH report for a specified time period and return the report content in CLOB format.
Unlike the ASH_REPORT procedure, which outputs the report line by line via DBMS_OUTPUT, ASH_REPORT_TEXT directly returns the complete report text, making it convenient to retrieve the report content in SQL queries or applications.
Applicability
This content applies only to OceanBase Database Enterprise Edition. OceanBase Database Community Edition does not support it.
Syntax
FUNCTION ASH_REPORT_TEXT(L_BTIME IN TIMESTAMP,
L_ETIME IN TIMESTAMP,
SQL_ID IN VARCHAR2 DEFAULT NULL,
TRACE_ID IN VARCHAR2 DEFAULT NULL,
WAIT_CLASS IN VARCHAR2 DEFAULT NULL,
SVR_IP IN VARCHAR2 DEFAULT NULL,
SVR_PORT IN NUMBER DEFAULT NULL,
TENANT_ID IN NUMBER DEFAULT NULL,
REPORT_TYPE IN VARCHAR2 DEFAULT 'text')
RETURN CLOB;
Parameters
Parameters |
Note |
|---|---|
| L_BTIME | Sampling start time. |
| L_ETIME | End time of sampling. |
| SQL_ID | SQL Statement to SampleSQL_ID, if not specified or set toNULLindicates no limit.SQL_ID. |
| TRACE_ID | SQL Statement to SampleTRACE_ID, if not specified or set toNULLindicates no limit.TRACE_ID. |
| WAIT_CLASS | The type of event to be sampled.WAIT_CLASSValid values:GV$ACTIVE_SESSION_HISTORY.WAIT_CLASSThe value of this field. If left empty or set toNULLindicates that the wait type is unrestricted. |
| SVR_IP | The IP address of the node for generating the ASH report. If this parameter is not specified or if the value is invalid, the system will automatically select a node to generate the ASH report.NULLindicates that the IP address is not restricted. |
| SVR_PORT | The port number of the node for generating the ASH report. If this parameter is not specified or the value isNULLindicates that the port is not limited. |
| TENANT_ID | Specifies the tenant ID for generating the ASH report. If this parameter is not specified or is set to a value other thanNULLindicates no limit.TENANT_ID. |
| REPORT_TYPE | Report type. Valid values:TEXTandHTMLType. If not specified, the default value isTEXTType. |
Return value
Returns a CLOB type value that contains the ASH report text for the specified time period.
Usage instructions
To obtain ASH-related information, query the oceanbase.GV$ACTIVE_SESSION_HISTORY view.