Informix Error -26062: The specified case is not defined in the CASE statement
Cause and resolution
The specified case is not defined in the CASE statement
The value of the case did not match any value in the WHEN clause of the CASE statement and no ELSE clause is defined. The following example returns this error because the LET statement specifies a case that is not defined in the CASE statement.
CREATE PROCEDURE case_proc( ) RETURNING CHAR(1); DEFINE grade CHAR(1); LET grade = 'D'; CASE grade WHEN 'A' THEN LET grade = 'a'; WHEN 'B' THEN LET grade = 'b'; WHEN 'C' THEN LET grade = 'c'; END CASE; RETURN grade; END PROCEDURE;
EXECUTE PROCEDURE case_proc();
To reduce the risk of this error, you might revise your CASE statement logic to include an ELSE clause to take appropriate action if no WHEN condition is true, or to add additional WHEN clauses that define how to handle additional cases.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-26062 fires when an SPL CASE statement's value matches no WHEN clause and no ELSE
clause is defined — per the official guidance.
- The
CASEvalue matched noWHENclause, and the statement has noELSEclause, per the official guidance — the direct, only cause.
Solutions / Resolution
- Add an
ELSEclause to handle values not covered by anyWHENclause, per the official guidance, or - Add additional
WHENclauses covering the missing cases, per the official guidance.
Examples
A CASE with no matching WHEN and no ELSE
CREATE PROCEDURE case_proc()
RETURNING CHAR(1);
DEFINE grade CHAR(1);
LET grade = 'D';
CASE grade
WHEN 'A' THEN LET grade = 'a';
WHEN 'B' THEN LET grade = 'b';
WHEN 'C' THEN LET grade = 'c';
END CASE;
-- -26062: 'D' matches no WHEN, and there's no ELSE
RETURN grade;
END PROCEDURE;
Corrected
CASE grade
WHEN 'A' THEN LET grade = 'a';
WHEN 'B' THEN LET grade = 'b';
WHEN 'C' THEN LET grade = 'c';
ELSE LET grade = 'f';
END CASE;
Diagnostic Checks
- Check every SPL
CASEstatement for anELSEclause, and add one, or addWHENclauses for the missing values.
Related Errors / Related Topics
- -26063 — "Data type not supported with CASE statement of SPL" A related
CASErestriction, on the case value's data type rather than an unmatched value.
An SPL CASE value matched no WHEN and there was no ELSE — add an ELSE clause or
cover the missing case.