Using 'savepoint' within PL/SQL block
463236Oct 28 2005 — edited Oct 28 2005Hello,
I am interested in knowing proper usage of 'savepoint' within a PL/SQL control block. Between the dashed lines below is the general circumstance (please ignore the syntax inaccuracy). My questions are:
a) Assuming the loop does NOT encounter the Exception, will repetitive iterations of the PL/SQL runtime engine seeing the 'Savepoint marker(x)' have an adverse affect?
b) I am fairly sure that the COMMIT is necessary within the Exception section to secure the effect of the 'Rollback' statement. If so, does this affect the cursor status?
Ideally, I would like to maintain the integrity of the cursor, and have the DML statements be autonomous. Can this be accomplished within (1) control block, or do I need to create a separate PL/SQL segment for the DML section to achieve this goal?
Thank you..
----------------------------------------------------------------------------------------------------------------
Begin
Open cursor for update
Loop until NOTFOUND
< Some Non-DML processing events occur>....
Savepoint marker(x)
<DML statement to Insert>
Exception
Rollback to marker(x)
Commit (main part of question)
<More processing events>
End Loop
Close Cursor
Commit
End
-----------------------------------------------------------------------------------------------------------------