Re: Transactions and cursors
Posted in 1998
Alejandro Dobniewski wrote: > > It seems to me from the ESQL/C documentation that a cursor must within a > transaction. For example: > > DECLARE CURSOR WITH HOLD ... SELECT * FROM TABLE WHERE FLAG IS NULL FOR > UPDATE > BEGIN WORK // Init transaction > OPEN cursor > while not eof > FETCH > Do something > UPDATE SET FLAG=1 WHERE CURRENT.. > end while > COMMIT WORK // End transaction > > Is it posible to have a transaction for each record, so a ROLLBACK only > affects one record? Yes that is what the WITH HOLD clause on the DECLARE CURSOR statement is all about. It prevents the cursor from being closed when a COMMIT or ROLLBACK happens. Just COMMIT WORK or ROLLBACK WORK every N records and then BEGIN WORK again. Art S. Kagel