Subscribe:

Monday, October 17, 2011

Transaction control

To complete your DML statements you need to control in it by
1-      CMMIT: make all pending changes in a transaction permanent.
2-      ROLLBACK: discard pending changes and return to an earlier point in the statement.
3-     SAVEPOINT: defines a marker to which you can later rollback.
Examples.
1-     Commit
Suppose you inset new row in NEWEMP table and you want to save the latest changes
Type
Commit;
2-     ROLLBACK
Suppose you inset new row in NEWEMP table and you want Returns the latest commit
Type
ROLLBACK;
3-     SAVEPOINT
As the below example after inserting data you can create a named save point
Insert into newemp
Select empno,ename,deptno
 From emp
 Where deptno=10;
SAVEPOINT inserting_finish;
You can returned to the latest savepoint named inserting_finish
Type
ROLLBACK INSERTING_FINISH

No comments:

Post a Comment