DB2 Procedure Error handling

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.
mohitgylAsked:
Who is Participating?
 
Kent OlsenConnect With a Mentor Data Warehouse Architect / DBACommented:
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
 
Kent OlsenData Warehouse Architect / DBACommented:

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
 
Kent OlsenData Warehouse Architect / DBACommented:

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
 
mohitgylAuthor Commented:
I appreciate for your idea. I will surely do that but Can you just show some statement to handle this error.
0
 
mohitgylAuthor Commented:
Not satisfied
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.