Solved

DB2 Procedure Error handling

Posted on 2010-08-30
6
768 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

November 2009 Recently, a question came up in the DB2 forum regarding the date format in DB2 UDB for AS/400.  Apparently in UDB LUW (Linux/Unix/Windows), the date format is a system-wide setting, and is not controlled at the session level.  I'm n…
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…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

910 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

19 Experts available now in Live!

Get 1:1 Help Now