Hey developers! π
If you work with Uniface 10.4 and Informix, you know that robust error handling is key. Sometimes, the message frame shows you an error, but it can be confusing. Is it Uniface? Is it the Connector? Is it the Informix database itself?
In this post, I will help you understand the different types of error messages and give you a cheat sheet for the specific Connector return values.
π€ This blog post was created with the help of an AI assistant, based on the official Uniface documentation.
Two Types of Messages π§
First, you need to spot the difference between a Connector error and a native Informix error. They look different in the message frame.
1. Connector Errors
These are errors generated by the Uniface driver itself (before or during communication with the database).
Syntax:
Connector {ERROR|WARNING} (Number): Message
2. Informix Errors
These come directly from the DBMS. They include the SQLSTATE and SQLCODE.
Syntax:
Informix {ERROR|WARNING|NO DATA} (SQLSTATE: sqlstate ): Message SQLCODE sqlcode: Message
The $dberror Variable π΅οΈ
When an error happens, Uniface stores the last error code in the $dberror variable. This is what you check in your ProcScript code.
Here is the breakdown of what the values in $dberror mean:
| Value | Meaning |
|---|---|
| 0 | Success, no error. Everything worked perfectly. β |
| < 0 | Error detected by Informix. A negative number means the DBMS reported an issue. π΄ |
| 20β29 | Connector errors. A positive number in this range means the Connector found an issue. π |
Connector Error Cheat Sheet π
If you see a positive number in $dberror between 20 and 29, it is one of these specific Connector issues. Keep this list handy!
| $dberror | Message |
|---|---|
| 20 | The requested function/mode is not supported. |
| 21 | The specified database environment name is too long. |
| 22 | The connector can fetch by primary key only. |
| 23 | No more cursors could be allocated. |
| 24 | No more statements could be allocated. |
| 25 | Connector deleted/updated more or less than 1 row. |
| 26 | The parsed SQL statement was not a select. |
| 27 | An illegal request was received by the connector. |
| 28 | Already logged on to a database. |
| 29 | Unrecognized option for open database. |
Examples in Action π
Example 1: Success (Error 0)
You fetch a record successfully from the Informix database.
- Result in
$dberror:0 - Message: No error message appears.
Example 2: Already Logged On (Error 28)
Your code tries to open a connection to the database, but your path is already open.
- Result in
$dberror:28 - Message:
Connector ERROR (28): Already logged on to a database.
Example 3: Informix Error (Negative Value)
The Informix DBMS reports an error (for example, a syntax error in your SQL or a constraint violation).
- Result in
$dberror: A negative number (example:-201) - Message:
Informix ERROR (SQLSTATE: 42000): ... SQLCODE -201: ...
Quick Tips π‘
- β¨ Always check
$dberrorafter database operations. - β¨ If
$dberroris positive and between 20β29, use the table above to find the cause. - β¨ If
$dberroris negative, contact Informix documentation for the SQLCODE meaning. - β¨ Look at both the error number and the message to debug faster.
Conclusion
Next time you see an error in the message frame, check the syntax first. Is it "Connector" or "Informix"? If it is a Connector error, use the table above to quickly find the cause!
Happy coding! π»β¨
Top comments (0)