Thanks for the question, Paras.
Asked: July 06, 2017 - 8:47 am UTC
Last updated: March 15, 2021 - 5:03 am UTC
Version: 11.2.0.4
Viewed 50K+ times! This question is
You Asked
Hi,
We are using the 11.2.0.4 database enterprise edition , and due to the application performance need we had to set CURSOR_SHARING=FORCE, as application was not able to use bind variables.
When i try to generate the PLAN for sql_id using OR when try to get the SQL text the values listed between "Select...from" get replaced by the system generated bind variables as expected behavior. the bind values replaced in "where" clause can be foun by querying view V$SQL_BIND_CAPTURE/DBA_HIST_SQLBIND, but this view doesn't show the bind values which were in between "SELECT...FROM".
The question i have is is there any view or WAY where i can find those bind values which are replaced between "Select....from" in sql statement/
For Example:-
select
cola,
colb,
to_char(colc, :"SYS_B_00"),
(cold / :"SYS_B_01") ,
(cole) / :"SYS_B_02",
decode(colf, :"SYS _B_03", :"SYS_B_04", :"SYS_B_05", :"SYS_B_06")
from
tablea
where
cola != :"SYS_B_08"
and colb = :"SYS_B_09"
and colc between trunc(sysdate - :"SYS_B_10") and sysdate
order by
ttd.transactiondate desc;
Now, when i query view GV$SQL_BIND_CAPTURE i don't see values for bind from 1 to 7, how can i find those?
select INST_ID,SQL_ID,POSITION,NAME,VALUE_STRING from GV$SQL_BIND_CAPTURE where sql_id='g0fdjxptp64bh' and inst_id=1 order by POSITION
INST_ID SQL_ID POSITION NAME VALUE_STRING
---------- ------------- ---------- ------------------------------ ------------
1 g0fdjxptp64bh 1 :SYS_B_00 --> NO VALUE
1 g0fdjxptp64bh 2 :SYS_B_01
1 g0fdjxptp64bh 3 :SYS_B_02
1 g0fdjxptp64bh 4 :SYS_B_03
1 g0fdjxptp64bh 5 :SYS_B_04
1 g0fdjxptp64bh 6 :SYS_B_05
1 g0fdjxptp64bh 7 :SYS_B_06
1 g0fdjxptp64bh 8 :SYS_B_07 9999999999
1 g0fdjxptp64bh 9 :SYS_B_08 Y
1 g0fdjxptp64bh 10 :SYS_B_09 XXX
1 g0fdjxptp64bh 11 :SYS_B_10 10
Thanks.
and Connor said...
Just an aside, dbms_xplan lets you look at binds as well
select * from table (dbms_xplan.display_cursor('[mysqlid]',[child], format => 'TYPICAL +PEEKED_BINDS'));
but in any event, V$SQL_BIND_CAPTURE is not a "complete" way of monitoring binds - it's too expensive for us to populate that for every execution, so its a sampled data set.
If you are licensed for sql monitoring, you can use V$SQL_MONITOR to get the binds, but similarly, this will be for queries that are being monitored (aka, long running queries only by default).
If you really want to get *every* bind, then you pretty much have to resort to low level tracing via DBMS_MONITOR with 'binds' set to true.
Rating
(3 ratings)
Is this answer out of date? If it is, please let us know via a Comment