Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Blob to Byte Array

Mustafa KALAYCIApr 25 2016 — edited Apr 26 2016

Hello everyone,

I have a question about binary data. Frist I searched for this topic and there are many subjects but I couldn't found any answer.

In out firm, there is a .net developer team. Application is working based on web services. For a project I have to call a web service that requires byte array data. I have a table with BLOB column and holding data like pdf, rar, doc etc... I will send this file data to a web service via a parameter of web service. that parameter takes BYTE ARRAY (as I know a c# term).

now:

I tried to get blob value as char, using UTL_RAW.cast_to_varchar2, also tried dbms_lob.substr and tried to read blob data. results are like this:

UTL_RAW:

select utl_raw.cast_to_varchar2(dbms_lob.substr(d,50,1))  from tmp_blob;

RESULT: Rar!   ϐs        ©ìt 9 ×¶   pé:)]H 3

select dbms_lob.substr(d,50,1) from tmp_blob;

Result: 526172211A0700CF907300000D00000000000000A9EC74A0903900D7B60F00007E1400029570E93A295D8F481D3314002020.

When a c# developer read this same file and transforme it into byte array result is like this:

UmFyIRoHAM+QcwAADQAAAAAAAACp7HSgkDkA17YPAAB+FAAClXDpOildj0gdMxQAI

So this is basicly what I want, "UmFyIR...." is the byte array data of this blob data. Do you have any idea how to convert to that? I have to sent this file data via this web service as byte array.

thanks,

This post has been answered by Paulzip on Apr 25 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 24 2016
Added on Apr 25 2016
6 comments
4,377 views