CAST
Description of the illustration cast.gif
CAST
converts one built-in datatype or collection-typed value into another built-in datatype or collection-typed value.CAST
lets you convert built-in datatypes or collection-typed values of one type into another built-in datatype or collection type. You can cast an unnamed operand (such as a date or the result set of a subquery) or a named collection (such as a varray or a nested table) into a type-compatible datatype or named collection. The type_name
must be the name of a built-in datatype or collection type and the operand must be a built-in datatype or must evaluate to a collection value.
For the operand,
expr
can be either a built-in datatype, a collection type, or an instance of an ANYDATA
type. If expr
is an instance of an ANYDATA
type, then CAST
tries to extract the value of the ANYDATA
instance and return it if it matches the cast target type, otherwise, null will be returned. MULTISET
informs Oracle Database to take the result set of the subquery and return a collection value. Table 5-1 shows which built-in datatypes can be cast into which other built-in datatypes. (CAST
does not support LONG
, LONG
RAW
, or the Oracle-supplied types.)CAST
does not directly support any of the LOB datatypes. When you use CAST
to convert a CLOB
value into a character datatype or a BLOB
value into the RAW
datatype, the database implicitly converts the LOB value to character or raw data and then explicitly casts the resulting value into the target datatype. If the resulting value is larger than the target type, then the database returns an error.
When you use
CAST
... MULTISET
to get a collection value, each select list item in the query passed to theCAST
function is converted to the corresponding attribute type of the target collection element type.
No comments:
Post a Comment