0% found this document useful (0 votes)
16 views

ConversionFunctions CheatSheet

Uploaded by

chanduvenu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

ConversionFunctions CheatSheet

Uploaded by

chanduvenu
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Cheat Sheet: Conversion Functions

TO_CHAR(number):
Converts the number or expression passed as parameter to a string of the varchar2 data type.

Syntax:
TO_CHAR(number[,format[,’nls_parameter’]])

The format and nls_parameter arguments are optional. If you omit them the function uses the default parameter values for your session.

TO_NUMBER:
Converts the string passed as parameter to a value of the number data type.

Syntax:
TO_NUMBER(string [DEFAULT return_value ON CONVERSION ERROR][,format[,’nls_parameter’]])

The ON CONVERSION ERROR clause is optional. If it is present and the conversion fails, the function returns return_value.

The format and nls_parameter arguments are optional and work in the same way as in the TO_CHAR function when applied to numbers (see
above).

TO_CHAR(date):
Converts the date or expression passed as parameter to a string of the varchar2 data type.

Syntax:
TO_CHAR(date[,format[,’nls_parameter’]])

The format and nls_parameter arguments are optional. If you omit them the function uses the default parameter values for your session.

TO_DATE:
Converts the string passed as parameter to a value of the date data type.

Syntax:
TO_DATE(string [DEFAULT return_value ON CONVERSION ERROR][,format[,’nls_parameter’]])

The ON CONVERSION ERROR clause is optional. If it is present and the conversion fails, the function returns return_value.

The format and nls_parameter arguments are optional. If you omit them the function uses the default parameter values for your session.

CAST:
Converts the expression passed as parameter to a value of the specified data type.

Syntax:
CAST(expression AS type_name [DEFAULT return_value ON CONVERSION ERROR] [,format[,’nls_parameter’]])

The ON CONVERSION ERROR clause is optional. If it is present and the conversion fails, the function returns return_value. This clause might not
be allowed depending on the type conversion being performed.

The format and nls_parameter arguments are optional. If you omit them the function uses the default parameter values for your session. These
parameters might not be allowed depending on the type conversion being performed.

VALIDATE_CONVERSION:
Determines whether the expression passed as parameter can be converted to the specified data type.

Syntax:
VALIDATE_CONVERSION(expression AS type_name] [,format[,’nls_parameter’]])

Only some data type conversions can be tested with this function.

If expression can successfully be converted to type_name it returns 1, otherwise returns 0.

The format and nls_parameter arguments are optional. If you omit them the function uses the default parameter values for your session.

sql.standout-dev.com

You might also like