1.

What is a ROLLBACK statement in PL/SQL?

Answer»

The SAVEPOINT statement forms a savepoint. This allows in performing partial ROLLBACKs.
Savepoints SPLITS a long transaction into smaller units. This is simply done using checkpoints. These checkpoints allow you to ROLL back to a checkpoint in a long transaction using the following COMMAND:

SAVEPOINT name_of_savepoint;

Let us see an example of SAVEPOINT:

INSERT INTO DEPTBUDGET (DEPTID,DEPTNAME,DEPTLOC, BUDGET) VALUES (1, 'Finance', 'NORTH', 20000); INSERT INTO DEPTBUDGET (DEPTID,DEPTNAME,DEPTLOC, BUDGET) VALUES (2, 'Marketing', 'EAST', 30000); SAVEPOINT s1; UPDATE DEPTBUDGET SET BUDGET = BUDGET - 4500; ROLLBACK TO s1; UPDATE DEPTBUDGET SET BUDGET = BUDGET - 4500;   WHERE DEPTNAME = 'MARKETING'; COMMIT;

Above, we have created a SAVEPOINT s1, which will allow us to rollback.



Discussion

No Comment Found