如何获取以字符/字母形式输出的数字/数字? 就像我输入:-1234 那么输出应该像:-一二三四与(在其他情况下)一个 1,234。
答案 0 :(得分:2)
尝试一下
select to_char(to_date(1234, 'j'), 'jsp') from dual
输出将是 1,234
答案 1 :(得分:0)
执行以下功能。
CREATE OR REPLACE FUNCTION NUMTOWORDS (P_IN IN NUMBER)
RETURN VARCHAR2
IS
V_WORDS VARCHAR2 (20) := '';
V_CHAR VARCHAR2 (20) := '';
V_LENGTH NUMBER;
TYPE ARRAY_TYPE IS VARRAY (10) OF VARCHAR2 (10);
V_ARRAY ARRAY_TYPE := ARRAY_TYPE ('ZERO', 'ONE', 'TWO', 'THREE', 'FOUR', 'FIVE', 'SIX', 'SEVEN', 'EIGHT', 'NINE');
BEGIN
SELECT LENGTH (TO_CHAR (P_IN)) INTO V_LENGTH FROM DUAL;
FOR I IN 1 .. V_LENGTH
LOOP
V_CHAR := V_ARRAY ( (TO_NUMBER (SUBSTR (TO_CHAR (P_IN), I, 1)) + 1));
V_WORDS := CONCAT (V_WORDS, CONCAT (V_CHAR, ' '));
END LOOP;
RETURN TRIM (V_WORDS);
END;
“”“从DUAL中选择NUMTOWORDS(674);