PostgreSQL error code
PostgreSQL error 55000
55000 is the SQLSTATE PostgreSQL reports for object not in prerequisite state, in class 55, Object Not In Prerequisite State.
| SQLSTATE | 55000 |
|---|---|
| Condition name | object_not_in_prerequisite_state |
| Class | 55 — Object Not In Prerequisite State |
Reproduce it, then fix it
currval returns the value nextval last gave this session, so it fails until nextval has run at least once. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
CREATE SEQUENCE invoice_no;
SELECT currval('invoice_no');CREATE SEQUENCE invoice_no;
SELECT nextval('invoice_no'), currval('invoice_no');