A program that uses exception handling

The getdiag.ec program contains exception handling on each of the SQL statements that the program executes. This program is a modified version of the demo1.ec program. The version that this section lists and describes uses the following exception-handling methods:
  • The SQLSTATE variable and the GET DIAGNOSTICS statement to obtain exception information.
  • The SQLWARNING and SQLERROR keywords of the WHENEVER statement to call the whenexp_chk() function for warnings and errors.

The whenexp_chk() function displays the error number and the accompanying ISAM error, if one exists. The exp_chk.ec source file contains this function and its exception-handling functions. The getdiag.ec source file includes the exp_chk.ec file.