PostgreSQL error code
PostgreSQL error P0003
P0003 is the SQLSTATE PostgreSQL reports for too many rows, in class P0, PL/pgSQL Error.
| SQLSTATE | P0003 |
|---|---|
| Condition name | too_many_rows |
| Class | P0 — PL/pgSQL Error |
Reproduce it, then fix it
SELECT INTO STRICT requires exactly one row, and there are several Electronics products. Narrow the WHERE clause to a single row, or loop over them all. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
DO $$ DECLARE p products; BEGIN SELECT * INTO STRICT p FROM products WHERE category = 'Electronics'; END $$;
DO $$ DECLARE p products; BEGIN SELECT * INTO STRICT p FROM products WHERE category = 'Electronics' AND id = 1; END $$;