0

I have a .zip file in a table and I'm trying to figure out how to unzip that file using the AS_ZIP package.

I know how to compress using that package but I don't know how to decompress, any ideas?

Cesar Tepetla
  • 39
  • 1
  • 8
  • What is `AS_ZIP`? That's either a package you (or someone in your organization wrote) or a third-party package you (or someone in your organization) installed. It's not something that is part of the Oracle distribution. You'd need to have some documentation for that library to know whether it is capable of unzipping the file you have. If you have APEX installed in your database, you could use the built-in `APEX_ZIP` package https://docs.oracle.com/cd/E59726_01/doc.50/e39149/apex_zip.htm#AEAPI29962 – Justin Cave Mar 12 '23 at 08:06
  • Hi Justin, APEX_ZIP is built with AS_ZIP. AS_ZIP is a package developed by Anton Scheffer it is an easy to use package unlike other libraries. – Cesar Tepetla Mar 12 '23 at 15:40

1 Answers1

0

I have managed to unzip a zip file from a table, this is the code:

DECLARE
  v_doc BLOB;
  zip_files as_zip.file_list;
BEGIN
    SELECT FILE_CONTENT INTO v_doc FROM ZIPPED_FILES WHERE FILE_NAME ='Test.zip';
  zip_files  := as_zip.get_file_list( v_doc );
  FOR i IN zip_files.FIRST() .. zip_files.LAST
  LOOP
        --dbms_output.put_line(DBMS_LOB.SUBSTR(zip_files(i).filename,2000,1) ||' '|| TO_CHAR(zip_files(i).datemaj,'DD/MM/RRRR HH24:MI:SS') ||' size:'|| zip_files(i).size_comp ||' / '|| zip_files(i).size_uncomp);
    dbms_output.put_line( utl_raw.cast_to_varchar2( as_zip.get_file(v_doc, zip_files(i))));
  END LOOP;
END;
Cesar Tepetla
  • 39
  • 1
  • 8