begin
  insert ....
  update ....
  commit;
exception
  {错误处理}
end
若SQL执行时出错,系统会自动roolback,否则commit

解决方案 »

  1.   

    ...
       insert ...;
       update ....;
       ...
       commit;
       exception
          when others then
              rollback;
      

  2.   

    出现异常后回滚,你也可把异常记下来
    declare Error_code number;
    Error_msg varchar2(250);
    begin
    ...
    exception
    ...
          when others then
          Error_code := SQLCODE;
          Error_msg :=SQLERRM;
          dbms_output.putline(tochar(sqlcode) || ':' || sqlerrm;
              rollback;
    ...
    end;
      

  3.   

    sxychee(一笑):说的很对,但要用:dbms_output.putline显示,必须首先运行:set serveroutput on