PL_SQL基础--续三
2009-06-01 00:37
239 查看
DBA通常建立error日志:
1.建立日志表:
create table errorlog
(
id number primary key,
errcode number,
errmsg varchar2(1024),
errdate date
);
2.建立序列
create sequence seq_errorlog_id start with 1 increment by 1;
3.PL_SQL中运用
declare
v_deptno dept.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;
--查看出错具体时间
select to_char(errdate,'YYYY-MM-DD HH24:MI:SS') from errorlog;
1.建立日志表:
create table errorlog
(
id number primary key,
errcode number,
errmsg varchar2(1024),
errdate date
);
2.建立序列
create sequence seq_errorlog_id start with 1 increment by 1;
3.PL_SQL中运用
declare
v_deptno dept.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;
--查看出错具体时间
select to_char(errdate,'YYYY-MM-DD HH24:MI:SS') from errorlog;
相关文章推荐
- pl/sql编程基础
- Oracle PL/SQL 编程基础 实例
- Oracle PL/SQL开发基础(第十弹:子查询)
- PL/SQL - 基础知识(2)
- PL_SQL基础--续四
- PL/SQL 编程(一)基础,变量,分支,循环,异常
- PL/SQL 基础 ( 下 )
- Oracle 笔记(七)、PL/SQL 基础
- PL/SQL编程基础
- Oracle PL/SQL开发基础(第二十一弹:基本函数)
- pl/sql编程基础
- PL/SQL学习笔记[1]-基础
- Oracle PL/SQL语言基础
- Oracle(PL/SQL编程基础(PL/SQL程序块与PL/SQL语句)、异常、游标、数据类型)
- [转贴]Oracle PL/SQL语言基础
- Oracle PL/SQL语言基础
- oracle实战第六天--pl/sql介绍和基础
- Oracle PL/SQL语言入门基础
- PL/SQL基础
- 原创:oracle PL/SQL编程基础 上<十一>