Check for exceptions with sqlca

After an SQL statement executes, the sqlca structure can indicate one of the four possible conditions that the following table shows.
Table 1. Exceptions that the sqlca structure returns
Exception condition sqlca value
Success SQLCODE (and sqlca.sqlcode) = 0
Success, but no rows found SQLCODE (and sqlca.sqlcode) = 100
Success, but warnings generated sqlca.sqlwarn.sqlwarn0 = 'W'
To indicate specific warning:
  • One of sqlwarn1 to sqlwarn7 in the sqlca.sqlwarn structure is also set to W
Failure, runtime error generated SQLCODE (and sqlca.sqlcode) < 0

For a general introduction to these four conditions, see Types of database exceptions.