PostgreSQL error code
PostgreSQL error 34000
34000 is the SQLSTATE PostgreSQL reports for invalid cursor name, in class 34, Invalid Cursor Name.
| SQLSTATE | 34000 |
|---|---|
| Condition name | invalid_cursor_name |
| Class | 34 — Invalid Cursor Name |
Reproduce it, then fix it
No cursor by that name is open. Cursors last only until the end of the transaction, so a cursor declared in one transaction is gone in the next. Run the broken query to see the error, then switch to the fixed one. Edit either freely; every run is rolled back.
FETCH 3 FROM product_cursor;
DECLARE product_cursor CURSOR FOR SELECT id, name FROM products ORDER BY id; FETCH 3 FROM product_cursor;