Updated on 2024-06-03 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_VARCHAR2_TO_RAW

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.

DBE_RAW.BIT_AND

Returns a RAW value after bitwise AND calculation.

DBE_RAW.BIT_COMPLEMENT

Returns a RAW value after bitwise complement calculation.

DBE_RAW.BIT_XOR

Returns a RAW value after bitwise XOR calculation.

DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW

Converts a BINARY_DOUBLE value to a RAW value.

DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE

Converts a RAW value to a BINARY_DOUBLE value.

DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT

Converts a RAW value to a FLOAT4 value.

DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW

Converts a FLOAT4 value to a RAW value.

DBE_RAW.CAST_FROM_RAW_TO_NUMBER

Converts a RAW value to a NUMERIC value.

DBE_RAW.CAST_FROM_NUMBER_TO_RAW

Converts a NUMERIC value to a RAW value.

DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2

Converts a RAW value to an NVARCHAR2 value.

DBE_RAW.COMPARE

Returns the first different position of two RAW values.

DBE_RAW.CONCAT

Concatenates a maximum of 12 RAW values into a new RAW value and returns the value.

DBE_RAW.CONVERT

Converts a RAW value from the source encoding mode from_charset to the target encoding mode to_charset.

DBE_RAW.COPIES

Copies a RAW value for n times, concatenates the values, and returns the concatenated result.

DBE_RAW.OVERLAY

Overlays one RAW data with another RAW data by specifying the start position and length to be overlaid.

DBE_RAW.REVERSE

Reverses RAW data by byte.

DBE_RAW.TRANSLATE

Converts or discards a specified byte of a RAW value.

DBE_RAW.TRANSLITERATE

Converts a specified byte of a RAW value.

DBE_RAW.XRANGE

Returns a value containing the succession of one-byte encodings beginning and ending with the specified byte-code.

