绑定变量转换

  今天是2014-01-23,

   看到一个同事写的一个sql绑定变量转换挺有意思,再次转载一下:

--找到SQL_ID中的最后一个字值
select * from v$sql where sql_id=‘0z25ncfbunafk‘
--转化对应的绑定变量值
SELECT position,value_string
FROM TABLE(DBMS_SQLTUNE.EXTRACT_BINDS(‘BEDA0A20050052366ECE000307F0012003540CB9E2CFCBBDD3C8EBBACFCDACF0021604C32C6256F0012003540CB9E2CFCBBDD3C8EBBACFCDAC‘));
--如果v$sql中不存在,可以用此方法获取绑定变量值
select dbms_sqltune.extract_bind(bind_data, 1).value_string || ‘-‘ ||
dbms_sqltune.extract_bind(bind_data, 2).value_string || ‘-‘ ||
dbms_sqltune.extract_bind(bind_data, 3).value_string || ‘-‘ ||
dbms_sqltune.extract_bind(bind_data, 4).value_string || ‘-‘ ||
dbms_sqltune.extract_bind(bind_data, 5).value_string || ‘-‘ ||
dbms_sqltune.extract_bind(bind_data, 6).value_string
from sys.wrh$_sqlstat
where sql_id = ‘0z25ncfbunafk‘
--查看对应的SQL
SELECT * FROM SYS.WRH$_SQLSTAT WHERE SQL_ID=‘0z25ncfbunafk‘;
SELECT * FROM SYS.WRH$_SQL_BIND_METADATA WHERE SQL_ID=‘0z25ncfbunafk‘;
select t.sql_id,t.name,t.position,t.datatype_string,t.value_string,t.last_captured from v$sql_bind_capture t where sql_id=‘f78cpkf8cc003‘;

绑定变量转换

上一篇:“二次深访”UML


下一篇:Word Search