Oracle RAW type Basic operational functions and usage examples

Source: Internet
Author: User

The raw type is a data type that is used in Oracle to hold a bit string, similar to char, declared with a raw (L) method, up to 32767 bytes long. The system provides a SYS.UTL_RAW toolkit for raw type operations, and the commonly used functions are as follows:

1, the length of the calculation function, get a RAW type variable length, the unit is byte FUNCTION length (R in RAW) return number; For example: Select Utl_raw.length (' 12344321 ') from dual; Results are: 4
2, splicing function, for stitching two RAW type variables   FUNCTION concat (r1  in RAW DEFAULT NULL,        & nbsp;          r2  in RAW DEFAULT NULL                    r3  in RAW DEFAULT NULL,  & nbsp;                r4  in RAW DEFAULT NULL,                    r5  in RAW DEFAULT NULL,              & nbsp;    r6  in RAW DEFAULT NULL                    r7  in RAW DEFAULT NULL,        & nbsp;          r8  in RAW DEfault NULL,                    r9  in RAW DEFAULT NULL,              & nbsp;    R10 in RAW DEFAULT NULL,            & nbsp;      R11 in RAW DEFAULT NULL,          & nbsp;        R12 in Raw DEFAULT NULL) return RAW; For example: Select Utl_raw.concat (', ') from dual; Results are: 1234
3. Get Substring function substr (r in RAW, Pos. Binary_integer, Len in Binary_integer DEFAULT NULL) return RAW;
such as: Select Utl_raw.substr (' 12344321 ', 2, 1) from dual; Results are: 34
4, bitwise operation function Bit_and (r1 in raw, R2 in raw) return raw;   FUNCTION bit_or (r1 in raw, R2 in raw) return raw; FUNCTION Bit_xor (r1 in raw, R2 in raw) return raw; such as: Select Utl_raw.bit_and (' 12344321 ', ' 0f ') from dual; Select Utl_raw.bit_or (' 12344321 ', ' 0f ') from dual; Select Utl_raw.bit_xor (' 12344321 ', ' 0f ') from dual; The results were: 02344321, 1f344321, 1d344321
5. Assign value to specified byte   FUNCTION overlay (overlay_str in RAW,           & nbsp;        target      in RAW,                     pos          in Binary_integer

Related Article

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.