The TO_NUMBER function in Oracle converts a string into a numeric value. It takes a string argument, with the optional format_mask specifying the number format in the string. It returns a value of type NUMBER, or NULL if the conversion fails.
TO_NUMBER function usage in Oracle
TO_NUMBER function is used to convert a string or text value into a numeric value. It is a built-in function widely used in data conversion and calculations.
Syntax:
TO_NUMBER(string, [format_mask])
Parameters:
Example:
Convert the string "123.45" to the number 123.45:
SELECT TO_NUMBER('123.45') FROM DUAL;
Parse the string "1,234.56" into a number 1234.56, mask "9G999G999" Specify thousands separator and two decimal points:
SELECT TO_NUMBER('1,234.56', '9G999G999') FROM DUAL;
Get a string value from the table and convert it to a number:
SELECT TO_NUMBER(column_name) FROM table_name;
Return type :
TO_NUMBER function returns a numeric value of NUMBER data type. If the conversion fails, it returns NULL.
Note:
The above is the detailed content of Tonumber usage in oracle. For more information, please follow other related articles on the PHP Chinese website!