Solved

DB2 Procedure Error handling

Posted on 2010-08-30
6
767 Views
Last Modified: 2012-05-10
I am writing a procedure in DB2, bu while executing that I am a exception SQL0138, so i would like to handle it. Kindly suggest the ways to do that. I know the ways but i am still getting some errors or i am not able to handle the error properly.
0
Comment
Question by:mohitgyl
  • 3
  • 2
6 Comments
 
LVL 45

Expert Comment

by:Kdo
ID: 33561884

Hi mohitqyl,

You want to declare an exception handler to deal with the error, or each type of error.

If you'll post you procedure I'll be glad to show you what to plug in.


Kent
0
 
LVL 45

Expert Comment

by:Kdo
ID: 33561900

Actually, that error is a programming error.  The procedure is calling SUBSTR with an illegal argument.

Trapping the error and handling it is more work than correcting the SUBSTR function call.


Kent
0
 

Author Comment

by:mohitgyl
ID: 33568479
I appreciate for your idea. I will surely do that but Can you just show some statement to handle this error.
0
 
LVL 45

Accepted Solution

by:
Kdo earned 500 total points
ID: 33569030
The IBM documentation is here:

  http://publib.boulder.ibm.com/infocenter/db2luw/v9/topic/com.ibm.db2.udb.apdv.embed.doc/doc/c0005777.htm

You should also read:

  http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.plsql.doc/doc/c0053876.html


You'll need a handler in your procedure that looks like this:

  DECLARE CONTINUE WHEN {condition};


But I STRONGLY urge you to not use this.  If you have a coding error in your procedure (and the error that you're getting indicates that one exists) all you're doing is masking the error.  Subsequent steps in the procedure could be meaningless, or worse, hazardous to your data.


Kent
0
 

Author Closing Comment

by:mohitgyl
ID: 33767377
Not satisfied
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
OPENQUERY not recognizing valid table names 6 397
db2icrt -u db2inst1 db2inst1 problem on mac 4 230
RPG to c# 3 326
AS400 Single Sign On 3 1,031
Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now