일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | |||||
3 | 4 | 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 | 19 | 20 | 21 | 22 | 23 |
24 | 25 | 26 | 27 | 28 | 29 | 30 |
Tags
- MFC
- JDOM
- GPS
- sencha touch
- appspresso
- 전자정부프레임워크
- rowspan
- 선택적조인
- Eclipse
- phonegap
- iBATIS
- Ajax
- Spring
- 가우스
- Android
- PLSQL
- node.js
- PHP
- jsr 296
- JSON
- ibsheet
- dock
- Struts
- MySQL
- tomcat
- swingx
- Google Map
- jQuery
- oracle
- WebLogic
Archives
- Today
- Total
Where The Streets Have No Name
Consistent error logging greatly simplifies PL/SQL debugging 본문
Developement/DataBase
Consistent error logging greatly simplifies PL/SQL debugging
highheat 2010. 10. 26. 15:03
CREATE TABLE ERRORLOG
(
ID NUMBER NOT NULL,
TIME DATE NOT NULL,
CODE VARCHAR2(9 BYTE) NOT NULL,
MESSAGE VARCHAR2(2000 BYTE) NOT NULL,
PACKAGE_NAME VARCHAR2(100 BYTE),
PROCEDURE_NAME VARCHAR2(100 BYTE) NOT NULL,
LOCATION NUMBER,
PARAMETERS VARCHAR2(4000 BYTE)
);
CREATE SEQUENCE ERRORLOG_ID_SEQ
MINVALUE 1
MAXVALUE 999999999999999999999999999
INCREMENT BY 1
START WITH 1
CACHE 20
NOORDER
NOCYCLE ;
CREATE OR REPLACE TRIGGER T_ERRORLOG_BI
BEFORE INSERT
ON ERRORLOG
REFERENCING OLD AS OLD NEW AS NEW
FOR EACH ROW
begin
if :new.id is null then
select errorlog_id_seq.nextval
into :new.id
from dual;
end if;
end t_errorlog_bi;
ALTER TABLE ERRORLOG ADD (PRIMARY KEY (ID));
CREATE OR REPLACE package pkg_error is
procedure log (p_error_code errorlog.code%type,
p_error_message errorlog.message%type,
p_package errorlog.package_name%type default null,
p_procedure errorlog.procedure_name%type,
p_location errorlog.location%type default null,
p_parameters errorlog.parameters%type default null);
end pkg_error;
CREATE OR REPLACE package body pkg_error is
procedure log (p_error_code errorlog.code%type,
p_error_message errorlog.message%type,
p_package errorlog.package_name%type default null,
p_procedure errorlog.procedure_name%type,
p_location errorlog.location%type default null,
p_parameters errorlog.parameters%type default null) is
pragma autonomous_transaction;
begin
insert
into errorlog
(time,
code,
message,
package_name,
procedure_name,
location,
parameters)
values (sysdate,
p_error_code,
p_error_message,
p_package,
p_procedure,
p_location,
p_parameters);
commit;
end log;
end pkg_error;
CREATE OR REPLACE FUNCTION hello_world RETURN VARCHAR2 IS
v_procedure errorlog.procedure_name%TYPE default 'hello_world';
v_location errorlog.location%TYPE;
BEGIN
v_location := 1000;
return ('hello, world');
EXCEPTION
when others then
pkg_error.log(p_error_code => substr(sqlerrm,1,9),
p_error_message => substr(sqlerrm,12),
p_package => 'FUNCTION',
p_procedure => v_procedure,
p_location => v_location);
END;
http://blogs.techrepublic.com.com/programming-and-development/?p=400