DEV Community

Franz
Franz

Posted on

Uniface 10.4 & Informix: Decoding Error Messages πŸ”

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
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

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 $dberror after database operations.
  • ✨ If $dberror is positive and between 20–29, use the table above to find the cause.
  • ✨ If $dberror is 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)