Is it possible to get a string containing a list of the local variables names and their values at any point in time to aid in debugging (i.e. add to a row in the log table of the database as a text string)?
-
2Certainly it is somehow possible because there is debuging mode in Oracle DB, but I suggest you to use some IDE like PL/SQL Developer or Oracle SQL developer which have built in debugging window which allows you to do exactly this - to set break point, to step in, to see current values of variables, etc.Martina– Martina2015-11-22 22:58:51 +00:00Commented Nov 22, 2015 at 22:58
-
Personally I don't use debuggers but logging. In PL/SQL scope that's a dedicated log table, small amount of supporting PL/SQL code, conditional compilation and a lot of nicely formatted "print"-statements.user272735– user2727352015-11-23 08:12:44 +00:00Commented Nov 23, 2015 at 8:12
-
Is there a generic way to grab all local variables to log themEd Heal– Ed Heal2015-11-23 08:17:09 +00:00Commented Nov 23, 2015 at 8:17
-
1Have you looked at the DBMS_DEBUG PL/SQL Package? Could possibly help, but too involved to discuss here. See the PL/SQL Packages and Types Reference (assuming 11g)DBug– DBug2015-11-24 21:14:34 +00:00Commented Nov 24, 2015 at 21:14
-
Do you have example of your thoughts?Muhammad Muazzam– Muhammad Muazzam2015-11-26 07:22:25 +00:00Commented Nov 26, 2015 at 7:22
2 Answers
Is not possible to obtain a String with debug information, however using Sql Developer (Oracle free tool) you can DEBUG your pl/sql as usual likewise any other debug tool for another language including the VALUE for any variable.
This is taken from its documentation:
HTH
1 Comment
No, it is not possible.
DBMS_DEBUG can inspect PL/SQL variables, but it requires that the running session suspend and that a second session attach to it to perform the inspection.
I've thought about creating an API to spawn a second session (via DBMS_SCHEDULER) which would stop the calling session, inspect it, restart it, and report back.
That'd be very involved and I'm not sure it'd be a supported use case of DBMS_DEBUG.
Short of that, there is nothing.
