Informix Error -947: Declaration of an SPL variable named 'null' conflicts with SQL NULL value.
Cause and resolution
Declaration of an SPL variable named 'null' conflicts with SQL NULL value.
Users may not define an SPL routine variable whose spelling is 'null'. This is an error because allowing such definition would restrict the global scope of the NULL constant.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-947 fires when an SPL routine declares a variable literally named null — per the official
guidance, this is disallowed because it would restrict the global scope of the NULL constant
within the routine.
DEFINE null ...(or any declaration usingnullas the variable's name), per the official guidance — the direct, only cause.- A variable name chosen without realizing
nullcan't be shadowed inside an SPL routine —NULLis a reserved word in Informix SQL generally, and this error is the SPL-specific consequence of that: declaring a variable with that name would shadow the globalNULLconstant within the routine's scope.
Solutions / Resolution
- Choose a different variable name, per the official guidance —
NULLmust remain globally available as the SQL null-value constant throughout the routine, so no variable can shadow it.
Examples
The disallowed attempt
CREATE PROCEDURE check_order(p_order_id INT)
DEFINE null CHAR(10);
-- -947: 'null' conflicts with the NULL constant
END PROCEDURE;
Corrected
CREATE PROCEDURE check_order(p_order_id INT)
DEFINE v_status CHAR(10);
END PROCEDURE;
Diagnostic Checks
- Scan
DEFINEstatements for a variable literally namednull, and rename it.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -947 in this set yet.
null is reserved as a variable name within SPL routines specifically — choose any other name.