매년 연말정산 처리용 프로그램 개발시 유용하게 사용중인 연말정산 간소화파일 XML 파싱 쿼리
나는 매년 그해에 해당하는 간소화파일만 뷰테이블로 만들어서 처리한다.
항목이 너무 많아서 다 적지는 못하지만 대충 이런 느낌으로 작성하면 됨.
CREATE OR REPLACE FORCE VIEW V_YJ_XML
AS
SELECT EXTRACTVALUE(A.XMLDOC, '/yesone/doc/doc_type') AS DOC_TYPE
, EXTRACTVALUE(A.XMLDOC, '/yesone/doc/seq') AS SEQ
, EXTRACTVALUE(A.XMLDOC, '/yesone/doc/att_year') AS ATT_YEAR
, EXTRACTVALUE(A.XMLDOC, '/yesone/doc/att_inqrMm') AS ATT_INQRMM
, EXTRACTVALUE(A.XMLDOC, '/yesone/doc/name') AS BONIN_NAME
, EXTRACTVALUE(B.COLUMN_VALUE, '/form/@form_cd') AS FORM_CD
, EXTRACTVALUE(C.COLUMN_VALUE, '/man/@resid') AS RESID
, EXTRACTVALUE(C.COLUMN_VALUE, '/man/@name') AS NAME
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@dat_cd') AS DAT_CD
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@busnid') AS BUSNID
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@trade_nm') AS TRADE_NM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@acc_no') AS ACC_NO
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@edu_tp') AS EDU_TP
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@edu_cl') AS EDU_CL
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@use_place_cd') AS USE_PLACE_CD
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/goods_nm') AS GOODS_NM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/insu_resid') AS INSU_RESID
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/insu_nm') AS INSU_NM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/insu1_resid') AS INSU1_RESID
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/insu1_nm') AS INSU1_NM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/typeCd') AS TYPECD
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum') AS SUM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@ddct') AS SUM_DDCT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]') AS MM01
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@date') AS MM01_DATE
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@fix_cd') AS MM01_FIX_CD
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@hi_ntf') AS MM01_HI_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@ltrm_ntf') AS MM01_LTRM_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@hi_pmt') AS MM01_HI_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@ltrm_pmt') AS MM01_LTRM_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@hi_yrs') AS SUM_HI_YRS
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@ltrm_yrs') AS SUM_LTRM_YRS
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@hi_ntf') AS SUM_HI_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@ltrm_ntf') AS SUM_LTRM_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@hi_pmt') AS SUM_HI_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@ltrm_pmt') AS SUM_LTRM_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@wrkp_ntf') AS MM01_WRKP_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@rgn_pmt') AS MM01_RGN_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@apln') AS MM01_APLN
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/amt[@mm="01"]/@sum') AS MM01_SUM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@sp_ntf') AS SUM_SP_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@spym') AS SUM_SPYM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@jlc') AS SUM_JLC
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@ntf') AS SUM_NTF
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sum/@pmt') AS SUM_PMT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/sbdy_apln_sum') AS SBDY_APLN_SUM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/conb_sum') AS CONB_SUM
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/@pwd_cd') AS PWD_CD
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/ctr_term_mm_cnt') AS CTR_TERM_MM_CNT
, EXTRACTVALUE(D.COLUMN_VALUE, '/data/edu_end') AS EDU_END
FROM (SELECT INSA_NO
, XMLTYPE(XML_DATA) XMLDOC
FROM YJ_XML_M
WHERE 1 = 1
AND YEAR = '2021') A
, XMLTABLE('/yesone/form'
PASSING A.XMLDOC) B
, XMLTABLE('/form/man'
PASSING B.COLUMN_VALUE) C
, XMLTABLE('/man/data'
PASSING C.COLUMN_VALUE) D
;
'DataBase > Oracle' 카테고리의 다른 글
오라클 정규식 모음 (0) | 2018.03.20 |
---|---|
64비트 윈도우10에 설치된 파워빌더 7에서 오라클 9 데이터베이스 32비트 ODBC 이용해서 연결하기 (0) | 2016.03.31 |
Oracle Client 설치 방법 (0) | 2013.11.05 |