Type conversion functions in Oracle

Source: Internet
Author: User
The string with the decimal point (except the decimal point) is converted to the TO_NUMBERConvertsastringtotheNUMBERdatatypeTO_NUMBE value.

Convert the string with the decimal point (All digits except the decimal point) to the value TO_NUMBER Converts a string to the NUMBER data type TO_NUMBE

A string with a decimal point (All digits except the decimal point) is converted to a numeric value.

TO_NUMBER

Converts a string to the NUMBER data typeTO_NUMBER ( [, , ]) RETURN NUMBER

Create table test (
Testcol VARCHAR2 (10 ));

Insert into test VALUES ('2014. 67 ');

SELECTTO_BINARY_DOUBLE(Testcol) BIN_DOUBLE,TO_BINARY_FLOAT(Testcol) BIN_FLOAT,TO_NUMBER(Testcol) NMBR
FROM test;

Converts a HEX number to FLOATTO_NUMBER ( , );

SELECTTO_NUMBER('0a', 'xx ')
FROM dual;

Converts a HEX number to DECIMALTO_NUMBER ( ,
' ') RETURN ;

SELECTTO_NUMBER(100000, 'xxxxxxxxxx ')
FROM dual;

1. Syntax: TO_NUMBER (string [, format [, nlsparams])
Objective: to convert a string of the CHAR or VARCHAR2 type to a numeric value of the NUMBER type. If the format is specified, the string format follows the corresponding numeric format.
2. Example
DECLARE
V_Num NUMBER;
BEGIN
V_Num: = TO_NUMBER ('$12345.67', '$99999.99 ');
END;

Oracle UTL_RAW

General Information

Source{ORACLE_HOME}/rdbms/admin/utlraw. SQL

First Available7.3.4

Constants

NameData TypeValue

Dependencies179 objects

SELECT name FROM dba_dependencies
WHERE referenced_name = 'utl _ raw'
UNION
SELECT referenced_name FROM dba_dependencies
WHERE name = 'utl _ raw ';

Exceptions

Error #NameDescription

An arithmetic, conversion, truncation, or size-constraint error. Usually raised by trying to cram a 6 character string into a VARCHAR2 (5 ).

Required Object PrivilegesGRANT execute on UTL_RAW

GRANT execute ON utl_raw to uwclass;

BIT_AND

Perform bitwise logical "and" of the values in raw r1 with raw r2 and return the "anded" result rawUtl_raw.bit_and (r1 in raw, r2 in raw) return raw;

SELECTUtl_raw.bit_and('0102f3 ', 'f30201 ')
FROM dual;

BIT_COMPLEMENT

Perform bitwise logical "complement" of the values in raw and return the "complement 'ed" result rawUtl_raw.bit_complement (r in raw) return raw;

SELECTUtl_raw.bit_complement('0102f3 ')
FROM dual;

BIT_OR

Perform bitwise logical "or" of the values in raw r1 with raw r2 and return the "or 'd" result rawUtl_raw.bit_or (r1 in raw, r2 in raw) return raw;

SELECTUtl_raw.bit_or('0102f3 ', 'f30201 ')
FROM dual;

BIT_XOR

Perform bitwise logical "exclusive or" of the values in raw r1 with raw r2 and return the "xor 'd" result rawUtl_raw.bit_xor (r1 in raw, r2 in raw) return raw;

SELECTUtl_raw.bit_xor('0102f3 ', 'f30201 ')
FROM dual;

CAST_FROM_BINARY_DOUBLE

Return the RAW representation of a binary_double valueUtl_raw.cast_from_binary_double (n IN BINARY_DOUBLE,
Endianess IN PLS_INTEGER DEFAULT 1) return raw;

SELECTUtl_raw.cast_from_binary_double(123.45)
FROM dual;

CAST_FROM_BINARY_FLOAT

Return the RAW representation of a binary_float valueUtl_raw.cast_from_binary_float (n IN BINARY_FLOAT,
Endianess IN PLS_INTEGER DEFAULT 1) return raw;

SELECTUtl_raw.cast_from_binary_float(123.45)
FROM dual;

CAST_FROM_BINARY_INTEGER

Return the RAW representation of a binary_integer valueUtl_raw.cast_from_binary_integer (
N IN BINARY_INTEGER,
Endianess IN PLS_INTEGER DEFAULT 1) return raw;

SELECTUtl_raw.cast_from_binary_integer(100)
FROM dual;

CAST_FROM_NUMBER

Returns the binary representation of a NUMBER in RAWUtl_raw.cast_from_number (n in number) return raw;

SELECTUtl_raw.cast_from_number(100)
FROM dual;

CAST_TO_BINARY_DOUBLE

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.