RAW data is represented as hexadecimal characters externally, and stored as binary characters internally. For example, the representation of RAW data 11001011 is 'CB', that is, the input for type conversion is '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 prototype of the DBE_RAW.CAST_FROM_BINARY_INTEGER_TO_RAW function 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 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 prototype of the DBE_RAW.CAST_FROM_RAW_TO_BINARY_INTEGER function is as follows:

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

    Parameter

    Description

    value

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

    endianess

    Endianness. The value can be 1, 2, or 3. The value 1 indicates BIG_ENDIAN, 2 indicates LITTLE_ENDIAN, and 3 indicates MACHINE_ENDIAN. The default value is 1. If BIG_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using BIG_ENDIAN. If LITTLE_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using LITTLE_ENDIAN.

  • DBE_RAW.GET_LENGTH

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

    The prototype of the DBE_RAW.GET_LENGTH function is as follows:

    1
    2
    3
    DBE_RAW.GET_LENGTH(
    value     IN    RAW)
    RETURN INTEGER;
    
    Table 4 DBE_RAW.GET_LENGTH 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 prototype of the DBE_RAW.CAST_FROM_VARCHAR2_TO_RAW function 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 parameters

    Parameter

    Description

    str

    VARCHAR2 value to be converted.

  • DBE_RAW.CAST_TO_VARCHAR2

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

    The prototype of the DBE_RAW.CAST_TO_VARCHAR2 function is as follows:

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

    Parameter

    Description

    str

    VARCHAR2 value to be converted.

  • DBE_RAW.BIT_OR

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

    The prototype of the DBE_RAW.BIT_OR function is as follows:

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

    Parameter

    Description

    str1

    First character string of the bitwise OR calculation.

    NOTE:

    Due to legacy reasons, this parameter is defined as the TEXT type. However, the DBE_RAW.BIT_OR interface expects to process RAW values. Defining this parameter as the TEXT type does not affect the processing of RAW values.

    str2

    Second character string of the bitwise OR calculation.

    NOTE:

    Due to legacy reasons, this parameter is defined as the TEXT type. However, the DBE_RAW.BIT_OR interface expects to process RAW values. Defining this parameter as the TEXT type does not affect the processing of RAW values.

  • DBE_RAW.SUBSTR

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

    The prototype of the DBE_RAW.SUBSTR function is as follows:

    1
    2
    3
    4
    5
    DBE_RAW.SUBSTR(
        IN lob_loc BLOB,
        IN off_set INTEGER DEFAULT 1,
        IN amount INTEGER DEFAULT 32767)
    RETURN RAW;
    
    Table 8 DBE_RAW.SUBSTR parameters

    Parameter

    Description

    lob_loc

    Source RAW value.

    NOTE:

    Due to legacy reasons, this parameter is defined as the BLOB type. However, the DBE_RAW.SUBSTR interface expects to process RAW values. Defining this parameter as the BLOB type does not affect the processing of RAW values.

    off_set

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

    amount

    Substring length. The default value is 32767.

  • DBE_RAW.BIT_AND

    Obtains the bitwise AND result of two RAW values.

    The prototype of the DBE_RAW.BIT_AND function is as follows:

    1
    2
    3
    4
    DBE_RAW.BIT_AND(
        r1 IN RAW,
        r2 IN RAW)
    RETURN RAW;
    
    Table 9 DBE_RAW.BIT_AND parameters

    Parameter

    Description

    r1

    The RAW value for the bitwise AND operation with r2. The maximum length is 32767.

    r2

    The RAW value for the bitwise AND operation with r1. The maximum length is 32767.

  • DBE_RAW.BIT_COMPLEMENT

    Obtains the bitwise complement result of a RAW value.

    The prototype of the DBE_RAW.BIT_COMPLEMENT function is as follows:

    1
    2
    3
    DBE_RAW.BIT_COMPLEMENT(
        r IN RAW)
    RETURN RAW;
    
    Table 10 DBE_RAW.BIT_COMPLEMENT parameters

    Parameter

    Description

    r

    The RAW value for the bitwise complement operation. The maximum length is 32767.

  • DBE_RAW.BIT_XOR

    Obtains the bitwise XOR result of two RAW values.

    The prototype of the DBE_RAW.BIT_XOR function is as follows:

    1
    2
    3
    4
    DBE_RAW.BIT_XOR(
        r1 IN RAW,
        r2 IN RAW)
    RETURN RAW;
    
    Table 11 DBE_RAW.BIT_XOR parameters

    Parameter

    Description

    r1

    The RAW value for the bitwise XOR operation with r2. The maximum length is 32767.

    r2

    The RAW value for the bitwise XOR operation with r1. The maximum length is 32767.

  • DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW

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

    The prototype of the DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW function is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW (
        n         IN BINARY_DOUBLE,
        endianess IN INTEGER DEFAULT 1)
    RETURN RAW;
    
    Table 12 DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW parameters

    Parameter

    Description

    n

    BINARY_DOUBLE value to be converted.

    endianess

    Endianness. The value can be 1, 2, or 3. The value 1 indicates BIG_ENDIAN, 2 indicates LITTLE_ENDIAN, and 3 indicates MACHINE_ENDIAN. The default value is 1. If BIG_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using BIG_ENDIAN. If LITTLE_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using LITTLE_ENDIAN.

  • DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE

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

    The prototype of the DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE function is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE(
        r         IN RAW,
        endianess IN INTEGER DEFAULT 1)
    RETURN BINARY_DOUBLE;
    
    Table 13 DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE parameters

    Parameter

    Description

    r

    The RAW value to be converted. The value contains 8 to 32767 characters.

    endianess

    Endianness. The value can be 1, 2, or 3. The value 1 indicates BIG_ENDIAN, 2 indicates LITTLE_ENDIAN, and 3 indicates MACHINE_ENDIAN. The default value is 1. If BIG_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using BIG_ENDIAN. If LITTLE_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using LITTLE_ENDIAN.

  • DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT

    Converts a RAW value to a FLOAT4 value.

    The prototype of the DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT function is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT(
        r         IN RAW,
        endianess IN INTEGER DEFAULT 1)
    RETURN FLOAT4;
    
    Table 14 DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT parameters

    Parameter

    Description

    r

    The RAW value to be converted. The value contains 4 to 32767 characters.

    endianess

    Endianness. The value can be 1, 2, or 3. The value 1 indicates BIG_ENDIAN, 2 indicates LITTLE_ENDIAN, and 3 indicates MACHINE_ENDIAN. The default value is 1. If BIG_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using BIG_ENDIAN. If LITTLE_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using LITTLE_ENDIAN.

  • DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW

    Converts a FLOAT4 value to a RAW value.

    The prototype of the DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW function is as follows:

    1
    2
    3
    4
    DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW(
        n         IN FLOAT4,
        endianess IN INTEGER DEFAULT 1)
    RETURN RAW;
    
    Table 15 DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW parameters

    Parameter

    Description

    n

    FLOAT4 value to be converted.

    endianess

    Endianness. The value can be 1, 2, or 3. The value 1 indicates BIG_ENDIAN, 2 indicates LITTLE_ENDIAN, and 3 indicates MACHINE_ENDIAN. The default value is 1. If BIG_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using BIG_ENDIAN. If LITTLE_ENDIAN is used on the host where the function is executed, the function execution result using MACHINE_ENDIAN is the same as that using LITTLE_ENDIAN.

  • DBE_RAW.CAST_FROM_RAW_TO_NUMBER

    Converts a RAW value to a NUMERIC value.

    The bottom-layer implementation of the number data type in database ORA is different from that in GaussDB, and the RAW data type is the hexadecimal representation of the binary stream implemented at the bottom layer. Therefore, the function in database ORA is different from that in GaussDB. You cannot obtain the same number-type data from GaussDB based on the RAW data corresponding to the number-type data in database ORA. For details about the number-type data in GaussDB, see the example.

    The prototype of the DBE_RAW.CAST_FROM_RAW_TO_NUMBER function is as follows:

    1
    2
    3
    DBE_RAW.CAST_FROM_RAW_TO_NUMBER(
        r IN RAW)
    RETURN NUMERIC;
    
    Table 16 DBE_RAW.CAST_FROM_RAW_TO_NUMBER parameters

    Parameter

    Description

    r

    The RAW value to be converted. The value contains 6 to 32767 characters.

  • DBE_RAW.CAST_FROM_NUMBER_TO_RAW

    Converts a NUMERIC value to a RAW value.

    The bottom-layer implementation of the number data type in database ORA is different from that in GaussDB, and the RAW data type is the hexadecimal representation of the binary stream implemented at the bottom layer. Therefore, the function in database ORA is different from that in GaussDB. You cannot restore the RAW data corresponding to the number-type data in database ORA to the original number type in database ORA in the GaussDB database. For details about the performance of this function in GaussDB, see the example.

    The prototype of the DBE_RAW.CAST_FROM_NUMBER_TO_RAW function is as follows:

    1
    2
    3
    DBE_RAW.CAST_FROM_NUMBER_TO_RAW(
        n IN NUMERIC)
    RETURN RAW;
    
    Table 17 DBE_RAW.CAST_FROM_NUMBER_TO_RAW parameters

    Parameter

    Description

    n

    NUMERIC value to be converted.

  • DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2

    Converts a RAW value to an NVARCHAR2 value.

    The prototype of the DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2 function is as follows:

    1
    2
    3
    DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2(
        r IN RAW)
    RETURN NVARCHAR2;
    
    Table 18 DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2 parameters

    Parameter

    Description

    r

    The RAW value to be converted. The maximum length is 32767.

  • DBE_RAW.COMPARE

    Returns the first different position of two RAW values.

    The prototype of the DBE_RAW.COMPARE function is as follows:
    1
    2
    3
    4
    5
    DBE_RAW.COMPARE(
        r1  IN RAW,
        r2  IN RAW,
        pad IN RAW DEFAULT NULL)
    RETURN INTEGER;
    
    Table 19 DBE_RAW.COMPARE parameters

    Parameter

    Description

    r1

    First data to be compared. The value can be NULL or the length is 0. The maximum length is 32767.

    r2

    Second data to be compared. The value can be NULL or the length is 0. The maximum length is 32767.

    pad

    The first byte of pad is used to extend the shorter one of r1 or r2. The maximum length is 32767. If this parameter is set to NULL, the length is 0, or the default value is used, the extended value is 0x00.

  • DBE_RAW.CONCAT

    Concatenates a maximum of 12 RAW values into a new RAW value and returns the value. If the length after concatenation exceeds 32767, an error is reported.

    The prototype of the DBE_RAW.CONCAT function is as follows:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    DBE_RAW.CONCAT(
        r1  IN RAW DEFAULT NULL,
        r2  IN RAW DEFAULT NULL,
        r3  IN RAW DEFAULT NULL,
        r4  IN RAW DEFAULT NULL,
        r5  IN RAW DEFAULT NULL,
        r6  IN RAW DEFAULT NULL,
        r7  IN RAW DEFAULT NULL,
        r8  IN RAW DEFAULT NULL,
        r9  IN RAW DEFAULT NULL,
        r10 IN RAW DEFAULT NULL,
        r11 IN RAW DEFAULT NULL,
        r12 IN RAW DEFAULT NULL) 
    RETURN RAW;
    
    Table 20 DBE_RAW.CONCAT parameters

    Parameter

    Description

    r1...r12

    The RAW values to be concatenated.

  • DBE_RAW.CONVERT

    Converts a RAW value from the source encoding mode from_charset to the target encoding mode to_charset.

    If the rule for converting between source and target encoding (for example, GBK and LATIN1) does not exist, the parameter r is returned without conversion. See the pg_conversion system catalog for details.

    The prototype of the DBE_RAW.CONVERT function is as follows:

    1
    2
    3
    4
    5
    DBE_RAW.CONVERT(
        r            IN RAW,
        to_charset   IN VARCHAR2,
        from_charset IN VARCHAR2)
    RETURN RAW;
    
    Table 21 DBE_RAW.CONVERT parameters

    Parameter

    Description

    r

    The RAW value to be converted. The maximum length is 32767.

    to_charset

    Name of the target encoding character set.

    from_charset

    Name of the source encoding character set. In this encoding, r must be valid.

  • DBE_RAW.COPIES

    Copies a RAW value for n times, concatenates the values, and returns the concatenated result. If the length after copying exceeds 32767, an error is reported.

    The prototype of the DBE_RAW.COPIES function is as follows:

    1
    2
    3
    4
    DBE_RAW.COPIES(
        r IN RAW,
        n IN NUMERIC)
    RETURN RAW;
    
    Table 22 DBE_RAW.COPIES parameters

    Parameter

    Description

    r

    The RAW values to be copied.

    n

    Number of replication times. The value must be a positive number. If the value is a decimal, the value is rounded off.

  • DBE_RAW.OVERLAY

    Overlays one RAW data with another RAW data by specifying the start position and length to be overlaid.

    The prototype of the DBE_RAW.OVERLAY function is as follows:
    1
    2
    3
    4
    5
    6
    7
    DBE_RAW.OVERLAY(
        overlay_str IN RAW,
        target      IN RAW,
        pos         IN BINARY_INTEGER DEFAULT 1,
        len         IN BINARY_INTEGER DEFAULT NULL,
        pad         IN RAW            DEFAULT NULL)
    RETURN RAW;
    
    Table 23 DBE_RAW.OVERLAY parameters

    Parameter

    Description

    overlay_str

    Byte used for overwriting. The value cannot be NULL.

    target

    Source byte string to be overlaid. The value is of the RAW type and contains a maximum of 32767 bytes. The value cannot be NULL.

    pos

    Indicates the byte from which the overlay starts. The position of the first byte is 1. The value of pos must be greater than or equal to 1 and the value of len+pos must be less than or equal to 32767. The default value is 1.

    len

    Length to be overlaid. The value of len must be greater than or equal to 0 and the value of len+pos must be less than or equal to 32767. The default value is the length of overlay_str.

    pad

    Padding byte. Only the first byte is valid. The default value is NULL. If the value is NULL, it is regarded as 0x00 by default.

  • DBE_RAW.REVERSE

    Reverses RAW data by byte.

    The prototype of the DBE_RAW.REVERSE function is as follows:

    1
    2
    3
    4
    DBE_RAW.REVERSE(
        r IN RAW
    )
    RETURN RAW;
    
    Table 24 DBE_RAW.REVERSE parameters

    Parameter

    Description

    r

    The RAW value to be reversed. The maximum length is 32767. If the value is NULL, NULL is returned.

  • DBE_RAW.TRANSLATE

    Converts or discards a specified byte of a RAW value.

    The prototype of the DBE_RAW.TRANSLATE function is as follows:

    1
    2
    3
    4
    5
    DBE_RAW.TRANSLATE(
        r        IN RAW,
        from_set IN RAW,
        to_set   IN RAW)
    RETURN RAW;
    
    Table 25 DBE_RAW.TRANSLATE parameters

    Parameter

    Description

    r

    Source byte string to be converted. The value is of the RAW type and contains a maximum of 32767 bytes. The value cannot be NULL.

    from_set

    Bytecode to be converted in the source byte string. The value is of the RAW type. The value cannot be NULL. The bytes in from_set in the source byte string are replaced with the bytes in the corresponding positions in to_set. If from_set contains multiple identical bytes, only the first byte corresponding to the byte is replaced. For example, if r[x]=from_set[n], r[x] is replaced with to_set[n]. If to_set[n] corresponding to from_set[n] does not exist (that is, the number of bytes of to_set does not exceed n), r[x] will be discarded.

    to_set

    Byte code converted from the from_set byte. The value is of the RAW type. The value cannot be NULL.

  • DBE_RAW.TRANSLITERATE

    Converts a RAW value to a NUMERIC value.

    The prototype of the DBE_RAW.TRANSLITERATE function is as follows:

    1
    2
    3
    4
    5
    6
    DBE_RAW.TRANSLITERATE(
        r        IN RAW,
        from_set IN RAW DEFAULT NULL,
        to_set   IN RAW DEFAULT NULL,
        pad      IN RAW DEFAULT NULL)
    RETURN RAW;
    
    Table 26 DBE_RAW.TRANSLITERATE parameters

    Parameter

    Description

    r

    Source byte string to be converted. The value is of the RAW type and contains a maximum of 32767 bytes. The value cannot be NULL.

    to_set

    Byte code converted from the from_set byte. The value is of the RAW type. The default value is NULL. If the value is NULL, all bytes in r that exist in from_set are converted to pad.

    from_set

    Bytecode to be converted in the source byte string r. The value is of the RAW type. The default value is NULL. If from_set is NULL, all bytes in the source byte string r are converted into equal-length data filled by pad. Otherwise, the bytes in from_set in the source byte string r are replaced with the bytes in the corresponding position in to_set. For example, if r[x]=from_set[n], r[x] is converted to to_set[n]. If to_set[n] does not exist, r[x] will be converted to pad.

    pad

    Padding byte. Only the first byte is valid. The default value is NULL. If the value is NULL, it is regarded as 0x00 by default.

  • DBE_RAW.XRANGE

    Returns a RAW value containing the succession of one-byte encodings beginning and ending with the specified byte-code.

    The prototype of the DBE_RAW.XRANGE function is as follows:

    1
    2
    3
    4
    DBE_RAW.XRANGE(
        start_byte IN RAW,
        end_byte   IN RAW)
    RETURN RAW;
    
    Table 27 DBE_RAW.XRANGE parameters

    Parameter

    Description

    start_byte

    Start byte. Only the first byte is valid. If the value is NULL, it is regarded as 0x00 by default.

    end_byte

    End byte. Only the first byte is valid. If the value is NULL, it is regarded as 0xFF by default. If end_byte is less than start_byte, end_byte is concatenated to 0xFF, and then 0x00 is concatenated to start_byte.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
