Finding the values of Query bind variables  (Oracle 10g)

This is a nice feature that is made available in Oracle 10g.  if you run a query using bind variable, it is not easy task to trace back what value were there when the query was executed.

For tracing, troubleshooting and tuning exercises, it can become really important to know the actual values that the query was using. For example

Select * from EMP where empno =:B1

You could find such statements in trace files and SQL_AREA

 

select
  sql_id,   t.sql_text SQL_TEXT,
  b.name VALUE_NAME,
  b.value_string BIND_VALUE
from   v$sql t    join v$sql_bind_capture b     -- do not worry, just normal join
  using (sql_id)
where
  b.value_string is not null
  and sql_id ='3387zvbvz48qd'

you can get sql_id from v$sqlarea