Oracle:级联时,大量数字转换为科学计数法(40位)

时间:2018-09-11 14:12:30

标签: sql oracle concatenation

Oracle在串联时将Number转换为字符串或将其移动到_char。

示例:

select value from tab;
value
9076725748515642018090620180906173606980000000000000000000000000000000000000000

select RPAD(value,LENGTH(value)+1,chr(135)) from tab;

RPAD(value,LENGTH(value)+1,chr(135))
9.0767257485156420180906201809061736E+78‡

预期结果

9076725748515642018090620180906173606980000000000000000000000000000000000000000‡

1 个答案:

答案 0 :(得分:0)

也许PL / SQL可以为您提供帮助。您可以尝试以下脚本。

CREATE OR REPLACE FUNCTION test123 (p_number NUMBER) return VARCHAR2
IS
    v_no VARCHAR2(100);
BEGIN
    EXECUTE IMMEDIATE 
     'select '''||p_number||'''||CHR(135) '||
      ' from dual'
      INTO v_no;
    RETURN v_no;
END;
/

SELECT TEST123(9076725748515642018090620180906173606980000000000000000000000000000000000000000) 
FROM DUAL;

OUTPUT                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
--------------------------------------------------------------------------------
9076725748515642018090620180906173606980000000000000000000000000000000000000000‡