dbTalk Databases Forums  

Simple debugging of procedures?

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Simple debugging of procedures? in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Troels Arvin
 
Posts: n/a

Default Simple debugging of procedures? - 09-05-2010 , 04:17 PM






Hello,

Is there a simple way to debug DB2 SQL procedures, such as: which branch
of a conditional construct was chosen, what value did a counter reach,
etc, _without_ installing some big, complicated IDE?

My question could maybe be rephrased as "is there a way to perform printf-
style debugging in DB2 SQL procedures?"

If not: I'm considering creating a C-based UDF which logs arbitrary
strings to syslog, so that a SQL procedure can inform the surroundings of
its state during development.

--
Troels

Reply With Quote
  #2  
Old   
Willem Fischer
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-05-2010 , 06:05 PM






On Sep 5, 11:17*pm, Troels Arvin <tro... (AT) arvin (DOT) dk> wrote:
Quote:
Hello,

Is there a simple way to debug DB2 SQL procedures, such as: which branch
of a conditional construct was chosen, what value did a counter reach,
etc, _without_ installing some big, complicated IDE?

My question could maybe be rephrased as "is there a way to perform printf-
style debugging in DB2 SQL procedures?"

If not: I'm considering creating a C-based UDF which logs arbitrary
strings to syslog, so that a SQL procedure can inform the surroundings of
its state during development.

--
Troels
I don't know if Serge's SQL PL/PL/SQL profiler would be of use:
http://www.google.com/url?sa=D&q=htt...wEjqjrdlB7VRmg

(I hope this link works, otherwise he had posted it a short while
ago.)

What else comes to my mind is a debug table and a debug function,
something like insert into dbg values (current timestamp, message).

PL/SQL should have a debug function built in if you're on V9.7.

Sorry, mainly guesses here.

Reply With Quote
  #3  
Old   
Troels Arvin
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-06-2010 , 02:33 AM



Hello,

Willem Fischer wrote:
Quote:
I don't know if Serge's SQL PL/PL/SQL profiler would be of use
[...]

I'm not thinking about performance at this point, but may come in handy
later on.


Quote:
What else comes to my mind is a debug table and a debug function,
something like insert into dbg values (current timestamp, message).
Yes, but can such inserts be done outside of the currently running
transaction? - Otherwise I suppose that no messages will end up in the
message-table?


Quote:
PL/SQL should have a debug function built in if you're on V9.7.
That's interesting. I suppose this relates to DBMS_OUTPUT which seems to
be exactly what I was looking for. Thanks.

--
Troels

Reply With Quote
  #4  
Old   
Troels Arvin
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-06-2010 , 05:42 AM



Hello,

I wrote:
Quote:
PL/SQL should have a debug function built in if you're on V9.7.

That's interesting. I suppose this relates to DBMS_OUTPUT which seems to
be exactly what I was looking for. Thanks.
Hmm. DBMS_OUTPUT requires that Oracle compatibility be enabled :-(

Is Oracle compatibility enabled in all DB2 LUW 9.7 editions, or does it
require a special licence?

--
Troels

Reply With Quote
  #5  
Old   
The Boss
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-06-2010 , 09:28 AM



On Sep 6, 12:42*pm, Troels Arvin <tro... (AT) arvin (DOT) dk> wrote:
Quote:
Hello,

I wrote:
PL/SQL should have a debug function built in if you're on V9.7.

That's interesting. I suppose this relates to DBMS_OUTPUT which seems to
be exactly what I was looking for. Thanks.

Hmm. DBMS_OUTPUT requires that Oracle compatibility be enabled :-(

Is Oracle compatibility enabled in all DB2 LUW 9.7 editions, or does it
require a special licence?

It depends on which specific compatibility feature you want to use.
DB2 Enterprise Edition is the only version that supports the full
spectrum.
Regarding DBMS_OUTPUT (and other system-defined modules), this is
supported in Workgroup Edition but not in Personal Edition or Express(-
C) Edition, see:
http://publib.boulder.ibm.com/infoce.../c0053670.html

You may also want to checkout this forum-post on DeveloperWorks:
http://www.ibm.com/developerworks/fo...85419&tstart=0

HTH

--
Jeroen

Reply With Quote
  #6  
Old   
Ian
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-07-2010 , 02:17 AM



On Sep 5, 2:17*pm, Troels Arvin <tro... (AT) arvin (DOT) dk> wrote:
Quote:
Hello,

Is there a simple way to debug DB2 SQL procedures, such as: which branch
of a conditional construct was chosen, what value did a counter reach,
etc, _without_ installing some big, complicated IDE?
One thing you can do is create a global temporary table, and have
your
procedure insert records into the GTT. Then, simply query your GTT
to
see your output...

Reply With Quote
  #7  
Old   
Serge Rielau
 
Posts: n/a

Default Re: Simple debugging of procedures? - 09-07-2010 , 07:24 AM



On 9/6/2010 10:28 AM, The Boss wrote:
Quote:
On Sep 6, 12:42 pm, Troels Arvin<tro... (AT) arvin (DOT) dk> wrote:
Hello,

I wrote:
PL/SQL should have a debug function built in if you're on V9.7.

That's interesting. I suppose this relates to DBMS_OUTPUT which seems to
be exactly what I was looking for. Thanks.

Hmm. DBMS_OUTPUT requires that Oracle compatibility be enabled :-(

Is Oracle compatibility enabled in all DB2 LUW 9.7 editions, or does it
require a special licence?


It depends on which specific compatibility feature you want to use.
DB2 Enterprise Edition is the only version that supports the full
spectrum.
Regarding DBMS_OUTPUT (and other system-defined modules), this is
supported in Workgroup Edition but not in Personal Edition or Express(-
C) Edition, see:
http://publib.boulder.ibm.com/infoce.../c0053670.html

You may also want to checkout this forum-post on DeveloperWorks:
http://www.ibm.com/developerworks/fo...85419&tstart=0
Troels,

DBMS_OUTPUT is supported without compatibility vector.
Also if you search for my name on developerworks you will find an
article on SQL PL "tracing".
Out of the box it only logs entry/exit/error, but I also provided a DATA
function which you can embed as printf.

There was some snafu in DB2 9.7.0 for Windows with the library used
which was rectified no later than FP2. So if you want to go that route
ensure you are on the latest and greatest on Windows.

Also if you use the SQL PL / PL/SQL profiler you can execute it after
flushing the package cache to get an individual run.
(Probably not something to do on a production machine...)

Send me a note and I send you a more streamlined version of the profiler...

Cheers
Serge
--
Serge Rielau
SQL Architect DB2 for LUW
IBM Toronto Lab

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.