Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

how to read blob as binary value in SAP

former_member625844
Participant
0 Likes
3,800

I tried the official demo demo_db_writer and demo_db_reader for writing and reading LOB. I save a image to the table and read it .It worked but I have a question, in other DB when I query the blob field it contain lots of ? or ! like characters. But in HANA blob field all characters are 0-9 and A-Z. So is this because some special coding method of HANA? Thx.

I tried the official demo demo_db_writer and demo_db_reader for writing and reading LOB. I save a image to the table and read it .It worked but I have a question, in other DB when I query the blob field it contain lots of ? or ! like characters. But in HANA blob field all characters are 0-9 and A-Z. So is this because some special coding method of HANA? Thx.

5 REPLIES 5
Read only

joltdx
Active Contributor
0 Likes
3,030

Hi!

The BLOB is binary data, RAWSTRING. Depending on how you look at it or display it, it can be represented as hexadecimal values (consisting of the number 0-9 and characters A-F). Maybe that is what you saw? For instance the hexadecimal value "F2" is the number 242, or in binary 11110010. This is one byte.

It's a representation to make the binary data a bit more "human readable".

So, when you "query the blob field" in other databases, you're probably also in other systems that display the binary data to you in another way.

Read only

joltdx
Active Contributor
0 Likes
3,030

Hi loki_luo15! To clarify... A blob is binary data, it is not text to just display. For instance in your question, you talked about an image. How do you expect that to look as text? You get the binary data from the database just fine in both your cases.

When you talk to the SQL Server, the way that system is _displaying_ the binary data sounds like it might be trying to output it as text. Meaning that som characters might be real ones, some might be spaces and some might look like garbage.

And in the example with the HANA, that system _displays_ the binary data to you as hexadecimal values. That does not look like garbage the same way, and consists of the numbers 0-9 and letters A-F, as I explained.

So I don't think you're doing the correct comparison between the systems.

A BLOB is only useful when it is used the right way, and outputting it to a text string is rarely the right way. Just as it makes no sense to open a text file in an image editor, it makes no sense to open an image in a text editor.

Read only

former_member660513
Participant
0 Likes
3,030

Hi!

Just based on the characters that you mentioned - '?', '!' i am assuming that the output is somehow being converted to a form of a char string(including also encoding/decoding?)

How do you treat the output, where do you see these unexpected characters - in a console, or your own program?

Read only

0 Likes
3,030

OK I'm wrong. I didn't see '?'. But I do output it to a string. Actually I use a third party software which read blob image from DB , when I read blob image from a SQL server DB the output is like combination of spaces and unreadable characters while from sql server studio the values is combination of 0-9 and a-z. And in HANA the output is as its value in DB view.

Read only

Sandra_Rossi
Active Contributor
0 Likes
3,030

The rendering depends on the tool you are using. The tools which try to display the BLOB (Binary Large OBject) via characters by using a character set like ASCII, UTF, etc. cannot show you the right content. Only display via hexadecimal (0-9, A-F), binary (0-1), octal (0-7), base 64 (64 characters like A-Z, a-z, 0-9 and 2 others) can render the BLOB without possibility of human misinterpretation.