Oracle8i Supplied Packages Reference Release 8.1.5 A68001-01 |
|
The UTL_RAW
package provides SQL functions for manipulating RAW
datatypes. This package is necessary because normal SQL functions do not operate on RAWs
, and PL/SQL does not allow overloading between a RAW
and a CHAR
datatype. UTL_RAW
also includes subprograms that convert various COBOL number formats to, and from, RAWs
.
UTL_RAW
is not specific to the database environment, and it may actually be used in other environments as it exists here. For this reason, the prefix UTL has been given to the package, instead of DBMS.
The are many possible uses for the RAW
functions. UTL_RAW
allows a RAW
"record" to be composed of many elements. By using the RAW
datatype, character set conversion will not be performed keeping the RAW
in its original format when being transferred through remote procedure calls (RPC).
The RAW
functions also provide the ability to manipulate binary data which was previously limited to the hextoraw
and rawtohex
functions.
Subprogram | Description |
---|---|
|
Concatenates up to 12 |
|
Converts a |
|
Converts a |
|
Returns the length in bytes of a |
|
Returns |
|
Translates the bytes in the input |
|
Converts the bytes in the input |
|
Overlays the specified portion of target |
|
Returns |
|
Returns a |
|
Reverses a byte sequence in |
|
Compares |
|
Converts |
|
Performs bitwise logical "and" of the values in |
|
Performs bitwise logical "or" of the values in |
BIT_XOR function |
Performs bitwise logical "exclusive or" of the values in |
|
Performs bitwise logical "complement" of the values in |
This function concatenates up to 12 RAWs
into a single RAW
. If the concatenated size exceeds 32K, then an error is returned
UTL_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;
pragma restrict_references(concat, WNDS, RNDS, WNPS, RNPS);
r1
....r12
are the RAW
items to concatenate.
Return | Description |
---|---|
RAW |
Containing the items concatenated. |
There is an error if the sum of the lengths of the inputs exceeds the maximum allowable length for a RAW
, which is 32767 bytes.
This function converts a VARCHAR2
represented using n
data bytes into a RAW
with n
data bytes. The data is not modified in any way, only its datatype is recast to a RAW
datatype.
UTL_RAW.CAST_TO_RAW ( c IN VARCHAR2) RETURN RAW;
pragma restrict_references(cast_to_raw, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
c |
|
Return | Description |
---|---|
RAW |
Containing the same data as the input |
NULL |
If |
None.
This function converts a RAW
represented using n
data bytes into VARCHAR2
with n
data bytes.
UTL_RAW.CAST_TO_VARCHAR2 ( r IN RAW) RETURN VARCHAR2;
pragma restrict_references(cast_to_varchar2, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
|
Return | Description |
---|---|
VARCHAR2 |
Containing having the same data as the input |
NULL |
If |
None.
This function returns the length in bytes of a RAW
r
.
UTL_RAW.LENGTH ( r IN RAW) RETURN NUMBER;
pragma restrict_references(length, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
The |
Return | Description |
---|---|
NUMBER |
Equal to the current length of the |
None.
This function returns len
bytes, starting at pos
from RAW
r
.
UTL_RAW.SUBSTR ( r IN RAW, pos IN BINARY_INTEGER, len IN BINARY_INTEGER DEFAULT NULL) RETURN RAW;
pragma restrict_references(substr, WNDS, RNDS, WNPS, RNPS);
If pos
is positive, then SUBSTR
counts from the beginning of r
to find the first byte. If pos
is negative, then SUBSTR
counts backwards from the end of the r
. The value pos
cannot be 0.
If len
is omitted, then SUBSTR
returns all bytes to the end of r
. The value len
cannot be less than 1.
Parameter | Description |
---|---|
r |
The |
pos |
The byte position in |
len |
The number of bytes from |
Optional Parameter | Description |
---|---|
len |
Position |
Return | Description |
---|---|
portion of r |
Beginning at |
NULL |
|
Error | Description |
---|---|
VALUE_ERROR |
Either |
This function translates the bytes in the input RAW
r
according to the bytes in the translation RAWs
from_set
and to_set
. If a byte in r
has a matching byte in from_set
, then it is replaced by the byte in the corresponding position in to_set
, or deleted.
Bytes in r
, but undefined in from_set
, are copied to the result. Only the first (leftmost) occurrence of a byte in from_set
is used. Subsequent duplicates are not scanned and are ignored. If to_set
is shorter than from_set
, then the extra from_set
bytes have no translation correspondence and any bytes in r
matching.
UTL_RAW.TRANSLATE ( r IN RAW, from_set IN RAW, to_set IN RAW) RETURN RAW;
pragma restrict_references(translate, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
|
from_set |
|
to_set |
|
Return | Description |
---|---|
RAW |
Translated byte-string. |
Error | Description |
---|---|
VALUE_ERROR |
-
-
- |
This function converts the bytes in the input RAW
r
according to the bytes in the transliteration RAWs
from_set
and to_set
. Successive bytes in r
are looked-up in the from_set
, and, if not found, copied unaltered to the result RAW
. If found, then they are replaced in the result RAW
by either corresponding bytes in the to_set
, or the pad
byte when no correspondence exists.
Bytes in r
, but undefined in from_set
, are copied to the result. Only the first (leftmost) occurrence of a byte in from_set
is used. Subsequent duplicates are not scanned and are ignored. The result RAW
is always the same length as r
.
If the to_set
is shorter than the from_set
, then the pad
byte is placed in the result RAW
when a selected from_set
byte has no corresponding to_set
byte (as if the to_set
were extended to the same length as the from_set
with pad
bytes).
UTL_RAW.TRANSLITERATE ( r IN RAW, to_set IN RAW DEFAULT NULL, from_set IN RAW DEFAULT NULL, pad IN RAW DEFAULT NULL) RETURN RAW;
pragma restrict_references(transliterate, WNDS, RNDS, WNPS, RNPS);
Optional Parameter | Description |
---|---|
from_set |
x'00 through x'ff. |
to_set |
To the |
pad |
x'00'. |
Return | Description |
---|---|
RAW |
Converted byte-string. |
Error | Description |
---|---|
VALUE_ERROR |
|
This function overlays the specified portion of target RAW
with overlay RAW
, starting from byte position pos
of target and proceeding for len
bytes.
If overlay
has less than len
bytes, then it is extended to len
bytes using the pad
byte. If overlay
exceeds len
bytes, then the extra bytes in overlay are ignored. If len
bytes beginning at position pos
of target exceeds the length of target, then target is extended to contain the entire length of overlay
.
len
, if specified, must be greater than, or equal to, 0. pos
, if specified, must be greater than, or equal to, 1. If pos
exceeds the length of target, then target is padded with pad
bytes to position pos
, and then target is further extended with overlay
bytes.
UTL_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;
pragma restrict_references(overlay, WNDS, RNDS, WNPS, RNPS);
Optional Parameter | Description |
---|---|
pos |
1 |
len |
To the length of overlay |
pad |
x'00' |
Return | Description |
---|---|
RAW |
The target |
Error | Description |
---|---|
VALUE_ERROR |
- Overlay is - Target is missing or undefined
- Length of target exceeds maximum length of a
- |
This function returns n
copies of r
concatenated together.
UTL_RAW.COPIES ( r IN RAW, n IN NUMBER) RETURN RAW;
pragma restrict_references(copies, WNDS, RNDS, WNPS, RNPS);
Parameters | Description |
---|---|
r |
|
n |
Number of times to copy the |
This returns the RAW
copied n
times.
Error | Description |
---|---|
VALUE_ERROR |
-
- Length of result exceeds maximum length of a |
This function returns a RAW
containing all valid 1-byte encodings in succession, beginning with the value start_byte
and ending with the value end_byte
. If start_byte
is greater than end_byte
, then the succession of result bytes begin with start_byte
, wrap through 'FF'x to '00'x, and end at end_byte
. If specified, then start_byte
and end_byte
must be single byte RAWs
.
UTL_RAW.XRANGE ( start_byte IN RAW DEFAULT NULL, end_byte IN RAW DEFAULT NULL) RETURN RAW;
pragma restrict_references(xrange, WNDS, RNDS, WNPS, RNPS);
Parameters | Description |
---|---|
start_byte |
Beginning byte-code value of resulting sequence. |
end_byte |
Ending byte-code value of resulting sequence. |
start_byte - x'00' start_byte - x'00' end_byte - x'FF'
Return | Description |
---|---|
RAW |
Containing succession of 1-byte hexadecimal encodings. |
None.
This function reverses a byte sequence in RAW
r
from end to end. For example, x'0102F3' would be reversed into x'F30201', and 'xyz' would be reversed into 'zyx'.The result length is the same as the input RAW
length.
UTL_RAW.REVERSE ( r IN RAW) RETURN RAW;
pragma restrict_references(reverse, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
|
Return | Description |
---|---|
RAW |
Containing the "reverse" of |
Error | Description |
---|---|
VALUE_ERROR |
|
This function compares RAW
r1
against RAW
r2
. If r1
and r2
differ in length, then the shorter RAW
is extended on the right with pad
if necessary.
UTL_RAW.COMPARE ( r1 IN RAW, r2 IN RAW, pad IN RAW DEFAULT NULL) RETURN NUMBER;
pragma restrict_references(compare, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r1 |
1st |
r2 |
2nd |
pad |
Byte to extend whichever of |
pad - x'00'
Return | Description |
---|---|
NUMBER |
Equals 0 if Equals position (numbered from 1) of the first mismatched byte. |
None.
This function converts RAW
r
from character set from_charset
to character set to_charset
and returns the resulting RAW
.
Both from_charset
and to_charset
must be supported character sets defined to the Oracle server.
UTL_RAW.CONVERT ( r IN RAW, to_charset IN VARCHAR2, from_charset IN VARCHAR2) RETURN RAW;
pragma restrict_references(convert, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
|
to_charset |
Name of NLS character set to which |
from_charset |
Name of NLS character set in which |
Return | Description |
---|---|
RAW |
Byte string |
Error | Description |
---|---|
VALUE_ERROR |
-
-
- |
This function performs bitwise logical "and" of the values in RAW
r1
with RAW
r2
and returns the "anded" result RAW
.
If r1
and r2 differ in length, then the "and" operation is terminated after the last byte of the shorter of the two RAWs
, and the unprocessed portion of the longer RAW
is appended to the partial result. The result length equals the longer of the two input RAWs
.
UTL_RAW.BIT_AND ( r1 IN RAW, r2 IN RAW) RETURN RAW;
pragma restrict_references(bit_and, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r1 |
|
r2 |
|
Return | Description |
---|---|
RAW |
Containing the "and" of |
NULL |
Either |
None.
This function performs bitwise logical "or" of the values in RAW
r1 with RAW
r2 and returns the "or'd" result RAW
.
If r1
and r2
differ in length, then the "or" operation is terminated after the last byte of the shorter of the two RAWs
, and the unprocessed portion of the longer RAW
is appended to the partial result.The result length equals the longer of the two input RAWs
.
UTL_RAW.BIT_OR ( r1 IN RAW, r2 IN RAW) RETURN RAW;
pragma restrict_references(bit_or, WNDS, RNDS, WNPS, RNPS);
Parameters | Description |
---|---|
r1 |
|
r2 |
|
Return | Description |
---|---|
|
Containing the "or" of |
NULL |
Either |
None.
This function performs bitwise logical "exclusive or" of the values in RAW
r1
with RAW
r2
and returns the "xor'd" result RAW
.
If r1
and r2
differ in length, then the "xor" operation is terminated after the last byte of the shorter of the two RAWs
, and the unprocessed portion of the longer RAW
is appended to the partial result.The result length equals the longer of the two input RAWs
.
UTL_RAW.BIT_XOR ( r1 IN RAW, r2 IN RAW) RETURN RAW;
pragma restrict_references(bit_xor, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r1 |
|
r2 |
|
Return | Description |
---|---|
RAW |
Containing the "xor" of |
NULL |
If either |
None.
This function performs bitwise logical "complement" of the values in RAW
r
and returns the "complement'ed" result RAW
. The result length equals the input RAW
r
length.
UTL_RAW.BIT_COMPLEMENT ( r IN RAW) RETURN RAW;
pragma restrict_references(bit_complement, WNDS, RNDS, WNPS, RNPS);
Parameter | Description |
---|---|
r |
|
Return | Description |
---|---|
RAW |
The "complement" of |
NULL |
If |
None.