Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: BLOB Storage Issue
jimmy.brock schrieb:
> We have a customer requirement to take a number data type field and
> covert it to a binary data type of 4-bytes, and reverse the order of
> the binary data. Then we are to write out the value to a file using the
> UTL_FILE package.
>
> This requirement is due to the fact that the customer is using an old
> legacy application to read the file and it can only read numbers that
> are in binary format and it reads numbers from right to left. Their
> application is excepting the data to always be 4-bytes regardless of
> the value.
>
> The number can by up to 10-digtits, so the max value would be
> 9,999,999,999.
> I tried using the RAW data type but it writes out HEX data, not what
> the customer wants.
> I tried using BLOB but the max value for 4-bytes is 128,100,000. Also,
> there is no way to resize a BLOB. The customer wants 4-bytes binary
> data, regardless if the value is 0 of 9 Billion.
>
> Any suggestions would be great!
>
Could you elaborate, how would you store your representation of 9,999,999,999 ? I.e., what would be the content of first byte,second byte,third byte and fourth byte?
In general, for converting the numbers to the binary representation ( without any encoding) the UTL_RAW is probably the most appropriated choice, however even this package can't do magic and press a 5 bytes value into 4 bytes.
Best regards
Maxim Received on Thu Nov 16 2006 - 13:34:45 CST