For over a year we have had a SQL table function to be able to retrieve information about the SQL codes. Now we can do the same kind of thing for SQL states. The major difference is that we retrieve the information for the SQL statuses from a SQL View: SQLSTATE_INFO in the library QSYS2.
When working with SQL codes and statuses it is important to remember that they are not all a one-to-one relationship. There are some SQL states that are associated with more than one SQL code, and there are some SQL codes that are associated with more than one SQL state.
The SQLSTATE_INFO view returns three columns:
- SQLSTATE_VALUE: SQL state
- SQLCODE_VALUE: SQL code
- SQLSTATE_DETAIL: Text for the SQL state. Interestingly this is returned only in English
If SQL state is associated with more than one SQL code each combination will have its own row.


