Updated on 2024-10-14 GMT+08:00

DBE_RAW

Interface Description

Table 1 provides all interfaces supported by the DBE_RAW package.

Table 1 DBE_RAW

Interface

Description

DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW

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

DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER

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

DBE_RAW.GET_LENGTH

Obtains the length of a RAW object.

DBE_RAW.CAST_FROM_VARCHA...

Converts a value of the VARCHAR2 type to a binary representation (RAW type).

DBE_RAW.CAST_TO_VARCHAR2

Converts a value of the RAW type to a value of the VARCHAR2 type.

DBE_RAW.SUBSTR

Returns the substring of the RAW type.

DBE_RAW.BIT_OR

Performs the bitwise OR operation on raw data.

RAW data is represented as hexadecimal characters externally, and stored as binary characters internally. For example, one byte of RAW data with bits 11001011 is displayed and entered as 'CB'.

  • DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW

    The stored procedure CAST_FROM_BINARY_INTEGER_TO_RAW converts a value of the INTEGER type to a binary representation (RAW type).

    The function prototype of DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW (
    value          IN  INTEGER,
    endianess      IN  INTEGER DEFAULT 1)
    RETURN RAW;
    
    Table 2 DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW interface parameters

    Parameter

    Description

    value

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

    endianess

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

  • DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER

    The stored procedure CAST_FROM_RAW_TO_BINARY_INTEGER converts a binary representation (RAW type) to a value of the INTEGER type.

    The function prototype of DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER (
    value          IN  RAW,
    endianess      IN  INTEGER DEFAULT 1)
    RETURN BINARY_INTEGER;
    
    Table 3 DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER interface parameters

    Parameter

    Description

    value

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

    endianess

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

  • DBE_RAW.GET_LENGTH

    The stored procedure GET_LENGTH returns the length of a RAW object.

    The function prototype of DBE_RAW.GET_LENGTH is as follows:

    1
    2
    3
    DBE_RAW.GET_LENGTH(
    value     IN    RAW)
    RETURN INTEGER;
    
    Table 4 DBE_RAW.GET_LENGTH interface parameters

    Parameter

    Description

    value

    Specifies a RAW object.

  • DBE_RAW.CAST_FROM_VARCHAR2_TO_RAW

    The stored procedure CAST_FROM_VARCHAR2_TO_RAW converts a VARCHAR2 object to a RAW object.

    The function prototype of DBE_RAW.CAST_FROM_VARCHAR2_TO_RAW is as follows:

    1
    2
    3
    DBE_RAW.CAST_TO_RAW(
    str     IN    VARCHAR2)
    RETURN RAW;
    
    Table 5 DBE_RAW.CAST_FROM_VARCHAR2_TO_RAW interface parameters

    Parameter

    Description

    c

    Specifies a VARCHAR2 object to be converted.

  • DBE_RAW.CAST_TO_VARCHAR2

    The stored procedure CAST_TO_VARCHAR2 converts a RAW object to a VARCHAR2 object.

    The DBE_RAW.CAST_TO_VARCHAR2 function prototype is as follows:

    1
    2
    3
    DBE_RAW.CAST_TO_VARCHAR2(
    str     IN    RAW)
    RETURN VARCHAR2;
    
    Table 6 DBE_RAW.CAST_TO_VARCHAR2 interface parameters

    Parameter

    Description

    str

    Specifies a RAW object to be converted.

  • DBE_RAW.BIT_OR

    The stored procedure BIT_OR calculates the bitwise OR result of two raw data records.

    The DBE_RAW.BIT_OR function prototype is as follows:

    1
    2
    3
    4
    DBE_RAW.BIT_OR(
    str1     IN    RAW,
    str2     IN    RAW)
    RETURN RAW;
    
    Table 7 DBE_RAW.BIT_OR interface parameters

    Parameter

    Description

    str1

    First character string of the bitwise OR operation

    str2

    Second character string of the bitwise OR operation

  • DBE_RAW.SUBSTR

    The stored procedure SUBSTR truncates an object of the RAW type based on the start bit and length.

    The DBE_RAW.SUBSTR function prototype is as follows:

    1
    2
    3
    4
    5
    DBE_RAW.SUBSTR(
        IN lob_loc raw,
        IN off_set integer default 1,
        IN amount integer default 32767)
    RETURN RAW;
    
    Table 8 DBE_RAW.SUBSTR interface parameters

    Parameter

    Description

    lob_loc

    Source raw character string

    off_set

    Start position of a substring. The default value is 1.

    amount

    Length of a substring. The default value is 32767.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
--Perform operations on RAW data in a stored procedure.
CREATE OR REPLACE PROCEDURE proc_raw
AS
str varchar2(100) := 'abcdef';
source raw(100);
amount integer;
BEGIN
source := dbe_raw.cast_from_varchar2_to_raw(str);--Convert the type.
 amount := dbe_raw.get_length(source);--Obtain the length.
dbe_output.print_line(amount);
END;
/

-- Call the stored procedure.
CALL proc_raw();

-- Delete the stored procedure.
DROP PROCEDURE proc_raw;