PostgreSQL error code
PostgreSQL error 22035
22035 is the SQLSTATE PostgreSQL reports for no sql json item, in class 22, Data Exception.
| SQLSTATE | 22035 |
|---|---|
| Condition name | no_sql_json_item |
| Class | 22 — Data Exception |
Reproduce it, then fix it
The document has no price, and ERROR ON EMPTY makes a missing value an error. DEFAULT ... ON EMPTY supplies a fallback instead. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
SELECT JSON_VALUE(jsonb '{"name": "Mouse"}', '$.price' RETURNING numeric ERROR ON EMPTY);SELECT JSON_VALUE(jsonb '{"name": "Mouse"}', '$.price' RETURNING numeric DEFAULT 0 ON EMPTY);