1311
MariaDBerrorstored-procedureshigh confidence
Undefined CONDITION
Production Risk
Low — compile-time error; routine not created.
What this means
A DECLARE ... HANDLER FOR references a named condition that was not declared in the current routine.
Why it happens
- 1Typo in the condition name
- 2Condition declared in a different BEGIN...END block scope
How to reproduce
trigger — this will error
trigger — this will error
CREATE PROCEDURE p() BEGIN DECLARE CONTINUE HANDLER FOR undeclared_cond SELECT 1; END;
expected output
ERROR 1311 (42000): Undefined CONDITION: undeclared_cond
Fix
Declare the condition first
Declare the condition first
DECLARE cond_name CONDITION FOR SQLSTATE '45000';
Why this works
Named conditions must be declared before handlers reference them.
Sources
Official documentation ↗
MySQL 8.0 — 1311 ER_SP_COND_MISMATCH
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev