- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Implementation of common error-trapping logic for all SQL statements in program
A COBOL-DB2 program can have multiple DB2 SQL statements. In order to implement the common error-trapping for all the SQL statements in a COBOL-DB2 program, we will use WHENEVER statement.
The WHENEVER statement can direct the control to the error handling section or routine based on the value returned in SQLCODE field of SQLCA. For example, we can declare WHENEVER statement in COBOL-DB2 program as below−
EXEC SQL WHENEVER SQLERROR GOTO ERROR-ROUTINE END-EXEC
In the above example, the SQLERROR parameter will be set only when the value of SQLCODE will be lesser than zero, which indicates that there was some error occurred while executing the query. In that case, the control will be transferred to the ERRORROUTINE paragraph of the program.
- Related Articles
- Implementation of restart logic in a COBOL-DB2 program
- Mathematical Logic Statements and Notations
- Implementation of a table level locks in a COBOL-DB2 program during SQL execution
- Usage of backtick in SQL statements?
- What is Implementation of Three Address Code Statements?
- What kind of SQL statements can be used to prepare statements?
- Program for Fibonacci numbers in PL/SQL
- C++ Program for Common Divisors of Two Numbers?
- Python Program for Common Divisors of Two Numbers
- Java Program for Common Divisors of Two Numbers
- ERROR 1064 (42000): You have an error in your SQL syntax at zero fill column?
- Trapping Rain Water in Python
- Using SQL statements in ABAP Programming and Database performance
- C++ Program for Longest Common Subsequence
- Java Program for Longest Common Subsequence

Advertisements