Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

DB2 Procedure Error handling

Posted on 2010-08-30
6
Medium Priority
?
789 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 46

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 46

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 46

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

636 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