blob conversion to base64

  • From: Jeroen van Sluisdam <jeroen.van.sluisdam@xxxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Tue, 23 Nov 2004 16:20:01 +0100

Hi,
We have to provide a conversion of blobs to base64 in order to exchange data
with
a 3th party. I wrote the following function which is used to format an
xml-message.
Problem is the supplier reads this data with a .net decode of base64
complains it's invalid and it
sees some lines with more than 76 characters which seems to be not correct.
Any ideas what is wrong are greatly appreciated.
9.2.0.4 HPUX11.11

Tnx,

Jeroen

Function getbase64String( lv_blob   blob )
Return clob is
  Result clob;
  resultString  VARCHAR2(4096);
  resultString1 clob;
  l_amt  number default 2048;
  l_raw  raw(4096);
  l_offset number default 1;
  l_clob clob;
BEGIN
  dbms_output.put_line('length blob: ' || dbms_lob.getlength( lv_blob ) );
  begin
      DBMS_LOB.CREATETEMPORARY(resultString1,FALSE,DBMS_LOB.CALL);
      DBMS_LOB.CREATETEMPORARY(result,FALSE,DBMS_LOB.CALL);
      loop
         dbms_lob.read( lv_blob, l_amt, l_offset, l_raw );
         l_offset := l_offset + l_amt;
       --  dbms_output.put_line(' voor resultstring');
         resultString := utl_raw.cast_to_varchar2( utl_encode.base64_encode(
l_raw ) );
      --   dbms_output.put_line(' na resultsstring');
         resultString1:=to_clob(resultString);
         dbms_lob.append(result,resultString1);
       end loop;
       exception
           when no_data_found then
              null;
  end;
--  dbms_output.put_line('length:'||dbms_lob.getlength(result));
  RETURN ( result );
END getbase64String;


--
//www.freelists.org/webpage/oracle-l

Other related posts:

  • » blob conversion to base64