Is there a way to get the sql_id/child number/plan hash after calling OCIStmtExecute()? I can’t see it in OCIAttrGet().
NOTE: As a regular user who can’t see v$session – if I can it’s as simple as executing select prev_sql_id, prev_child_number from v$session where sid=sys_context('USERENV', 'SID')
Thanks!
There is no means to get the sql_id or the plan_hash_value with oci or sys_context. However it might be a good idea to file an enhancement request with oracle support to add that feature.
There is the possibility to trace all sql statements of a session with the following statement:
Depending on the trace level more or less trace is generated (Level 4 and 8 create less information). To turn off the tracing execute
The other option is to create a function to compute the sql_id yourself
Of course this is error prone as oracle might change the mechanism to calculate the sql_id in the future.