구루비에서 많은 도움을 받고 참조를 많이 하고 있습니다. 용어 관리에 있어 좀 더 편하게 할 수 있었으면 합니다. 문의드리고 싶은것은 실제 공통용어는 스페이스로만 분리되어 있으면서 공통용어가(실제용어)를 가지고 컬럼용어 처럼 약어와 약어를 '_'로 연결하고 싶습니다. 단 약어에 등록되어 있지 않은 실제용어는 원문용어 그대로 '_'로 연결하면 좋겠습니다. 약어를 등록한 기준에서 컬럼용어를 좀 더 표준화 시킬 필요에 따라 산업영역에서 사용하는 전문용어를 약어와 약어로 연결시켜서 하나의 컬럼을 (테이블) 활용하려 합니다. 염치없지만 쿼리작성하는데 도움을 주셨으면 합니다. 약어 테이블(TABLE1) 약어 약어원어 한글명 DUR DURATION 기간 ID IDENTIFICATION 구분 DWG DRAWING 도면 AFD ACTUAL FINISH DATE 실적일자 AMH ACTUAL-MANHOUR 실적시수 DTBN DISTRIBUTION 배포 DATE DATE 일자 JOB JOB JOB CODE CODE 코드 MID MIDWAY 중구분 PND PRODUCTION-NEED-DATE 소요일자 PNT PRINT 출력 RCPT RECEIPT 접수 LT LEAD-TIME 소요기간 REQ REQUIRED 접수 QTY QUANTITY 수량 공통용어(실제) 테이블(TABLE2) DURATION IDENTIFICATION DRAWING ACTUAL FINISH DATE DRAWING ACTUAL-MANHOUR DRAWING DISTRIBUTION DATE DRAWING JOB CODE DRAWING MIDWAY CODE DRAWING PRODUCTION-NEED-DATE DRAWING PRINT DRAWING RECEIPT LEAD-TIME DRAWING REQUEST QUANTITY 결과 형태 입니다. 컬럼용어 공통용어(실제) DUR_ID DURATION IDENTIFICATION /*기간구분 DWG_AFD DRAWING ACTUAL FINISH DATE /*도면완료실적일 DWG_AMH DRAWING ACTUAL-MANHOUR /*도면실적시수 DWG_DTBN_DATE DRAWING DISTRIBUTION DATE /*도면배포일자 DWG_JOB_CODE DRAWING JOB CODE /*도면업무코드 DWG_MID_CODE DRAWING MIDWAY CODE /*도면종류중구분코드 DWG_PND DRAWING PRODUCTION-NEED-DATE /*도면소요일 DWG_PNT DRAWING PRINT /*도면 출력 여부 DWG_RCPT_LT DRAWING RECEIPT LEAD-TIME /*도면접수기간 DWG_REQ_QTY DRAWING REQUIRED QUANTITY /*도면청구수량
도움 부탁드립니다.
-- 정규식도 될것 같은데.. 제가 좀 잘 몰라서.. SQL로 WITH TABLE1 (SHORT_NAME , FULL_NAME , KOREA_NAME ) AS ( SELECT 'DUR' , 'DURATION' , '기간' FROM DUAL UNION ALL SELECT 'ID' , 'IDENTIFICATION' , '구분' FROM DUAL UNION ALL SELECT 'DWG' , 'DRAWING' , '도면' FROM DUAL UNION ALL SELECT 'AFD' , 'ACTUAL FINISH DATE' , '실적일자' FROM DUAL UNION ALL SELECT 'AMH' , 'ACTUAL-MANHOUR' , '실적시수' FROM DUAL UNION ALL SELECT 'DTBN' , 'DISTRIBUTION' , '배포' FROM DUAL UNION ALL SELECT 'DATE' , 'DATE' , '일자' FROM DUAL UNION ALL SELECT 'JOB' , 'JOB' , 'JOB' FROM DUAL UNION ALL SELECT 'CODE' , 'CODE' , '코드' FROM DUAL UNION ALL SELECT 'MID' , 'MIDWAY' , '중구분' FROM DUAL UNION ALL SELECT 'PND' , 'PRODUCTION-NEED-DATE' , '소요일자' FROM DUAL UNION ALL SELECT 'PNT' , 'PRINT' , '출력' FROM DUAL UNION ALL SELECT 'RCPT' , 'RECEIPT' , '접수' FROM DUAL UNION ALL SELECT 'LT' , 'LEAD-TIME' , '소요기간' FROM DUAL UNION ALL SELECT 'REQ' , 'REQUIRED' , '접수' FROM DUAL UNION ALL SELECT 'QTY' , 'QUANTITY' , '수량' FROM DUAL ), TABLE2 (TXT ) AS ( SELECT 'DURATION IDENTIFICATION' FROM DUAL UNION ALL SELECT 'DRAWING ACTUAL FINISH DATE' FROM DUAL UNION ALL SELECT 'DRAWING ACTUAL-MANHOUR' FROM DUAL UNION ALL SELECT 'DRAWING DISTRIBUTION DATE' FROM DUAL UNION ALL SELECT 'DRAWING JOB CODE' FROM DUAL UNION ALL SELECT 'DRAWING MIDWAY CODE' FROM DUAL UNION ALL SELECT 'DRAWING PRODUCTION-NEED-DATE' FROM DUAL UNION ALL SELECT 'DRAWING PRINT' FROM DUAL UNION ALL SELECT 'DRAWING RECEIPT LEAD-TIME' FROM DUAL UNION ALL SELECT 'DRAWING REQUEST,REQUIRED QUANTITY' FROM DUAL ) , COPY_T AS ( SELECT LEVEL LV FROM DUAL CONNECT BY LEVEL <=( SELECT MAX(LENGTH(TXT)- LENGTH(REPLACE(TXT,' ','')))+1 FROM TABLE2 ) ) SELECT LISTAGG(B.SHORT_NAME,'_') WITHIN GROUP( ORDER BY A.LV ) "컬럼용어" , A.TXT "공통용어 (실제)" , '/*' || LISTAGG(B.KOREA_NAME,'') WITHIN GROUP( ORDER BY A.LV ) "한글" FROM (SELECT AA.TXT , REGEXP_SUBSTR(AA.TXT,'[^ ]+' , 1 , LV) TOKEN , BB.LV FROM TABLE2 AA , COPY_T BB WHERE REGEXP_COUNT(AA.TXT,' ') + 1 >= LV ) A , TABLE1 B WHERE A.TOKEN = B.FULL_NAME GROUP BY A.TXT ORDER BY 2
SELECT txt , LISTAGG(short_name, '_') WITHIN GROUP(ORDER BY x) short_name , LISTAGG(korea_name ) WITHIN GROUP(ORDER BY x) korea_name FROM (SELECT txt , short_name , korea_name , x , LAG(x + y, 1, 0) OVER(PARTITION BY txt ORDER BY x, y DESC) z FROM (SELECT a.txt , b.short_name , b.korea_name , INSTR(' '||a.txt||' ', ' '||b.full_name||' ') x , LENGTH(b.full_name) y FROM table2 a , table1 b ) WHERE x > 0 ) WHERE x > z GROUP BY txt ORDER BY txt ;