This article is written about how to use the Oracle/PLSQL TO_NUMBER feature with syntax and examples.
Description
The Oracle/PLSQL TO_NUMBER function converts a string to a number.
Syntax
The syntax for the TO_NUMBER feature in Oracle/PLSQL is:
TO_NUMBER( string1 [, format_mask] [, nls_language] )
Parameters or Arguments
string1 The string that will be converted to a number. format_mask Optional. This is the layout that will be used to convert string1 to a number. nls_language Optional. This is the nls language used to convert string1 to a number.
Returns
The TO_NUMBER function returns a numeric value.
Applies To
The TO_NUMBER characteristic can be used in the following versions of Oracle/PLSQL:
Oracle 12c, Oracle 11g, Oracle 10g, Oracle 9i, Oracle 8i
Example
Let’s seem to be at some Oracle TO_NUMBER function examples and explore how to use the TO_NUMBER feature in Oracle/PLSQL.
For example:
TO_NUMBER('1210.73', '9999.99')
Result: 1210.73
TO_NUMBER('546', '999')
Result: 546
TO_NUMBER('23', '99')
Result: 23
Since the format_mask and nls_language parameters are optional, you can honestly convert a text string to a numeric price as follows:
TO_NUMBER('1210.73')
Result: 1210.73
Leave a Review