MySQL throws Error 1332 (ER_SP_DUP_COND) when a stored routine declares two CASE, IF, or LOOP conditions with the same name or error code.
MySQL Error 1332: ER_SP_DUP_COND appears when a stored procedure or function repeats the same condition name or SQLSTATE value in a DECLARE … CONDITION statement. Remove or rename the duplicate condition, then re-create the routine to resolve the error.
Duplicate condition: %s
Error 1332 occurs during CREATE PROCEDURE or CREATE FUNCTION compilation. MySQL detects two DECLARE … CONDITION statements that reference the same condition name, SQLSTATE value, or MySQL error code.
The parser blocks creation of the routine to prevent ambiguous handler logic. The error is purely definitional and surfaces before any code runs.
The message appears immediately after the first compile pass. It can also arise during ALTER PROCEDURE or a dump reload when the duplicate lines are re-parsed.
Because it halts compilation, no partial routine is stored; execution attempts then raise a separate ‘doesn’t exist’ error.
Leaving a broken routine blocks dependent application logic, CI pipelines, or migrations. Continuous integration jobs fail, and production deployments risk downtime.
Fixing the definition and adding unit tests keeps release cycles smooth and prevents costly rollbacks.
Copy-paste during refactoring often leaves an unused duplicate with the same SQLSTATE or condition name.
Nested BEGIN … END blocks may each declare a condition without checking outer scope, causing a clash.
Reusing a condition name while pointing to the same SQLSTATE value elsewhere still counts as a duplicate.
Concurrent feature branches can each add a DECLARE that survives merge, resulting in duplication.
Raised when a routine declares two variables with the same name in the same block. Fix by renaming or removing duplicates.
Occurs if DECLARE statements appear after cursor or handler declarations. Reorder the declarations.
Signals multiple HANDLER definitions for the same condition in the same scope. Consolidate the handlers.
No. It also affects stored functions, triggers, and events that use DECLARE … CONDITION.
No. MySQL treats matching SQLSTATE or error numbers as duplicates even if the names differ.
Yes. Importing the dump will fail at the CREATE statement until you fix the duplicate lines.
Galaxy’s linting flags duplicate condition definitions in real time, and version control highlights merge-induced duplication before deployment.