Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

insert with sequence generated key and rollback script

user5108636Jan 7 2019 — edited Jan 8 2019

Hi All,

      I need to write a insert statement with sequence generated key and a rollback script for the same

The emp_id comes from sequence. SEQ_EMP_IDThe insert statement is

insert into employees(seq_emp_id.nextval, 'Jon' , 'Bon', sysdate);

and for the rollback script

delete from employees where emp_id =<seq_value> say 40.

Is it possible to decrement the sequence value. Basically two things I am in doubt

1) How to insert the sequence value in the insert statement. don't see any triggers defined. CONSTRAINT "EMP_ID" PRIMARY KEY ("SEQ_EMP_ID")

2) How to write a proper rollback script by reverting the sequence as well.

Thanks

This post has been answered by BrunoVroman on Jan 7 2019
Jump to Answer
Comments
Post Details
Added on Jan 7 2019
7 comments
913 views