마농님의 강의가 있습니다. ^^*
"[퀴즈] 숫자를 한글로 표기"
http://www.gurubee.net/article/49942
DECLARE CURSOR c1 IS WITH t AS ( SELECT 12345678 amt FROM dual UNION ALL SELECT 1234567890 amt FROM dual ) SELECT TRANSLATE ( SUBSTR(v, 1,1)||DECODE(SUBSTR(v, 1,1),0,'','천') || SUBSTR(v, 2,1)||DECODE(SUBSTR(v, 2,1),0,'','백') || SUBSTR(v, 3,1)||DECODE(SUBSTR(v, 3,1),0,'','십') || SUBSTR(v, 4,1)||DECODE(SUBSTR(v, 1,4),0,'','조') || SUBSTR(v, 5,1)||DECODE(SUBSTR(v, 5,1),0,'','천') || SUBSTR(v, 6,1)||DECODE(SUBSTR(v, 6,1),0,'','백') || SUBSTR(v, 7,1)||DECODE(SUBSTR(v, 7,1),0,'','십') || SUBSTR(v, 8,1)||DECODE(SUBSTR(v, 5,4),0,'','억') || SUBSTR(v, 9,1)||DECODE(SUBSTR(v, 9,1),0,'','천') || SUBSTR(v,10,1)||DECODE(SUBSTR(v,10,1),0,'','백') || SUBSTR(v,11,1)||DECODE(SUBSTR(v,11,1),0,'','십') || SUBSTR(v,12,1)||DECODE(SUBSTR(v, 9,4),0,'','만') || SUBSTR(v,13,1)||DECODE(SUBSTR(v,13,1),0,'','천') || SUBSTR(v,14,1)||DECODE(SUBSTR(v,14,1),0,'','백') || SUBSTR(v,15,1)||DECODE(SUBSTR(v,15,1),0,'','십') || SUBSTR(v,16,1) , '1234567890', '일이삼사오육칠팔구') || '원' v FROM (SELECT LPAD(amt, 16, '0') v FROM t) ; BEGIN FOR c IN c1 LOOP dbms_output.put_line(c.v); END LOOP; END; /
DECLARE CURSOR c1 IS WITH t AS ( SELECT 12345678 amt FROM dual UNION ALL SELECT 1234567890 amt FROM dual UNION ALL SELECT 12345678901234567890 amt FROM dual UNION ALL SELECT 0 amt FROM dual ) SELECT * FROM t ; v_amt VARCHAR2(20); v_tmp VARCHAR2(4); v_rtn VARCHAR2(100); BEGIN FOR c IN c1 LOOP v_rtn := ''; v_amt := LPAD(c.amt, 20, '0'); FOR i IN 1..5 LOOP v_tmp := SUBSTR(v_amt, i*4-3, 4); IF v_tmp != '0000' THEN FOR j IN 1..4 LOOP IF SUBSTR(v_tmp, j, 1) != '0' THEN v_rtn := v_rtn || SUBSTR(v_tmp, j, 1) || SUBSTR('천백십', j, 1); END IF; END LOOP; v_rtn := v_rtn || SUBSTR('경조억만', i, 1); END IF; END LOOP; v_rtn := TRANSLATE(v_rtn, '1234567890', '일이삼사오육칠팔구'); v_rtn := NVL(v_rtn, '영') || '원'; dbms_output.put_line(v_rtn); END LOOP; END; /