-- 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;
/
CREATE PROCEDURE

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

(1 row)
-- Delete the stored procedure.
DROP PROCEDURE proc_raw;
DROP PROCEDURE

DECLARE
v_raw RAW;
v_double BINARY_DOUBLE;
v_float FLOAT4;
v_numeric NUMERIC;
v_nvarchar2 NVARCHAR2;
BEGIN
-- Perform bitwise AND calculation on RAW values.
SELECT DBE_RAW.BIT_AND('AFF', 'FF0B') INTO v_raw; -- 0A0B
-- Perform bitwise complement calculation on RAW values.
SELECT DBE_RAW.BIT_COMPLEMENT('0AFF') INTO v_raw; -- F500
-- Perform bitwise XOR calculation on RAW values.
SELECT DBE_RAW.BIT_XOR('AFF', 'FF0B') INTO v_raw; -- F5F4
-- Convert a BINARY_DOUBLE value to a RAW value.
SELECT DBE_RAW.CAST_FROM_BINARY_DOUBLE_TO_RAW(1.0001,1) INTO v_raw; -- 3FF00068DB8BAC71
-- Convert a RAW value to a BINARY_DOUBLE value.
SELECT DBE_RAW.CAST_FROM_RAW_TO_BINARY_DOUBLE('3FF00068DB8BAC7',1) INTO v_double; -- 1.0001
-- Convert a RAW value to a FLOAT4 value.
SELECT DBE_RAW.CAST_FROM_RAW_TO_BINARY_FLOAT('40200000',1) INTO v_float; -- 2.5
-- Convert a FLOAT4 value to a RAW value.
SELECT DBE_RAW.CAST_FROM_BINARY_FLOAT_TO_RAW('2.5',1) INTO v_raw; -- 40200000
-- Convert a RAW value to a NUMERIC value.
SELECT DBE_RAW.CAST_FROM_RAW_TO_NUMBER('808002008813') INTO v_numeric; -- 2.5
-- Convert a NUMERIC value to a RAW value.
SELECT DBE_RAW.CAST_FROM_NUMBER_TO_RAW('2.5') INTO v_raw; -- 808002008813
-- Convert a RAW value to an NVARCHAR2 value.
SELECT DBE_RAW.CAST_FROM_RAW_TO_NVARCHAR2('12345678') INTO v_nvarchar2; -- \x124Vx
-- Compare RAW values.
SELECT DBE_RAW.COMPARE('ABCD','AB') INTO v_numeric; -- 2
-- Concatenate RAW values.
SELECT DBE_RAW.CONCAT('ABCD','AB') INTO v_raw; -- ABCDAB
-- Convert RAW values.
SELECT DBE_RAW.CONVERT('E695B0', 'GBK','UTF8') INTO v_raw; -- CAFD
-- Copy RAW values.
SELECT DBE_RAW.COPIES('ABCD',2) INTO v_raw; -- ABCDABCD
-- Specify the start position and length of a RAW value to be overlaid.
SELECT DBE_RAW.OVERLAY('abcef', '12345678123456', 2, 5, '9966') INTO v_raw; -- 120ABCEF999956
-- Reverse a RAW value by byte.
SELECT DBE_RAW.REVERSE('12345678') INTO v_raw; -- 78563412
-- Convert bytes of the RAW type (without padding code).
SELECT DBE_RAW.TRANSLATE('1122112233', '1133','55') INTO v_raw; -- 55225522
-- Convert bytes of the RAW type (with padding code).
SELECT DBE_RAW.TRANSLITERATE('1122112233', '55','1133','FFEE') INTO v_raw; -- 55225522FF
-- All bytes between two bytes of the RAW type.
SELECT DBE_RAW.XRANGE('00','03') INTO v_raw; -- 00010203
END;
/
ANONYMOUS BLOCK EXECUTE