Updated on 2024-12-18 GMT+08:00

UTL_RAW

Related Interfaces

Table 1 provides all interfaces supported by the UTL_RAW package.

Table 1 UTL_RAW

API

Description

UTL_RAW.CAST_FROM_BINARY_INTEGER

Converts an INTEGER type value to a binary representation (RAW type).

UTL_RAW.CAST_TO_BINARY_INTEGER

Converts a binary representation (RAW type) to an INTEGER type value.

UTL_RAW.LENGTH

Obtains the length of the RAW type object.

UTL_RAW.CAST_TO_RAW

Converts a VARCHAR2 type value to a binary expression (RAW type).

The external representation of the RAW type data is hexadecimal and its internal storage form is binary. For example, the representation of the RAW type data 11001011 is 'CB'. The input of the actual type conversion is 'CB'.

  • UTL_RAW.CAST_FROM_BINARY_INTEGER

    The stored procedure CAST_FROM_BINARY_INTEGER converts an INTEGER type value to a binary representation (RAW type).

    The UTL_RAW.CAST_FROM_BINARY_INTEGER function prototype is:

    1
    2
    3
    4
    UTL_RAW.CAST_FROM_BINARY_INTEGER (
    n           IN  INTEGER,
    endianess   IN  INTEGER)
    RETURN RAW;
    
    Table 2 UTL_RAW.CAST_FROM_BINARY_INTEGER interface parameters

    Parameter

    Description

    n

    Specifies the INTEGER type value to be converted to the RAW type.

    endianess

    Specifies the INTEGER type value 1 or 2 of the byte sequence. (1 indicates BIG_ENDIAN and 2 indicates LITTLE-ENDIAN.)

  • UTL_RAW.CAST_TO_BINARY_INTEGER

    The stored procedure CAST_TO_BINARY_INTEGER converts an INTEGER type value in a binary representation (RAW type) to the INTEGER type.

    The UTL_RAW.CAST_TO_BINARY_INTEGER function prototype is:

    1
    2
    3
    4
    UTL_RAW.CAST_TO_BINARY_INTEGER (
    r          IN  RAW,
    endianess  IN  INTEGER)
    RETURN BINARY_INTEGER;
    
    Table 3 UTL_RAW.CAST_TO_BINARY_INTEGER interface parameters

    Parameter

    Description

    r

    Specifies an INTEGER type value in a binary representation (RAW type).

    endianess

    Specifies the INTEGER type value 1 or 2 of the byte sequence. (1 indicates BIG_ENDIAN and 2 indicates LITTLE-ENDIAN.)

  • UTL_RAW.LENGTH

    The stored procedure LENGTH returns the length of a RAW type object.

    The UTL_RAW.LENGTH function prototype is:

    1
    2
    3
    UTL_RAW.LENGTH(
    r      IN RAW)
    RETURN INTEGER;
    
    Table 4 UTL_RAW.LENGTH interface parameters

    Parameter

    Description

    r

    Specifies a RAW type object.

  • UTL_RAW.CAST_TO_RAW

    The stored procedure CAST_TO_RAW converts a VARCHAR2 type object to the RAW type.

    The UTL_RAW.CAST_TO_RAW function prototype is:

    1
    2
    3
    UTL_RAW.CAST_TO_RAW(
    c      IN VARCHAR2)
    RETURN RAW;
    
    Table 5 UTL_RAW.CAST_TO_RAW interface parameters

    Parameter

    Description

    c

    Specifies a VARCHAR2 type object to be converted.

Example

Perform operations on RAW data in a stored procedure:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
CREATE OR REPLACE PROCEDURE proc_raw
AS
str varchar2(100) := 'abcdef';
source raw(100);
amount integer;
BEGIN
source := utl_raw.cast_to_raw(str);--Convert the type.
amount := utl_raw.length(source);--Obtain the length.
dbms_output.put_line(amount);
END;
/

Call the stored procedure:

1
CALL proc_raw();