Why does To_char (3E4) not result in '3E4'?

3

How do I convert an exponential number (NUMBER) to string (VARCHAR) but which is expressed equal to?

Example:

SQL> SELECT   TO_CHAR (NUMERO) NUMCONVERT
  2    FROM   (SELECT   3E4 NUMERO FROM DUAL);

NUMCONVERT
----------------------------------------
30000

How to return '3E4' ??

    
asked by anonymous 13.04.2017 / 18:37

2 answers

1

Try this:

TO_CHAR(number, '9.9EEEE')

Source: link

    
13.04.2017 / 18:50
0

Using only TO_CHAR(numero,'FM9.9EEEE') , returns:

  

3.E + 04

But since you want me to stay the same way, I did a Gambiarra :

   SELECT REPLACE(
             REPLACE(
                REPLACE(TO_CHAR(numero,'FM9.9EEEE'),
                'E+0','e')
             ,'E+','e')
           ,'.','') numconvert
      FROM (SELECT 3e4 as numero
              FROM dual);

Returning:

  

3e4

I hope it helps.

    
13.04.2017 / 19:09