![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjbU93eEE5mpGY47FK9F3JGCOMDDR13o_faI_2qiJqnIqdCff5o9VnE3DlrYVSZAN2vCkGwwN75eHcxQV6lqwENG77n3r23rXixIxi4FUpoGkXShUmiluX15Rs0CyJkFjlBWbOZeY0w2wvN9NOK_YXN8WbvCxOO-MuetfXvYNrUCWRB7nZhJx7NCl5ORWU/s200/sql.png)
All of us who use SQL have encountered errors, and when we do a SQL code is returned. This then leaves us trying to find the text associated with the SQL code to understand what had happened.
If this is in a RPG program I always recommend that you use GET DIAGNOTISTICS, which will return all you wanted to know about the message and a whole lot more too. If I am quickly writing a RPG program that will only be used one, or maybe twice, or a CL program and I get a SQL code I need to look it up to understand what happened.
There are two types of SQL codes:
- Those less than zero: Errors
- Those greater than zero: Warnings
All SQL codes have an equivalent IBM i message id. Basically it is 'SQL' followed by the SQL code. For example, SQL code -423 becomes message id SQL0423.
All message ids' information in IBM i are held in message files. SQL messages have their own message file QSQLMSG in the library QSYS.
If I wanted to look up the message for SQL code -423, message id SQL0423, I could use the Display Message Description command,DSPMSGD: