Oracle® OLAP Expression Syntax Reference Release 11.2 E23381-01 |
|
|
PDF · Mobi · ePub |
CAST
converts values from one data type to another.
The data type specified by type_name
.
CAST(expr AS type_name)
expr
can be an expression in one of the data types.
type_name
is one of the data types listed in Table 1-2, "Dimensional Data Types".
Table 3-1 shows which data types can be cast into which other built-in data types. NUMBER
includes NUMBER
, DECIMAL
, and INTEGER
. DATETIME
includes DATE
, TIMESTAMP
, TIMESTAMP WITH TIMEZONE
, and TIMESTAMP WITH LOCAL TIMEZONE
. INTERVAL
includes INTERVAL DAY TO SECOND
and INTERVAL YEAR TO MONTH
.
Table 3-1 Compatible Data Types
From | To BINARY_FLOAT, BINARY_DOUBLE | To CHAR, VARCHAR2 | To NUMBER | To DATETIME, INTERVAL | To NCHAR, NVARCHAR2 |
---|---|---|---|---|---|
BINARY_FLOAT, BINARY_DOUBLE |
yes |
yes |
yes |
no |
yes |
CHAR, VARCHAR2 |
yes |
yes |
yes |
yes |
no |
NUMBER |
yes |
yes |
yes |
no |
yes |
DATETIME, INTERVAL |
no |
yes |
no |
yes |
yes |
NCHAR, NVARCHAR2 |
yes |
no |
yes |
no |
yes |
CAST('123.4567' AS NUMBER(10,2))
returns the value 123.46
.