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!

How to make pl/sql procedure not auto-commit?

581054Jun 26 2007 — edited Jun 27 2007
I wish to be able to execute a create statement, and then rollback if there is a problem with any sql that follows. It seems that you cannot rollback? Why is this?

(My problem is that I wish to execute a series of sql statements and run a rollback if anything before it fails, including the creation of the table)
set serveroutput on;
declare
  rcount INTEGER;
PRAGMA AUTONOMOUS_TRANSACTION;
begin
  execute immediate 'create table bsdconv_s1stc_code (id number)';
  dbms_output.put_line('Table created successfully');
  rollback;
exception
  when others then dbms_output.put_line('Error while creating table. Probably already exists.');
end;
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 25 2007
Added on Jun 26 2007
10 comments
932 views