Data type conversions
Type conversions can happen automatically, or they can be explicitly
requested using the CAST or CONVERT function.
If a string is used in a numeric expression or as an argument to a function
that expects a numeric argument, the string is converted to a number.
If a number is used in a string expression or as a string function argument, it
is converted to a string before being used.
All date constants are specified as strings. The string is automatically
converted to a date before use.
There are certain cases where the automatic database conversions are not
appropriate.
'12/31/90' + 5
'a' > 0
The automatic data type conversion fails here. The CAST or CONVERT
functions can be used to force type conversions. For information about the
CAST and CONVERT functions, see "Data type conversion functions" on
page 304.
The following functions can also be used to force type conversions (see
"SQL Functions" on page 303).
♦
DATE( value )
Converts the expression into a date, and removes any
hours, minutes or seconds. Conversion errors may be reported.
♦
Similar to CAST( value AS CHAR ), except that
STRING( value )
string( NULL ) is the empty string (''), while CAST( NULL AS CHAR )
is the NULL value.
♦
Equivalent to CAST( value AS DECIMAL ).
VALUE+0.0
Chapter 7 SQL Data Types
293
Need help?
Do you have a question about the Adaptive Server Anywhere and is the answer not in the manual?
Questions and answers