"WITH HOLD"
Cursors are usually closed automatically at the end of a transaction, i.e. when a COMMIT or ROLLBACK (or an implicit termination of the transaction) occurs. That behavior can be changed if the cursor is declared using the WITH HOLD clause. (The default is WITHOUT HOLD.) A holdable cursor is kept open over COMMIT and closed upon ROLLBACK. (Some DBMS deviate from this standard behavior and also keep holdable cursors open over ROLLBACK.)
DECLARE cursor_name CURSOR WITH HOLD FOR SELECT ... FROM ...When a COMMIT occurs, a holdable cursor is positioned before the next row. Thus, a positioned UPDATE or positioned DELETE statement will only succeed after a FETCH operation occurred first in the transaction.
Note that JDBC defines cursors as holdable per default. This is done because JDBC also activates auto-commit per default. Due to the usual overhead associated with auto-commit and holdable cursors, both features should be explicitly deactivated at the connection level.
Read more about this topic: Cursor (databases)
Famous quotes containing the word hold:
“There is a place where we are always alone with our own mortality, where we must simply have something greater than ourselves to hold ontoGod or history or politics or literature or a belief in the healing power of love, or even righteous anger.... A reason to believe, a way to take the world by the throat and insist that there is more to this life than we have ever imagined.”
—Dorothy Allison (b. 1949)
“I is a militant social tendency, working to hold and enlarge its place in the general current of tendencies. So far as it can it waxes, as all life does. To think of it as apart from society is a palpable absurdity of which no one could be guilty who really saw it as a fact of life.”
—Charles Horton Cooley (18641929)