Program/Oracle
소숫점 이하 자릿수 가져오기(Function)
SILF
2011. 12. 21. 16:44
--숫자가 아니면 -1(단, '4.' 같은 경우는 0으로 표기)
CREATE OR REPLACE FUNCTION isDECIMALPOINT (p_num IN VARCHAR2) RETURN NUMBER
AS
l_tst NUMBER;
BEGIN
l_tst := TO_NUMBER(p_num);
if INSTR(p_num,'.')>0 then
if SUBSTR(p_num,INSTR(p_num,'.')+1) is null then
return 0;
else
RETURN length(SUBSTR(p_num,INSTR(p_num,'.')+1));
end if;
else
RETURN 0;
end if;
EXCEPTION
WHEN OTHERS THEN
RETURN -1;
END;
/
CREATE OR REPLACE FUNCTION isDECIMALPOINT (p_num IN VARCHAR2) RETURN NUMBER
AS
l_tst NUMBER;
BEGIN
l_tst := TO_NUMBER(p_num);
if INSTR(p_num,'.')>0 then
if SUBSTR(p_num,INSTR(p_num,'.')+1) is null then
return 0;
else
RETURN length(SUBSTR(p_num,INSTR(p_num,'.')+1));
end if;
else
RETURN 0;
end if;
EXCEPTION
WHEN OTHERS THEN
RETURN -1;
END;
/