PL/SQL Use of Rollback and Savepoint


insert into employees
(
  employee_id,
  first_name,
  last_name,
  email,
  hire_date,
  job_id
)
values
(
  seq_employee_id.nextval,
  'Nurhak',
  'Kaya',
  'test1@gmail.com',
  sysdate,
  'IT_PROG'
);
savepoint point1;
insert into employees
(
  employee_id,
  first_name,
  last_name,
  email,
  hire_date,
  job_id
)
values
(
  seq_employee_id.nextval,
  'Nurhak',
  'Kaya',
  'test2@gmail.com',
  sysdate,
  'IT_PROG'
);
savepoint point2;
insert into employees
(
  employee_id,
  first_name,
  last_name,
  email,
  hire_date,
  job_id
)
values
(
  seq_employee_id.nextval,
  'Nurhak3',
  'Kaya',
  'test3@gmail.com',
  sysdate,
  'IT_PROG'
);
savepoint point3;

--ROLLBACK!!


select * from employees
where email='test3@gmail.com'; --Data has been found!

rollback to savepoint point2; --'Rollback to savepoint point2' command has undone the last
                          --inserted data.

select * from employees
where email='test3@gmail.com'; --Last inserted data can not be seen anymore!

Comments

Popular posts from this blog

Solution for the fault: "System.Diagnostics.Process.Start is not working on IIS, but working on ASP.NET Development Server"

Solution for "Can not obtain Oracle client information from registry"