DBMS_APPLICATION_INFO.SET_CLIENT_INFO 不起作用

DBMS_APPLICATION_INFO.SET_CLIENT_INFO not working(DBMS_APPLICATION_INFO.SET_CLIENT_INFO 不起作用)
本文介绍了DBMS_APPLICATION_INFO.SET_CLIENT_INFO 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置 client_info 值以区分不同的客户端.

I need to set the client_info value to differentiate between different clients.

这些是我正在运行以测试的脚本.

These are the scripts that I am running to test.

第 1 步:系统架构

ALTER SYSTEM FLUSH SHARED_POOL;
ALTER SYSTEM FLUSH BUFFER_CACHE;

第 2 步:人力资源架构

Step 2:HR SCHEMA

EXEC DBMS_APPLICATION_INFO.SET_CLIENT_INFO(UTL_INADDR.GET_HOST_NAME );
EXEC DBMS_APPLICATION_INFO.SET_MODULE( 'CHECK','select' );

select                                      
    a.FIRST_NAME || ' ' || LAST_NAME AS FULL_NAME
from                                        
    HR.EMPLOYEES a                                      
where                                       
    a.DEPARTMENT_ID = '40'
;

第 3 步:系统架构

select
    *
from
    (
        select
           a.SQL_ID
          ,a.SQL_FULLTEXT
          ,to_char( a.LAST_ACTIVE_TIME,'DD-MON-YYYY HH24:MI:SS' )                                                                                as LAST_ACTIVE_TIME
          ,a.SERVICE
          ,b.SCHEMANAME
          ,b.CLIENT_INFO
          ,a.MODULE
          ,a.ACTION
        from
            GV$SQL a
        left outer join GV$SESSION b
        on
            (
                b.SQL_ID = a.SQL_ID
            )
        where
            a.EXECUTIONS != 0
    )
    c
where
    c.MODULE like '%CHECK%'
order by
    c.LAST_ACTIVE_TIME desc ;

MODULE 和 ACTION 列正在获取值,但 CLIENT_INFO 没有显示任何内容.

The MODULE and ACTION columns are getting the values but the CLIENT_INFO is not showing anything.

有什么我遗漏的吗?

更新:我也试过没有运气

EXEC DBMS_APPLICATION_INFO.SET_CLIENT_INFO( SYS_CONTEXT('userenv','ip_address') );
EXEC DBMS_APPLICATION_INFO.SET_CLIENT_INFO( '10.10.10.10' );

推荐答案

SET_CLIENT_INFO 与会话相关,而不是与单个 SQL 语句相关.

SET_CLIENT_INFO is related to a Session, not to a single SQL Statement.

这样做

第 1 步:系统架构

ALTER SYSTEM FLUSH SHARED_POOL;
ALTER SYSTEM FLUSH BUFFER_CACHE;

第 2 步:人力资源架构

Step 2:HR SCHEMA

EXEC DBMS_APPLICATION_INFO.SET_CLIENT_INFO(UTL_INADDR.GET_HOST_NAME );
EXEC DBMS_APPLICATION_INFO.SET_MODULE( 'CHECK','select' );

第 3 步:系统架构

SELECT
    a.SQL_ID
   ,a.CLIENT_INFO
   ,a.MODULE
   ,a.ACTION
   ,a.SCHEMANAME
   ,a.USERNAME
FROM
   V$SESSION a
WHERE
    a.MODULE = 'CHECK';

这篇关于DBMS_APPLICATION_INFO.SET_CLIENT_INFO 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

SQL to Generate Periodic Snapshots from Transactions Table(用于从事务表生成定期快照的SQL)
MyBatis support for multiple databases(MyBatis支持多个数据库)
Oracle 12c SQL: Missing column Headers in result(Oracle 12c SQL:结果中缺少列标题)
SQL query to find the number of customers who shopped for 3 consecutive days in month of January 2020(查询2020年1月连续购物3天的客户数量)
How to get top 10 data weekly (This week, Previous week, Last month, 2 months ago, 3 month ago)(如何每周获取前十大数据(本周、前一周、上个月、2个月前、3个月前))
Select the latest record for an Id per day - Oracle pl sql(选择每天ID的最新记录-Oracle pl SQL)