Oracle PL/SQL/Data Type/TO NUMBER
Версия от 13:45, 26 мая 2010; (обсуждение)
Содержание
Converts the string 970.13 to a number using TO_NUMBER()
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>
Convert string to a number and then adds 25.5 to that number
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>
Convert the string to a number and pass the format string $99,999.99 to TO_NUMBER()
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>
use to_number to convert char to number
SQL>
SQL> select to_number( "15" )
2 from dual
3 /
TO_NUMBER("15")
---------------
15
1 row selected.
SQL>
SQL>
SQL> --