Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: substr, substrb and raw datatype
HansF wrote:
> The Oracle documentation also says:
> [...]
> "
> When Oracle automatically converts RAW or LONG RAW data to and from CHAR
> data, the binary data is represented in hexadecimal form with one
> hexadecimal character representing every four bits of RAW data. For
> example, one byte of RAW data with bits 11001011 is displayed and entered
> as 'CB.'
> "
That is what I expected from both substr and substrb. Both take "char" as first parameter, so, I thought that this implicit conversion is performed for both functions. If I invoke substrb as follows:
substrb( rawtohex(val), 5, 2)
results are the same as for
substr( val, 5, 2)
I'm surprised that such implicit conversion does not take place for substrb, although for substr - does. Also, such behavior is inconsistent with behavior of length/lengthb function pair. Both functions return the same value for raw fields.
> But, one may ask WHY you are doing character-based substrings of binary
> data? (Rhetorical question <g>)
In fact, I want to extract a part of a raw column. I haven't found in Oracle documentation any such function for raw datatype. But, substrb function does exactly what I want. Although, theoretically (in my opinion), should not.
I want to know, whether the function behaves really correctly, or whether is this an Oracle bug, which may be corrected in future.
-- Rafal sed -e s/s/a/g <my_address >my_right_addressReceived on Tue Jun 14 2005 - 13:34:57 CDT