Oracle PL/SQL/Data Type/TO NUMBER
Содержание
Converts the string 970.13 to a number using TO_NUMBER()
<source lang="sql">
SQL> SQL> --------------------------------------------------------------------------------------- SQL> SQL> -- Converts the string 970.13 to a number using TO_NUMBER(): SQL> SQL> SELECT TO_NUMBER("970.13") FROM dual; TO_NUMBER("970.13")
970.13
SQL>
</source>
Convert string to a number and then adds 25.5 to that number
<source lang="sql">
SQL> SQL> -- Convert string to a number and then adds 25.5 to that number: SQL> SQL> SELECT TO_NUMBER("970.13") + 25.5 FROM dual; TO_NUMBER("970.13")+25.5
995.63
SQL> SQL>
</source>
Convert the string to a number and pass the format string $99,999.99 to TO_NUMBER()
<source lang="sql">
SQL> SQL> -- Convert the string to a number and pass the format string $99,999.99 to TO_NUMBER(): SQL> SQL> SELECT TO_NUMBER("-$12,345.67", "$99,999.99") FROM dual; TO_NUMBER("-$12,345.67","$99,999.99")
-12345.67
SQL> SQL> SQL>
</source>
use to_number to convert char to number
<source lang="sql">
SQL> SQL> select to_number( "15" )
2 from dual 3 /
TO_NUMBER("15")
15
1 row selected. SQL> SQL> SQL> --
</source>