Informix Error -443
-443 The range specified in the FOR loop cannot have a NULL value: (%s).
The FOR statement in a stored procedure cannot have a NULL value for the starting value, the ending value, or the step value of a range.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-443 fires in a stored procedure's FOR loop when one of its three range parameters — start
value, end value, or step value — evaluates to NULL. All three need concrete numeric values for
the loop to be well-defined; a NULL bound or step has no sensible iteration meaning.
- A
FORloop range expression referencing a column or variable that's currentlyNULL— the most common cause, especially when the bound comes from a query result that could return no matching value. - An uninitialized stored-procedure variable used as a range bound, defaulting to
NULLbefore being explicitly set. - A step value expression that evaluates to
NULLunder some input combination not anticipated when the procedure was written.
Solutions / Resolution
- Ensure all three range parameters (start, end, step) evaluate to concrete numeric values,
per the official guidance, before the
FORloop executes. - Add a
NULLcheck (or a default viaNVL/COALESCE-equivalent logic) on any range parameter sourced from a query result or variable that might not always be populated. - Initialize stored-procedure variables explicitly before using them as range bounds, rather than relying on their default value.
Examples
A NULL end value from a query result
CREATE PROCEDURE process_range()
DEFINE max_id INTEGER;
SELECT MAX(order_id) INTO max_id FROM orders WHERE status = 'archived';
-- if no rows match, max_id is NULL here
FOR i = 1 TO max_id
-- -443 if max_id is NULL
END FOR
END PROCEDURE;
Fix — guard against a NULL bound:
CREATE PROCEDURE process_range()
DEFINE max_id INTEGER;
SELECT MAX(order_id) INTO max_id FROM orders WHERE status = 'archived';
IF max_id IS NULL THEN
RETURN;
END IF;
FOR i = 1 TO max_id
-- safe to iterate now
END FOR
END PROCEDURE;
Diagnostic Checks
- Check each of the three range parameters (start, end, step) for a possible
NULLsource. - Trace back to where a
NULLrange parameter originates — an unmatched query, an uninitialized variable, or an unexpected input combination.
Related Errors / Related Topics
- -391 — "Cannot insert a null into column column-name." A related
NULL-handling discipline, in the context of table columns rather than stored-procedure loop bounds.
Guard against a NULL range bound explicitly before entering a FOR loop, especially when a
bound comes from a query result that might not match any rows.