20000
Read PG 18 manual ↗case_not_found
- SQLSTATE
- 20000
- Condition name
- case_not_found
- Class
- Case Not Found
- Source macro
- ERRCODE_CASE_NOT_FOUND
- Evidence
- Source path confirmed
English SQLSTATE atlas: authored explanations and source/runtime evidence are separate from the manual definitions. View source ↗
At a glance
SQLSTATE 20000 is raised by PL/pgSQL for a CASE statement that reaches no matching WHEN and has no ELSE. PostgreSQL 18.6 reports case not found with hint CASE statement is missing ELSE part. The condition is about the procedural CASE statement path; it is not the result of an ordinary query returning zero rows.
Meaning
The executor path is exec_stmt_case in src/pl/plpgsql/src/pl_exec.c. It evaluates the searched or simple procedural CASE statement and reports 20000 when control reaches the missing-ELSE branch. A SQL CASE expression has different semantics, so diagnose the statement form and routine source before changing a query.
Messages
The fixed message is case not found; the hint is CASE statement is missing ELSE part..
Diagnosis
Find the PL/pgSQL routine and the CASE statement named by the routine context. List the possible selector values or predicates and verify that every intended path has a WHEN; then check whether an ELSE was omitted. Do not use row-count checks or SELECT INTO STRICT diagnostics as a substitute for this condition.
Response
Add an ELSE branch that implements the intended fallback, or make the WHEN predicates exhaustive and verify the routine with representative selector values. If the missing case represents invalid business input, have the branch report the application-specific condition deliberately. After changing the routine, rerun the surrounding transaction only when its side effects were rolled back or the business operation is idempotent.
Versions
The locked catalogue places this condition at least by PostgreSQL 8.4.0. The release definitions cover the published snapshots listed in the facts block; source-path status is limited to the fixed PostgreSQL 18.6 context cited below.
Sources
The fixed PL/pgSQL executor contains the message and hint. The PL/pgSQL CASE statement documentation describes the missing-ELSE behavior. See the structured evidence record for fixed source paths, scan scope, and unresolved runtime boundaries.
Source evidence
Evidence belongs to the frozen source and runtime versions listed here. It is not a runtime verification of the selected manual version.
20000 is case_not_found in SQLSTATE Class 20.
Method: Read the fixed errcodes definition row, severity, and macro.
The fixed PostgreSQL 18.6 source contains the report path and message context described on the page.
Method: Read the complete source context around the resolved report group.
Limits: This is source confirmation, not a runtime observation in this batch.
The locked release definitions establish catalogue presence from the known 8.4.0 boundary; they do not establish a precise introducing release or runtime use.
Method: Compare canonical release-definition facts with the available history boundary.
Limits: Definition presence is not an emitting-path observation.
- src/backend/utils/errcodes.txt · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 - src/pl/plpgsql/src/pl_exec.c · REL_18_6 ·
724edf9bde9d356724ad384a2e196edc3c9f80f7 raw/calls/REL_18_6.jsonl· ·
Message templates
ERROR · message.case-not-found
Primary
case not found
Hint
CASE statement is missing ELSE part.
Reproduction & repair cases
No reproduction case is attached to this condition.
Recorded runtime evidence
No runtime observation is attached to this entry.
Definition snapshot: english-manuals:112cc5b4067e643ee73864a70c0… · English manual source