1

I would like to decode DATE value written as varchar2 in DBA_HIST_SQLBIND, but unsure where to look for the mask required to decode it properly,

SYS> select value_string from DBA_HIST_SQLBIND where datatype_string='DATE' fetch first 4 rows only;

VALUE_STRING
--------------------------------------------------------------------------------
08/03/2025 13:04:27
08/03/2025 13:04:27
08/03/2025 13:03:57
08/03/2025 13:05:27

SYS> select value from NLS_DATABASE_PARAMETERS where parameter='NLS_DATE_FORMAT';

VALUE
----------------------------------------------------------------
DD-MON-RR

Is it safe to assume the mask is always MM/DD/YYYY HH24:MI:SS for DBA_HIST_SQLBIND.value_string regardless of NLS setting?

1 Answer 1

2

Yes, that's correct. DBA_HIST_SQLBIND captures the contents of v$sql_bind_capture, which represents all datatypes as strings in the VALUE_STRING column. I just checked multiple databases with various NLS_DATE_FORMAT settings and all of them - going back to version 10.1, format dates as a string with model MM/DD/YYYY HH24:MI:SS. Keep in mind that NLS_DATE_FORMAT is intended to format implicit date-to-string conversions done by users, and is inherited from the system level if not overridden by the session. Any session has the right to override it as desired. Oracle's internal performance views are no exception - they've been doing that for a long time with FIRST_LOAD_TIME in v$sql where they actually insert a literal \ between the date and time; v$sql_bind_capture is just another example where dates-as-strings in performance views can show up however the original programmer thought best. Since they are strings as they come to us in the view, not dates, theNLS_DATE_FORMAT setting is irrelevant.

And, if you think about it, most NLS_DATE_FORMAT settings default to something like DD-MON-RR, without a time portion. If the programmer who wrote the view had used that format to populate a string column, it would hide the time portion from us, and that's an important piece of information that shouldn't be hidden. So really they had no choice but to hard-code a date format conversion that does show the time.

Also, FYI, bind capture is meant for performance diagnostics (investigating cursor sharing, histogram skew, etc..); it is merely a sampling, not exhaustive. Capturing binds for every execution would be inordinately expensive. If you do need the precise binds of a specific execution, you'd need to 10046 trace it at level 4 or higher and examine the trace file. There's no performance view for that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.