TECH
QUESTION
자주하는 질문답변 입니다.
Oracle
작성자 | 유건데이타 | 등록일 | 2015-05-16 |
제목 | 문자 TYPE의 COLUMN에 대해서 숫자 여부 확인하는 방법(ISDIGIT) | ||
---|---|---|---|
문자 TYPE의 COLUMN에 대해서 숫자 여부 확인하는 방법(ISDIGIT)
========================================================= PURPOSE -------- 다음은 문자 Type 의 Data 가 숫자로 변환될 수 있는지 확인하는 몇가지 방법에 대해 소개한다. Explanation ----------- Example ------- 방법1) Translate function 으로 check 한다. 예) if translate( col, '0123456789','9999999999' ) = '9999999999' then .... 방법2) Pl/sql Block 에서 to_number시 'invalid_number' exception 처리한다. 예) begin .. select to_number( col ) from dual; .. exception when invalid_number then .. end; 방법3) 임의의 User-Defined Funcion 을 생성하여 사용한다. 예) create or replace function isdigit( str in varchar2) return boolean is function sub_isdigit( str in varchar2 ) return boolean is begin if (str is null) then return true; elsif (substr(str,1,1)>'9') then return false; else return sub_isdigit(substr(str,2)); end if; end; begin if (str is null) then return false; else return sub_isdigit(str); end if; end; / Function created. 위에 생성된 isdigit function 을 사용한다. Reference Document ------------------ |
Comment | |||
---|---|---|---|
등록된 코멘트가 없습니다. |