Informix Error -689
-689 Global variable variable-name declared inconsistently.
Two or more procedures were executed that defined the same global variable with different data types.
Example of error:
CREATE PROCEDURE test1() DEFINE GLOBAL glob INT DEFAULT 10; ... END PROCEDURE
CREATE PROCEDURE test2() DEFINE GLOBAL glob CHAR (9) DEFAULT USER; ... END PROCEDURE
Correction: Declare global variables consistently. (Using appropriate naming conventions would be useful.) Two variables of the same data type but different lengths are considered inconsistent.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-689 fires when two or more routines each declare the same global variable name with different
data types — per the official guidance's example, one routine declaring glob as INT and
another declaring it as CHAR. Per the official guidance, even two variables of the same data
type but different lengths count as inconsistent.
- Two routines declaring the same global variable name with genuinely different types, per the official guidance's example — the direct, common cause.
- Two routines declaring the same global variable name with the same base type but different
lengths (e.g.
CHAR(10)in one routine,CHAR(20)in another), per the official guidance's specific note — this counts as inconsistent even though the base type matches. - A global variable name reused independently across routines written by different people or at different times, without a shared declaration convention to keep them in sync.
Solutions / Resolution
- Declare global variables consistently everywhere they're used, per the official
guidance — every routine's
DEFINE GLOBALfor the same name must agree exactly on type and length. - Adopt a naming convention that makes global variable declarations easy to keep in sync,
per the official guidance's suggestion — for example, centralizing all
DEFINE GLOBALstatements for a given variable in one place that every routine includes/references, rather than duplicating the declaration by hand in each routine. - Search across every routine for the global variable's name to find and reconcile every declaration before retrying.
Examples
Inconsistent declarations across routines
CREATE PROCEDURE proc_a()
DEFINE GLOBAL glob INT DEFAULT 0;
...
END PROCEDURE;
CREATE PROCEDURE proc_b()
DEFINE GLOBAL glob CHAR(10) DEFAULT '';
-- -689: glob was already declared INT DEFAULT 0 in proc_a
...
END PROCEDURE;
Corrected — matching declarations
CREATE PROCEDURE proc_a()
DEFINE GLOBAL glob INT DEFAULT 0;
...
END PROCEDURE;
CREATE PROCEDURE proc_b()
DEFINE GLOBAL glob INT DEFAULT 0;
...
END PROCEDURE;
Diagnostic Checks
- Search every routine in the database for
DEFINE GLOBALstatements naming the same variable, and compare their exact type and length.
Related Errors / Related Topics
- -658 — "Variables declared as GLOBAL require a default value." A related global-variable declaration restriction, about requiring a default rather than declaration consistency across routines.
Every routine's DEFINE GLOBAL for the same name must match exactly, type and length — search
across all routines to find and reconcile every declaration.