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!

COMMIT AND ROLLBACK IN EXCEPTION

Ricky007Nov 8 2017 — edited Nov 8 2017

Dear experts,

                i have three dml statement, my second dml statement should get commit always.

create table test1

(

t1_id number(2)

);

create table test2

(

t2_id number(2)

);

create table test3

(

t3_id number(2)

);

Here first and second dml is valid with size precision,

I want to rollback first DML statement if 3 statement fails.

in my case it is getting inserted in test1. i do not want to insert IN TEST1 if third statement fails but my second

DML should get insert and  commit

Tried block

----------

here my first statement is getting commit;

DECLARE

BEGIN

begin

INSERT INTO TEST1 VALUES(10);

exception

when others then

rollback;

end;

begin

INSERT INTO TEST2 VALUES(10);

commit;

exception

when others then

rollback;

end;

begin

INSERT INTO TEST3 VALUES(100);

exception

when others then

rollback;

end;

END;

please help

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 6 2017
Added on Nov 8 2017
17 comments
2,835 views