Chapter 6. Condition Handling

In this chapter, you will learn

  • What SQLCODE and SQLSTATE are and their differences

  • What a condition handler is, how and when to best use it, its range and scope, and how to work with multiple handlers

  • How to force an application or user-defined exception, and set the appropriate message tag to go along with it

  • Various ways of returning errors, and how to check the success and/or failure of a stored procedure call

Any textbook that deals with the subject of writing code is not complete without a discussion on how to process errors and other conditions. Anticipating and handling conditions is part and parcel of good, robust programming style. With DB2 SQL procedures, this is accomplished through the use of condition handlers. ...

Get DB2® SQL PL: Essential Guide for DB2® UDB on Linux™, UNIX®, Windows®, i5/OS™, and z/OS®, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.