?
Solved

DB2 Procedure Error handling

Posted on 2010-08-30
6
Medium Priority
?
778 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 45

Expert Comment

by:Kent Olsen
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:Kent Olsen
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:
Kent Olsen earned 1000 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

Learn by Doing. Anytime. Anywhere.

Do you like to learn by doing?
Our labs and exercises give you the chance to do just that: Learn by performing actions on real environments.

Hands-on, scenario-based labs give you experience on real environments provided by us so you don't have to worry about breaking anything.

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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

770 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