25008
PostgreSQLERRORNotableInvalid Transaction StateHIGH confidence
held cursor requires same isolation level
What this means
SQLSTATE 25008 is raised when a held cursor (declared WITH HOLD) is accessed in a transaction with a different isolation level than the one in which the cursor was created.
Why it happens
- 1Opening a WITH HOLD cursor in one transaction isolation level and then accessing it from a new transaction with a different isolation level
How to reproduce
WITH HOLD cursor accessed at different isolation level.
expected output
ERROR: held cursor requires same isolation level
Fix
Use the same isolation level in all transactions that access a held cursor
WHEN When using WITH HOLD cursors across transaction boundaries.
Use the same isolation level in all transactions that access a held cursor
SET TRANSACTION ISOLATION LEVEL READ COMMITTED; -- match the cursor's level
Why this works
Ensure the transaction isolation level matches the level at which the cursor was created before accessing it.
Sources
Official documentation ↗
Class 25 — Invalid Transaction State
Content generated with AI assistance and reviewed for accuracy. Found an error? hello@errcodes.dev