00000
PostgreSQLNONESuccessful CompletionHIGH confidence

successful completion

What this means

SQLSTATE 00000 indicates that the last SQL statement completed without error or warning. It is the "all clear" code returned by the server when a command succeeds normally.

Why it happens
  1. 1Normal, expected completion of any SQL statement with no anomalies
How to reproduce

Any successfully executed SQL statement.

trigger — this will error
trigger — this will error
SELECT 1; -- SQLSTATE 00000

expected output

SELECT 1

Fix

Use SQLSTATE 00000 as the baseline success check in PL/pgSQL

WHEN When writing stored procedures or DO blocks that need to confirm a statement succeeded before continuing.

Use SQLSTATE 00000 as the baseline success check in PL/pgSQL
DO $
DECLARE
  v_sqlstate TEXT;
BEGIN
  INSERT INTO orders (user_id, total) VALUES (42, 99.99);
  GET DIAGNOSTICS v_sqlstate = RETURNED_SQLSTATE;
  IF v_sqlstate = '00000' THEN
    RAISE NOTICE 'Insert succeeded (SQLSTATE %)' , v_sqlstate;
  END IF;
EXCEPTION WHEN OTHERS THEN
  RAISE WARNING 'Statement failed: %', SQLERRM;
END;
$;

Why this works

In PL/pgSQL, GET DIAGNOSTICS ... = RETURNED_SQLSTATE captures the SQLSTATE of the most recent SQL statement. A value of 00000 confirms clean completion with no warnings or errors. This is useful when a procedure must audit its own intermediate steps before committing.

Sources
Official documentation ↗

Class 00 — Successful Completion

Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev

← All PostgreSQL errors