ziopex / plsql-utils

Automatically exported from code.google.com/p/plsql-utils
0 stars 0 forks source link

zip a clob variable #8

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
We use your zip-package for zipping some clob files. because your package 
primarily only zips blobs, we added a procedure for zipping a clob variable. 
Maybe a good addition for your package?

  procedure add_file(
    p_zipped_blob in out blob
  , p_name in varchar2
  , p_content in clob
  )
  is
    l_blob blob;
    l_dest_offset  number := 1;
    l_src_offset   number := 1;
    l_lang_context number := dbms_lob.default_lang_ctx;
    l_warning      number := dbms_lob.no_warning;
  begin
    dbms_lob.createtemporary(l_blob, true);

    dbms_lob.converttoblob( dest_lob       => l_blob
                         ,  src_clob       => p_content
                         ,  amount         => dbms_lob.getlength(p_content)
                         ,  dest_offset    => l_dest_offset
                         ,  src_offset     => l_src_offset
                         ,  blob_csid      => dbms_lob.default_csid
                         ,  lang_context   => l_lang_context
                         ,  warning        => l_warning
                         );

    dbms_lob.close(l_blob);
    dbms_lob.freetemporary(l_blob);
  exception
  when others
  then
    if dbms_lob.isopen(l_blob) = 1
    then
      dbms_lob.close(l_blob);
      dbms_lob.freetemporary(l_blob);
    end if;
    raise;
  end add_file;

Original issue reported on code.google.com by td...@socho.nl on 6 Dec 2011 at 1:45

GoogleCodeExporter commented 8 years ago
Thanks for your feedback. Note that there is a clob_to_blob function in the 
sql_util_pkg package in the library, so the same thing can be accomplished by 
calling add_file (..., p_content => sql_util_pkg.clob_to_blob (l_your_clob)). 
Hope this helps.

Original comment by thehunge...@gmail.com on 19 Dec 2011 at 9:56