728x90
반응형
오라클 10g부터 정규 표현식을 사용할수 있게 되었다ㅏ.
REGEXP_SUBSTR 란 키워드이다. 아주 간편하게 필터링 할수 있다. ㅎㅎ
REGEXP_SUBSTR 란 키워드이다. 아주 간편하게 필터링 할수 있다. ㅎㅎ
WITH TEMPTABLE AS
(SELECT IF_FILE_NM
FROM
(SELECT 'L6D0POMTK00020111116133559.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1K010POMPKP1020111117134202.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'W100W10002POMT20111122131003.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'E10000SWPOMT20111114232235_7942630.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'H10000GJPOMT201111221532409511.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1M114POMT20111122-184314-487.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1M114POMT20111122-221352-383.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'POGLNTIMK0.GDS.20111114222035' AS IF_FILE_NM
FROM DUAL
)
)
SELECT SUBSTR(REPLACE((REGEXP_SUBSTR(IF_FILE_NM , '([1-9]{1}[0-9]{13}|[1-9]{1}[0-9]{13}_[0-9]{7}|[1-9]{1}[0-9]{13}[0-9]{4}|[1-9]{1}[0-9]{7}-[0-9]{6}-[0-9]{3}).[a-zA-Z]{3}|[1-9]{1}[0-9]{13}$')),'-', '' ) ,0 ,14) AS FILE_CRE_YMD
FROM TEMPTABLE
(SELECT IF_FILE_NM
FROM
(SELECT 'L6D0POMTK00020111116133559.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1K010POMPKP1020111117134202.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'W100W10002POMT20111122131003.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'E10000SWPOMT20111114232235_7942630.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'H10000GJPOMT201111221532409511.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1M114POMT20111122-184314-487.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT '1M114POMT20111122-221352-383.txt' AS IF_FILE_NM
FROM DUAL
UNION
SELECT 'POGLNTIMK0.GDS.20111114222035' AS IF_FILE_NM
FROM DUAL
)
)
SELECT SUBSTR(REPLACE((REGEXP_SUBSTR(IF_FILE_NM , '([1-9]{1}[0-9]{13}|[1-9]{1}[0-9]{13}_[0-9]{7}|[1-9]{1}[0-9]{13}[0-9]{4}|[1-9]{1}[0-9]{7}-[0-9]{6}-[0-9]{3}).[a-zA-Z]{3}|[1-9]{1}[0-9]{13}$')),'-', '' ) ,0 ,14) AS FILE_CRE_YMD
FROM TEMPTABLE
728x90
반응형
'Development > DataBase' 카테고리의 다른 글
SQL 작성시 주의사항 (0) | 2013.02.12 |
---|---|
[Oracle]계층구조 가져오기 (0) | 2013.02.12 |
[Oracle]세로 data를 가로로 변형하기 - LISTAGG (0) | 2011.11.08 |
[Oracle]ORDER BY 절에서 NULL 값 위치 지정 (0) | 2011.09.26 |
[SQL] 테이블명, 컬럼명, PK를 조회할수 있는 쿼리 (0) | 2011.09.01 |