develog

format number 본문

DB/Oracle

format number

냐옴 2013. 2. 13. 20:15

DECLARE


    FUNCTION FN_FORMAT_SCORE(P_SCORE NUMBER)

    RETURN VARCHAR2

    IS

        V_SCORE     VARCHAR2(20);

    BEGIN

        V_SCORE := NVL(P_SCORE, 0);

        V_SCORE := TRIM(TO_CHAR(V_SCORE, '9,990.9'));

        RETURN V_SCORE;

    EXCEPTION

    WHEN OTHERS

    THEN

        RETURN TO_CHAR(NVL(P_SCORE, 0));

    END FN_FORMAT_SCORE;


BEGIN


    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(NULL));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE('0'));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(0));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(100));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(1000));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(1000.9));

    DBMS_OUTPUT.PUT_LINE(FN_FORMAT_SCORE(1007.9));


END;


'DB > Oracle' 카테고리의 다른 글

ORA-04091  (0) 2013.02.26
[oracle] sequence  (0) 2013.02.21
Package  (0) 2013.02.12
Procedure  (0) 2013.02.12
Function  (0) 2013.02.12
Comments