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这张表中去
(
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这张表中去
相关文章推荐
- 13PL_SQL过程之错误处理即捕获异常
- 12PL_SQl过程之三种循环
- 11PL_SQL过程之创建表
- MongoDB安装
- 10PL_SQL过程之执行if语句
- MYSQL-----索引
- 09PL_SQL过程之执行insert语句
- 08PL_SQL过程之执行select语句
- 07PL_SQL过程之复杂数据类型之Record
- 06PL_SQL过程之复杂数据类型Table
- 05PL_SQL过程之使用%type声明变量
- 04PL-SQL过程之声明各种简单变量
- 03PL_SQL过程之捕获异常
- 02PL_SQL过程之声明变量
- 01PL_SQL过程之输出HelloWorld
- spark:scala读取mysql的4种方法
- 数据库结构的设计与如何最大限度的利用索引
- SQL一次性查询一个字段不同条件下的统计结果
- MySQL存储过程
- SQL错误:”***“必须是批处理中仅有的语句