If you do not indicate a length for character string types, an appropriate length is chosen. If neither precision nor scale
is specified for a DECIMAL conversion, the database server selects appropriate values.
If you use the CAST function to truncate strings, the string_rtruncation database option must be set to OFF; otherwise, there
will be an error. It is recommended that you use the LEFT function to truncate strings.
The CAST function is a core feature of the SQL/2008 standard. However, in SQL Anywhere CAST supports a number of data
type conversions that are not permitted by the SQL standard. For example, in SQL Anywhere you can CAST an integer value to
a DATE type, whereas in the SQL standard this type conversion is not permitted. For more information, see Data type conversions.
The following function ensures a string is used as a date:
SELECT CAST( '2000-10-31' AS DATE );
The value of the expression 1 + 2 is calculated, and the result is then cast into a single-character string.
SELECT CAST( 1 + 2 AS CHAR );
Casting between VARCHAR and ST_GEOMETRY is usually implicit. For example, the following statement adds values to ST_GEOMETRY
columns using the ST_POINT function and a VARCHAR. Each value is implicitly cast to an ST_GEOMETRY data type consistent with
the table columns, but results still appear as VARCHAR.
INSERT INTO T1 VALUES (2, ST_POINT(1,2,0), 'SRID=2163;Point(1 2)');