O'Reilly logo

DB2® SQL PL: Essential Guide for DB2® UDB on Linux™, UNIX®, Windows®, i5/OS™, and z/OS®, Second Edition by Paul Yip, Fraser McArthur, Michael Gao, Raul Chong, Drew Bradstock, Clara Liu, Zamil Janmohamed

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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. ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required