Symptoms
The server reports SQLSTATE 02000 (no_data), a condition in the No Data class.
- The error is written to the server log and returned to the client carrying
SQLSTATE 02000. - Any driver (libpq, JDBC, psycopg, npgsql, pgx) surfaces this code in its error object so you can branch on it programmatically.
Environment
Severity: WARNING | PostgreSQL versions: 12, 13, 14, 15, 16, 17
Reproduce with the exact statement and read the full message in the server log (raise log_min_messages / set log_min_error_statement for more context).
Root Cause
02000 belongs to Class 02 — No Data. In this class, the statement completed but returned or affected no rows.
The first two characters (02) identify the error class, so application code can match the whole class via 02000 when the specific code is not needed.
Diagnostic Queries
Recovery
Treat "no data" as a normal outcome: in PL/pgSQL check FOUND or handle NOT FOUND; in applications verify your predicates instead of assuming a row exists.
Reference: PostgreSQL error codes — Class 02 (No Data).
Thanks — noted. This helps keep the database accurate.