469,282 Members | 1,694 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,282 developers. It's quick & easy.

How to extract from LONG RAW data in Oracle.

HI!

I have a binary data stored in a LONG RAW column in an Oracle table. The Binary data contains .pdf document. Can anybody please help me to write a function/SP which extracts that Binary data back to pdf document or to a text file?

Any help would be highly appreciated.

Thanks in Advance!!!
Oct 3 '07 #1
9 35054
amitpatel66
2,367 Expert 2GB
HI!

I have a binary data stored in a LONG RAW column in an Oracle table. The Binary data contains .pdf document. Can anybody please help me to write a function/SP which extracts that Binary data back to pdf document or to a text file?

Any help would be highly appreciated.

Thanks in Advance!!!
Make use of RAWTOCHAR to convert the RAW data to character type
Oct 4 '07 #2
amitpatel66
2,367 Expert 2GB
Make use of RAWTOCHAR to convert the RAW data to character type
Check below functions:

Expand|Select|Wrap|Line Numbers
  1. FUNCTION chartoraw(v_char varchar2) return long raw
  2. is
  3. rawdata long raw;
  4. rawlen number;
  5. hex varchar2(32760);
  6. i number;
  7. begin
  8. rawlen := length(v_char);
  9. i := 1;
  10. while i <= rawlen
  11. loop
  12. hex := numtohex(ascii(substrb(v_char,i,1)));
  13. rawdata := rawdata || HEXTORAW(hex);
  14. i := i + 1;
  15. end loop;
  16.  
  17. return rawdata;
  18. end;
  19.  
  20.  
  21. FUNCTION rawtochar(v_raw long raw) return varchar2
  22. is
  23. rawlen number;
  24. hex varchar2(32760);
  25. rawparam varchar2(32760);
  26. i number;
  27. begin
  28. hex := rawtohex(v_raw);
  29. rawlen := length(hex);
  30. i := 1;
  31. while i <= rawlen
  32. loop
  33. rawparam := rawparam||CHR(HEXTONUM(substrb(hex,i,2)));
  34. i := i + 2;
  35. end loop;
  36.  
  37. return rawparam;
  38. end;
  39.  
  40.  
Oct 4 '07 #3
Check below functions:

Expand|Select|Wrap|Line Numbers
  1. FUNCTION chartoraw(v_char varchar2) return long raw
  2. is
  3. rawdata long raw;
  4. rawlen number;
  5. hex varchar2(32760);
  6. i number;
  7. begin
  8. rawlen := length(v_char);
  9. i := 1;
  10. while i <= rawlen
  11. loop
  12. hex := numtohex(ascii(substrb(v_char,i,1)));
  13. rawdata := rawdata || HEXTORAW(hex);
  14. i := i + 1;
  15. end loop;
  16.  
  17. return rawdata;
  18. end;
  19.  
  20.  
  21. FUNCTION rawtochar(v_raw long raw) return varchar2
  22. is
  23. rawlen number;
  24. hex varchar2(32760);
  25. rawparam varchar2(32760);
  26. i number;
  27. begin
  28. hex := rawtohex(v_raw);
  29. rawlen := length(hex);
  30. i := 1;
  31. while i <= rawlen
  32. loop
  33. rawparam := rawparam||CHR(HEXTONUM(substrb(hex,i,2)));
  34. i := i + 2;
  35. end loop;
  36.  
  37. return rawparam;
  38. end;
  39.  
  40.  
Hi!
I hope you didn't understood me correctly. Let me explain you once more, I have actually loaded the binary data (.pdf file) to an Oracle 10g database table's LONG RAW column. Now, I want to extract that LONG RAW column containing (pdf file) and write another pdf file. Then I will compare the file which is generated now and the pdf file which I have loaded to verify my load.

So, for that I need a pl/sql function-SP. If not possible via Pl/Sql you experts can provide me a Java, .Net code to extract that pdf file.

(Currently this LONG RAW column stores pdf file but later on it can store other Binary data as well)

Thanks In Advance.!!
Oct 4 '07 #4
amitpatel66
2,367 Expert 2GB
Hi!
I hope you didn't understood me correctly. Let me explain you once more, I have actually loaded the binary data (.pdf file) to an Oracle 10g database table's LONG RAW column. Now, I want to extract that LONG RAW column containing (pdf file) and write another pdf file. Then I will compare the file which is generated now and the pdf file which I have loaded to verify my load.

So, for that I need a pl/sql function-SP. If not possible via Pl/Sql you experts can provide me a Java, .Net code to extract that pdf file.

(Currently this LONG RAW column stores pdf file but later on it can store other Binary data as well)

Thanks In Advance.!!
In order to create a PDF from oracle data, you can check here

What you could do is get the binary RAW data, convert it to char, then write it to new pdf using logic as shown in the above link
Oct 4 '07 #5
In order to create a PDF from oracle data, you can check here

What you could do is get the binary RAW data, convert it to char, then write it to new pdf using logic as shown in the above link

It dosen't required to answer everytime, atleast "NOT" if you haven't understood the question correctly.

What am I asking is A and you are replying me Z...

Thanks anyways!!!
Oct 4 '07 #6
amitpatel66
2,367 Expert 2GB
It dosen't required to answer everytime, atleast "NOT" if you haven't understood the question correctly.

What am I asking is A and you are replying me Z...

Thanks anyways!!!
We are here to provide different kind of solutions to a problem or a path way so that you could proceed further. Dont expect exact solutions every time. If you feel you are not getting satisfied answer, then you can google it out your self!!
Oct 4 '07 #7
We are here to provide different kind of solutions to a problem or a path way so that you could proceed further. Dont expect exact solutions every time. If you feel you are not getting satisfied answer, then you can google it out your self!!
That's what I am doing Mr. Patel.

I am simply looking for an answer that .. How we can extract the Binary Data which is stored in LONG RAW column of a Oracle table.

Now, if you will provide me the solution that how we can change the character based data to pdf..Then after sometime I will ask you .. How to get an image file extracted from a Binary stored data.

I am not questioning you knowledge and expertise. What i said was, an humble and polite request you not to hop into to provide the opening to solution. Please try to figure out what members are trying to ask and try to provide the balanced solution..

And we member post question and reply to answers because we know that these things we cannot found over google. We post only after doing that with proper problem and expecting a proper answer (which sombody other might have faced and solved)

Thanks
Oct 4 '07 #8
debasisdas
8,127 Expert 4TB
Hi laconicamit

If you know how to use Visual Basic 6.0

Try to use AppendChunk and GetChunk method of recordset object of ADO

for storing and retriving files from LONG RAW column in Oracle.
Oct 4 '07 #9
Hi laconicamit

If you know how to use Visual Basic 6.0

Try to use AppendChunk and GetChunk method of recordset object of ADO

for storing and retriving files from LONG RAW column in Oracle.
Thanks Sir,

Let me check and get back to you..

Many Thanks.. :)
Oct 4 '07 #10

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

3 posts views Thread by music4 | last post: by
5 posts views Thread by dijaster | last post: by
12 posts views Thread by wenmang | last post: by
1 post views Thread by caine | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.