SQL 4 Oracle 오라클용 sql 실무

SQL4Oracle

replace가 꼭 필요한 시점

돌프1 2023. 3. 10. 14:14

2011-08-22 10:20:34


SQL 4 Oracle 오라클용 sql 실무
▒ replace가 꼭 필요한 시점

 

웹상에서 문제를 일으키는 select 결과에 포함된 특수문자 처리

 


▒ html 태그로 오인 받는 "<", ">" 문자 처리
select trim(replace(비고,'<','['))
from 목적_Table
where 고객상태='활동중'
    and 비고 like '%<%'

 

update 목적_Table
     set 비고 = trim(replace(비고,'<','['))
where 고객상태='활동중'
    and 비고 like '%<%' ;
commit;

 

select trim(replace(비고,'>',']'))
from 목적_Table
where 고객상태='활동중'
    and 비고 like '%>%'

 

update 목적_Table
     set 비고 = trim(replace(비고,'>',']'))
where 고객상태='활동중'
    and 비고 like '%>%' ;
commit; 


▒ 문자열 구분으로 오인받는 "'" 문자 처리 (I'PARK 등)
select replace(주소,'''','-')
from 주소_Table
where 주소 like '%I'||''''||'PARK%'

 

update 주소_Table
     set 주소 = replace(주소,'''','-')
where 주소 like '%I'||''''||'PARK%' ;
commit; 

'SQL4Oracle' 카테고리의 다른 글

TABLESPACE 당 사용율 조회  (0) 2023.03.10
메인 Table 안에서 OVER함수 이용 다중고객 계산하기  (0) 2023.03.10
재미있는 DUAL 테이블2  (0) 2023.03.10
재미있는 DUAL 테이블  (0) 2023.03.10
회차 구간별 집계  (0) 2023.03.10