Conversion functions

The following table describes the supported conversion functions.

Function Description
ASCIISTR Returns an ASCII version of a string in the database character set. Non-ASCII characters are converted to the form \xxxx, where xxxx is a UTF-16 code unit.
BIN_TO_NUM Converts a bit vector to its numeric equivalent. Each argument must evaluate to 0 or 1 and can be a numeric type or implicitly convertible to NUMBER. Returns an Oracle NUMBER.
CAST Converts a built-in data type or collection-typed value to another type. The operand can be a built-in value, expression, or collection, and the target type_name must be a compatible built-in or collection type.
CHARTOROWID Converts a CHAR, VARCHAR2, NCHAR, or NVARCHAR2 value to a ROWID.
COMPOSE Applies Unicode canonical composition (definition D117) to char and returns the result. If the argument’s character set is not Unicode, returns the argument unmodified.
CONVERT Converts a character string from one character set to another.
DECOMPOSE Applies a Unicode decomposition to string and returns the result. The decomposition type is determined by the optional second parameter. If string is not in a Unicode character set, returns it unmodified.
HEXTORAW Converts char containing hexadecimal digits in CHAR, VARCHAR2, NCHAR, or NVARCHAR2 to a RAW value.
NUMTODSINTERVAL Converts n to an INTERVAL DAY TO SECOND literal. The argument n can be any NUMBER or an expression implicitly convertible to NUMBER. The interval_unit must be CHAR, VARCHAR2, NCHAR, or NVARCHAR2.
NUMTOYMINTERVAL Converts n to an INTERVAL YEAR TO MONTH literal. The argument n can be any NUMBER or an expression implicitly convertible to NUMBER. The interval_unit must be CHAR, VARCHAR2, NCHAR, or NVARCHAR2.
RAWTOHEX Converts raw to a character value containing its hexadecimal representation.
RAWTONHEX Converts raw to a character value containing its hexadecimal representation in the national character set. Equivalent to TO_NCHAR(RAWTOHEX(raw)).
ROWIDTOCHAR Converts a ROWID value to an 18-character VARCHAR2.
ROWIDTONCHAR Converts a ROWID value to an 18-character NVARCHAR2 in the national character set.
SCN_TO_TIMESTAMP Converts a system change number (SCN) to the approximate timestamp associated with it. Returns a TIMESTAMP value. Useful for associating an SCN with a point in time, for example when used with the ORA_ROWSCN pseudocolumn.
TIMESTAMP_TO_SCN Converts a TIMESTAMP value to the approximate system change number (SCN) associated with it. Returns a NUMBER value. Useful for obtaining the SCN for a given point in time.
TO_BINARY_DOUBLE Converts expr to a double-precision floating-point (BINARY_DOUBLE) value.
TO_BINARY_FLOAT Converts expr to a single-precision floating-point (BINARY_FLOAT) value.
TO_BLOB (bfile) Converts a BFILE value to a BLOB value.
TO_BLOB (raw) Converts LONG RAW or RAW values to BLOB values.
TO_CHAR (bfile\|blob) Converts BFILE or BLOB data to the database character set. Always returns a VARCHAR2 value. If the result exceeds the VARCHAR2 size limit, the data is truncated.
TO_CHAR (character) Converts NCHAR, NVARCHAR2, CLOB, or NCLOB data to the database character set. Always returns a VARCHAR2 value.
TO_CHAR (datetime) Converts a datetime or interval (DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH LOCAL TIME ZONE, INTERVAL DAY TO SECOND, or INTERVAL YEAR TO MONTH) to a VARCHAR2 value using the date format model fmt.
TO_CHAR (number) Converts n to a VARCHAR2 value using the optional number format model fmt. The argument n can be NUMBER, BINARY_FLOAT, or BINARY_DOUBLE. If fmt is omitted, n is converted to a VARCHAR2 just long enough to hold its significant digits.
TO_CLOB (bfile\|blob) Converts BFILE or BLOB data to the database character set and returns it as a CLOB value.
TO_CLOB (character) Converts NCLOB or other character data (CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB) to a CLOB. Oracle Database performs the conversion from the national character set to the database character set.
TO_DATE Converts char to a DATE value.
TO_DSINTERVAL Converts its argument to an INTERVAL DAY TO SECOND value.
TO_LOB Converts LONG or LONG RAW column values to LOB values. Can be used only on LONG or LONG RAW columns and only in the select list of a subquery within an INSERT statement.
TO_MULTI_BYTE Returns char with all single-byte characters converted to their corresponding multibyte characters. Accepts CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The return value has the same data type as char.
TO_NCHAR (character) Converts a character value (CHAR, VARCHAR2, CLOB, or NCLOB) to the national character set. Always returns an NVARCHAR2. Equivalent to using the TRANSLATE ... USING function with the national character set.
TO_NCHAR (datetime) Converts a datetime or interval (DATE, TIMESTAMP, TIMESTAMP WITH TIME ZONE, TIMESTAMP WITH LOCAL TIME ZONE, INTERVAL YEAR TO MONTH, or INTERVAL DAY TO SECOND) from the database character set to the national character set.
TO_NCHAR (number) Converts n (NUMBER, BINARY_FLOAT, or BINARY_DOUBLE) to a string in the national character set. Returns a value of the same type as the argument. Supports the optional format model fmt and nlsparam.
TO_NCLOB Converts CLOB or other character data (CHAR, VARCHAR2, NCHAR, NVARCHAR2, CLOB, or NCLOB) to an NCLOB. Oracle Database performs the conversion from the database character set to the national character set.
TO_NUMBER Converts expr to a NUMBER value.
TO_SINGLE_BYTE Returns char with all multibyte characters converted to their corresponding single-byte characters. Accepts CHAR, VARCHAR2, NCHAR, or NVARCHAR2. The return value has the same data type as char.
TO_TIMESTAMP Converts char to a TIMESTAMP value.
TO_TIMESTAMP_TZ Converts char to a TIMESTAMP WITH TIME ZONE value.
TO_YMINTERVAL Converts its argument to an INTERVAL YEAR TO MONTH value.
TREAT Changes the declared type of an expression.
UNISTR Returns character data in the national character set (AL16UTF16 or UTF8). Supports Unicode string literals by allowing Unicode code values in the string, useful for inserting data into NCHAR columns.
VALIDATE_CONVERSION Determines whether expr can be converted to the specified data type. Returns 1 if the conversion succeeds or if expr is NULL, 0 if the conversion fails, and an error if evaluating expr raises one.