db2의 진단로그(db2diag.log) 파일은 db2diag 유틸리티와 –fmt 옵션으로 포맷을 수정할 수 있다.
이외에도 테이블 함수를 사용해서 진단로그 내용을 SQL 방식으로 조회가 가능하다.
단 문제는 MSG 컬럼의 내용이 “줄바꿈”처리 되어 있는 경우 결과 값이 흐트러져서 나오는 문제점이 있다.
이 경우는 db2diag –fmt 옵션으로 볼 때도 마찬가지로 줄이 바뀌어져서 흐트러진다.
테이블 함수로 “줄 바꿈”하지 않고 처리할 수 있는 방법을 생각하다가 다음과 같은 함수를 사용해서 줄바꿈처리를 못하도록 변경할 수 있었다.
select varchar(replace (MSG, CHR(10),’ ‘),1024) msg from TABLE(PD_GET_DIAG_HIST(‘MAIN’,’D’,’’,CAST(NULL as timestamp), CAST(NULL as timestamp),-2)) as T |
Carriage Return 의 아스키 값이 14와 10이 있는데 db2diag 로그의 줄바꿈은 10번 값으로 되어져 있는 듯 하다.
테스트
select varchar(replace(MSG,CHR(10),' '),1024) msg |
결과
MSG 10 레코드가 선택되었습니다. |
줄바꿈처리를 하지 않은 경우
select varchar(MSG, 1024) msg |
- 10 레코드가 선택되었습니다. |
'Note' 카테고리의 다른 글
[설치] Activation Code 및 버전 EOS (0) | 2013.04.26 |
---|---|
[설치] CentOS 6 64bit에서 DB2 V10.1 설치를 위한 Library 설정 (0) | 2013.04.26 |
[SQL] 오라클 호환성 VARCHAR2 (0) | 2013.03.20 |
[권한] 사용자에게 테이블 생성 및 DML만 하게 하려면? (0) | 2013.03.07 |
[SQL] 변경된 데이터 추적 및 V10의 신기능 시간 테이블 (Temporal Table) (0) | 2013.02.14 |