ALLBASE/SQL Reference Manual (36216-90216)

238 Chapter8
Expressions
CAST Function
CAST Function
The CAST function converts data from one data type to another. The CAST function can be
used anywhere a general expression is allowed. CAST is supported inside functions that
support expressions including aggregate functions. CAST also takes general expressions
including nested functions as input.
Scope
SQL Data Manipulation Statements
SQL Syntax
{ CAST ( { Expression
NULL} { AS
,} DataType [,FormatSpec]) }
Parameters
Expression
is the value to be converted. See the "Expression" section in this chapter
for details on the syntax.
DataType
ALLBASE/SQL data type: CHAR(n), VARCHAR(n), DECIMAL(p[,s]),
FLOAT, REAL, INTEGER, SMALLINT, DATE, TIME, DATETIME,
INTERVAL, BINARY(n), VARBINARY(n), TID.
The LONG BINARY(n) and LONG VARBINARY(n) cannot be used in the
CAST operations.
FormatSpec
Format specification used for DATE, TIME, DATETIME, INTERVAL
conversions.
FormatSpec
is the same as that used in the date/time
conversion functions.
Description
The following table shows what data type conversions the CAST function supports. These
are the status codes used in the table:
Y—is supported
N—is not supported
E—is an ALLBASE/SQL Extension (not a part of ANSI standard)