I did want to write a PL/SQL debugger
change_on_install, March 01, 2002 - 8:24 am UTC
i want to write a PL/SQL develop tool just
like DBArtisan. i use delphi and have almost
completed. but i have no experience on
DBMS_DEBUG,can you give me a example, or any
other advices is also welcome.
best regards,
change_on_install
Error While Executing alter session plsql_debug = true
Kumar, April 16, 2002 - 5:53 pm UTC
I am getting error while executing
alter session plsql_debug = true
Insufficent privileges
What type of privilige is needed to execute the abouve statement
Thanks
Kumar
April 16, 2002 - 9:50 pm UTC
you need ALTER SESSION
ops$tkyte@ORA817DEV.US.ORACLE.COM> drop user a cascade;
User dropped.
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> grant create session to a identified by a;
Grant succeeded.
ops$tkyte@ORA817DEV.US.ORACLE.COM>
ops$tkyte@ORA817DEV.US.ORACLE.COM> @connect a/a
ops$tkyte@ORA817DEV.US.ORACLE.COM> set termout off
a@ORA817DEV.US.ORACLE.COM> REM GET afiedt.buf NOLIST
a@ORA817DEV.US.ORACLE.COM> set termout on
a@ORA817DEV.US.ORACLE.COM> alter session set plsql_debug=true;
ERROR:
ORA-01031: insufficient privileges
a@ORA817DEV.US.ORACLE.COM> @connect /
a@ORA817DEV.US.ORACLE.COM> set termout off
ops$tkyte@ORA817DEV.US.ORACLE.COM> REM GET afiedt.buf NOLIST
ops$tkyte@ORA817DEV.US.ORACLE.COM> set termout on
ops$tkyte@ORA817DEV.US.ORACLE.COM> grant alter session to a;
Grant succeeded.
ops$tkyte@ORA817DEV.US.ORACLE.COM> @connect a/a
ops$tkyte@ORA817DEV.US.ORACLE.COM> set termout off
a@ORA817DEV.US.ORACLE.COM> REM GET afiedt.buf NOLIST
a@ORA817DEV.US.ORACLE.COM> set termout on
a@ORA817DEV.US.ORACLE.COM> alter session set plsql_debug=true;
Session altered.
a@ORA817DEV.US.ORACLE.COM>
Thx tom for quick response
Kumar, April 17, 2002 - 8:31 am UTC
Is there a Demo tool available which has implemented the debugger
Mani, January 10, 2003 - 2:00 pm UTC
Is there a tool available, which I can use to debug by PL/SQL procedures.
Debugging package
Arun Mathur, January 29, 2004 - 10:38 am UTC
Hello Tom,
In your Expert One On One Oracle book, you mention a debug package which you and Christopher Beck wrote. I checked the WROX site for it, but didn't get any luck. Do you know of any site(s) which may have it?
As always, thank you.
Arun
January 29, 2004 - 1:25 pm UTC
it is on the apress.com website for that book (wrox went under and got sold in bits)
Nevermind - I just found it
Arun Mathur, January 29, 2004 - 10:40 am UTC
A reader, April 15, 2004 - 10:20 am UTC
Tom,
How can I find out which users are using dbms_debug package.
Will your script showsql.sql do that.
Thanks.
April 15, 2004 - 10:40 am UTC
show sql shows what they are currently running (doubtful you would catch a call -- you would generally see what they are debugging)
dba_ddl_locks can be useful to see what sessions have references to what objects.
debug
Raaghid, September 23, 2004 - 9:45 am UTC
I am following the tips you have given in writing PLSQL (Write package instead of proc., use correct literals etc etc.. Ref: you both books + this forum). Can you pl give tips on "how to debug the plsql" (Both general and link if any)
September 24, 2004 - 8:38 am UTC
Effective Oracle by Design goes through that with "the tools I use" (jdev has a source level debugger).
Also, in beginning Oracle Programming (Apress) there is a "debug.f" package -- if you goto my home page and goto "presentations" (Link near bottom), and get the BROUG slides -- it has the packge and a demo of using it. It is great for creating your own TRACE files.
debug plsql
Raaghid, September 23, 2004 - 9:49 am UTC
I am following the tips you have given in writing PLSQL (Write package instead of proc., use correct literals etc etc.. Ref: you both books + this forum). Can you pl give tips on "how to debug the plsql" (Both general and link if any)
how to trap the bug in function
Safrin, March 05, 2005 - 7:17 am UTC
I was asked by interviewer recently as follows:
"In a production environment user complains that the function returns result of 1256 instead of 1256.60." - How would you DEBUG the same. (Here, I have given exact content what the interviewer said)
I have answered like this:
1. Modify package/proc/function to get the output in different states using "dbms_output"
2. Modify package/proc/function to get the output in different states using "UTL FILE"
3. The method given in the "Begining oracle programming" (debug package tool)
But he (interviewer) is NOT at all impressed and asked me, how can you replicate the same in production when it is going on production.
CAN YOU PLEASE SHARE YOUR THOUGHTS IN THIS QUESTION. How should I answer for this question.
March 05, 2005 - 7:40 am UTC
It was a not so good question maybe, I mean -- lots to be inferred.
Did you write the code in a good way? That is, did you make the coders instrument it? If so, just turn on your diagnostics and lets see the inputs and outputs. You know, just like we do when the database is having a problem and we need to diagnose it. Defensive coding starts at home.
But ok, lets say -- no, no you didn't. I'd go into test and see if it reproduces. We must reproduce the issue, if you cannot -- well, we need to get to a point where we can. If test doesn't reproduce the issue, must be the unique set of data in production, so have the DBA restore that over here -- as we don't like to play in production (and since your code isn't already littered with debug.f statements -- we'll have to fix that once you hire me on :)
So, if we restore -- it should reproduce -- but if not, it could be something unique about the production environment -- might not even be the database, could be the client tool. Perhaps the end user set numformat 999999 in their login.sql or set a format in whatever tool they are using
In short, given I don't know your environment, your application, you level of instrumentation, your tools, your client applications -- I'd be guessing. I'd be asking lots of questions -- but the first goal would be to get it to reproduce in a test environment so we can find out what is wrong (if nothing obvious in the production environment was wrong -- I'd be asking about the client tools and such before diving into anything too deep, need more facts)
dbms_debug package - permissions required
Tim, July 20, 2005 - 5:28 pm UTC
I am attempting to use the dbms_debug with Oracle 9.2.0.4.0 through a third party application which has implemented this feature.
Your previous post said that the only system priv which was required was "alter session" priv.
However, I have received the following error and am wondering if perhaps additional privs may be required?
ORA-23322: Privilege error accessing pipe
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 86
ORA-06512: at "SYS.DBMS_PIPE", line 115
ORA-06512: at "SYS.PBREAK", line 256
ORA-06512: at "SYS.PBSDE", line 58
ORA-06512: at "SYS.DBMS_DEBUG", line 211
ORA-06512: at
(error stops there - not like I just stopped typing - character count on the error is 247 - so it may have hit some limit with the app or something - I hope enough there to be useful...)
Any thoughts you may have on this would be greatly appreciated.
Thanks.
July 21, 2005 - 3:46 pm UTC
you should not, I see nothing remotely similar in the problem database at all.
I'll have to refer you to support.
No Debugging till object is checked out
Laxman Kondal, August 25, 2005 - 4:34 pm UTC
Hi Tom
This is not an unusual problem but I am trying to figure out is there any better way to control this issue.
We have 5 active Oracle developers and 6 Java developers. Every one logs on as same user OPDEV and store procedures are mostly packages, involve around 4000+ lines of code each. Most package will have to call other package.
Developers are creating/modifying package in TOAD or PL-SQL Developer procedure editor. Once code is in editor it can be there for long time and in the mean time another developer gets the same code in his procedure editor and makes some changes and compiles it.
Now the first user cant see the changes made by second user unless refresh it, which in most case never be. So the net result is, changes made by second user is lost and totally confused why its not showing the new results which was dead certain to show up - results to more frustration.
I create a before alter on schema trigger to check if same procedure is locked by any one or not. If not locked then throw an error:
RAISE_APPLICATION_ERROR(-20001, ora_dict_obj_name||' not locked for ddl') and then this user need to make call to procedure:
Lock_Code( p_obj_name IN VARCHAR2,
p_lock IN CHAR DEFAULT 'Y')
and this inserts a record in table:
CREATE TABLE Ddl_Check_Out_Check_Ins
(
obj_name VARCHAR2(50) NOT NULL,
obj_type VARCHAR2(50) NOT NULL,
ddl_by VARCHAR2(30) NOT NULL,
ddl_begin VARCHAR2(30) NOT NULL,
machine VARCHAR2(30),
program VARCHAR2(30) NOT NULL,
terminal VARCHAR2(30) NOT NULL,
ddl_end VARCHAR2(30)
)
as long as there is a record in this table and ddl_end is null no other user can compile that object.
I have after create on schema trigger which takes care of new procedure by checking is object doesnt exists then enters the record in to the table and user continues without interruption.
Up to this it works fine but when user wants to debug it first throws an error from before alter on schema trigger:
RAISE_APPLICATION_ERROR(-20012, ora_dict_obj_name||' not locked for DDL');
and still continues with debugging.
Problem is if user has made some code change and straight hits debug its going to compile and make change to the original code.
I used DBMS_DEBUG.DEBUG_OFF it throws an error and still continues with debugging:
.....
EXCEPTION
--no one has lock on this code
WHEN NO_DATA_FOUND THEN
dbms_debug.debug_off;
RAISE_APPLICATION_ERROR(-20012, ora_dict_obj_name||' not locked for DDL');
END;
Since all logs on as same user OPDEV but have different machine, SID, serial# - is there any way to stop debugging if no record found in Ddl_Check_Out_Check_Ins table.
I used dba_ddl_locks to get the session_id and name but this turns out be for the before alter trigger name and not the object being debugged.
Is there any table/view in Oracle9iR2, I can get SID and Serial# and kill that session in before alter trigger before it compiles that object for debugging.
Or do you suggest any other method to not to allow debug unless object is locked.
Thanks and regards.
August 25, 2005 - 6:46 pm UTC
you need a thing called source code control, it is this thing whereby you don't read the code out of the dictionary, but you check it out.
(not being sarcastic, really - this is source code control, treat your PLSQL like they treat their java code)
Sample code usign dbms_debug package
maverick, August 29, 2005 - 12:46 pm UTC
Tom, Can you provide an example of using dbms_debug package in my packages/procedures , like how to set this on and off in 10g?
I couldn't find in your site ..
Thanks,
August 29, 2005 - 2:01 pm UTC
file:///c:/Documents%20and%20Settings/tkyte/My%20Documents/docs/allOraDoc/10gr2/B19306_01/appdev.102/b14258/d_debug.htm#sthref2331
....
30 DBMS_DEBUG
DBMS_DEBUG is a PL/SQL interface to the PL/SQL debugger layer, Probe, in the Oracle server.
This API is primarily intended to implement server-side debuggers and it provides a way to debug server-side PL/SQL program units.
..........
if you want to debug, don't write your own, just download jdeveloper (it is free)
Not Clear
A reader, August 29, 2005 - 3:25 pm UTC
Tom,
Let's say i do not want to use Jdeveloper. Can you show me a way[with samples] to debug?
I think the link you provided is from your Local drive [looks like].
Thanks,
August 30, 2005 - 12:55 am UTC
it would be a screen shot, you just go "file/debug" or something like that. It is a gui.
</code>
https://docs.oracle.com#index-STR <code>
you use the GUI to do it.
debug with dbms_application_info
Lise, May 14, 2008 - 8:48 am UTC
I hope this falls within this stream. If not I do apologise.
dbms_application_info is used throughout our PL/SQL packages to set the module and action where appropriate. We then use these settings within our error handling routine, and also within our archive table entries.
Apart from this and the ability to view the settings through v$session, I would like to extend the usage to be able to trace through my code when I need to (i.e. where I cannot use debug due to privileges).
A historical view of v$session would be great!
However, I could also write my module and action settings to an internal table, if I have switched the trace on say. I have wrapped my dbms_application_info package. It would mean that I would have to check everytime if I am suppose to trace or not, and that would add to performance unneccessary.
Any other ideas as to how I can use dbms_application_info settings with some kind of debug.
May 14, 2008 - 3:38 pm UTC
can you check just once at 'startup' or once every 100 calls or something? Use a global application context perhaps (no table, in sga)