如何获取最后执行的SQL语句并在Oracle中绑定变量值 [英] How to get the last executed SQL statement and bind variable values in oracle

查看:338
本文介绍了如何获取最后执行的SQL语句并在Oracle中绑定变量值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了以下查询,以获取特定会话在oracle数据库中最后执行的SQL语句. SQL文本不包含绑定变量的实际值.如何获取绑定变量值以及SQL文本.

I have written the following query to get the last executed SQL statement in the oracle database for a particular session. The SQL text does not contain the actual value of the bind variables. How to get the bind variable values along with the SQL text.

SELECT * FROM v$SQLTEXT_WITH_NEWLINES WHERE address = 
  (SELECT prev_sql_addr FROM v$session WHERE audsid = userenv('SESSIONID'))
ORDER BY piece;

推荐答案

要获取绑定变量,您将必须使用下面的代码,而无需使用跟踪.

To get the bind variables you will have to use the code below, you dont need to use tracing.

SELECT * FROM v$sql_bind_capture WHERE sql_id='';

SELECT NAME,POSITION,DATATYPE_STRING,VALUE_STRING 
FROM v$sql_bind_capture WHERE sql_id='';

http://shaharear.blogspot.com/2009/02/find-bind-variable-value.html

这篇关于如何获取最后执行的SQL语句并在Oracle中绑定变量值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