您的位置:首页 > 数据库

14PL_SQL之用表存储错误信息

2016-06-26 20:26 141 查看
create table errorlog

(

  id number primary key,

  errcode number,

  errmsg varchar2(1024),

  errdate date

)

创建一张存储错误信息的表

create sequence seq_errorlog_id start with 1 increment by 1

创建一个序列

declare

  v_deptno emp.deptno%type:=10;

  v_errcode number;

  v_errmsg varchar2(1024);

begin

  delete from dept where deptno = v_deptno;

  commit;

  exception

    when others then

      rollback;

      v_errcode:=SQLCODE;

      v_errmsg:=SQLERRM;

      insert into errorlog values(seq_errorlog_id.nextval,v_errcode,v_errmsg,sysdate);

      commit;

end;

执行一段代码,如果出现异常则插入到errorlog这张表中去
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: