How to read a Zip file in PL/SQL program

Hi,
I was Reading a ".csv" file from a web URL eg. "www.aba.com/zxc.csv" in my PL/SQL procedure using UTL_HTTP package and loading data in my DB.
Now that file is in .zip format, is there any way that I can still read that .csv.zip file through my PL/SQL procedure. Because now I have to download it first then
unzip it and then I am loading it into my DB using UTL_FILE package instead I want to do it automatically as I was doing it before when it was not zipped.
Thanks & Regards
Sanjay

Peters solution is a great, nice alternative - you should consider it.
But your present solution reads the data from the web using UTL_HTTP into a CLOB I presume? So you are not hitting the file system at all?
If it is not an option for you to go to the file system, then it is possible that you can use [url http://docs.oracle.com/cd/E11882_01/appdev.112/e25788/u_compr.htm#BGBBCDDI]UTL_COMPRESS package.
That is (maybe) a possibility if the zip file only contains one file - it cannot handle if the zip file is a zip archive with several files in it.
You could try doing your UTL_HTTP load into a BLOB and then call UTL_COMPRESS.LZ_UNCOMPRESS to unzip that BLOB into another BLOB.
I'm not guaranteeing it will work, but it may be worth a try if you cannot do it Peters way ;-)

Similar Messages

  • How to read a text file through pl/sql

    How to read a text file through pl/sql

    pl/sql runs inside the database. so your file also should be on the database server file system for you to be able to read.
    check out UTL_FILE package. This is the database package to read/write files on the database server.

  • How to read an XML file into a java program?

    hi,
    i want to load the following very simple xml file in my java program.
    <root>
    <weblogic>
    <url value="t3://192.168.1.160:7001" />
    <context value="weblogic.jndi.WLInitialContextFactory" />
    </weblogic>
    </root>
    I am getting the error: " Line=1: cvc-elt.1: Cannot find the declaration of element 'root'."
    What might be the problem can anyone help me out.
    My java class code is:
    public class BIXMLReader {
    /** All output will use this encoding */
    static final String outputEncoding = "UTF-8";
    // Parses an XML file and returns a DOM document.
    // If validating is true, the contents is validated against the DTD
    // specified in the file.
    public static Document parseXmlFile(String filename, boolean validating) {
    try {
    // Create a builder factory
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    factory.setNamespaceAware(true);
    factory.setIgnoringComments(false);
    factory.setIgnoringElementContentWhitespace(false);
    factory.setCoalescing(false);
    factory.setValidating(validating);
    // Create the builder and parse the file
    System.out.println("filename = " + filename);
    DocumentBuilder db = factory.newDocumentBuilder();
    // Set an ErrorHandler before parsing
    OutputStreamWriter errorWriter = new OutputStreamWriter(System.err, outputEncoding);
    db.setErrorHandler(new MyErrorHandler(new PrintWriter(errorWriter, true)));
    Document doc = db.parse(new File(filename));
    System.out.println(doc.toString());
    return doc;
    } catch (SAXException e) {
    System.out.println("A parsing error occurred; the xml input is not valid. " + e.getMessage());
    } catch (ParserConfigurationException e) {
    System.out.println("Parser configuration exception has occured");
    } catch (IOException e) {
    System.out.println("IO Exception has occured " + e.getMessage());
    return null;
    // Error handler to report errors and warnings
    private static class MyErrorHandler implements ErrorHandler {
    /** Error handler output goes here */
    private PrintWriter out;
    MyErrorHandler(PrintWriter out) {
    this.out = out;
    * Returns a string describing parse exception details
    private String getParseExceptionInfo(SAXParseException spe) {
    String systemId = spe.getSystemId();
    if (systemId == null) {
    systemId = "null";
    String info = "URI=" + systemId +
    " Line=" + spe.getLineNumber() +
    ": " + spe.getMessage();
    return info;
    // The following methods are standard SAX ErrorHandler methods.
    // See SAX documentation for more info.
    public void warning(SAXParseException spe) throws SAXException {
    out.println("Warning: " + getParseExceptionInfo(spe));
    public void error(SAXParseException spe) throws SAXException {
    String message = "Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    public void fatalError(SAXParseException spe) throws SAXException {
    String message = "Fatal Error: " + getParseExceptionInfo(spe);
    throw new SAXException(message);
    }

    ok thanks, i can get the elements, but why did it not validate it?
    I want to read the child nodes of "weblogic" not by their name but by their index. Because i dont want to confine the reader so i want to read all the child nodes of weblogic (looping over them). i m doing the following but its not returning me the correct result and giving me the wrong count of child nodes.
    Element elementNode = (Element)doc.getElementsByTagName("weblogic").item(0);
    NodeList nodeList = elementNode.getChildNodes();
    int length = nodeList.getLength();
    System.out.println("length = "+ length); // the length its giving is 5 but i shuld get only 2
    for(int i=0; i < length; i++) {
    Element elmChild = (Element) nodeList.item(i);
    System.out.println(elmChild.getAttribute("value"));
    what might be the problem?

  • How to insert a ZIP file in the message body and display it as icons

    how to attach an ZIP file as an inline attachment. whether its possible in java mail.

    Stop asking the same thing over and over.
    Keep the discussion in your original thread.

  • How to Read a CAB File from JAVA?

    Hi,
    Anyone knows how to read a CAB File from java. I need to read a property file of txt file that is packaged in CAB file & then based on that, I have to do processing. Is there anyway to do it.
    I had tried using java.util.zip.ZipFile Class, but it does work for JAR, but not for CAB.
    siva.

    Perhaps there's something in the Cabinet SDK that will help:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dncabsdk/html/cabdl.asp

  • How to store the zip file in oracle table?

    hi,
    How to store the zip file in oracle table ?
    is it possible to unzip and read the file ?
    Thanks
    Rangan S

    SQL> DESC BLOB_TABLE;
    Name Type Nullable Default Comments
    A INTEGER Y
    B BLOB Y
    SQL> INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,BLOB('MWDIR_TST','TEST.ZIP'))
    ORA-00904: "BLOB": invalid identifier
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('MWDIR_TST','TEST.ZIP'))
    ORA-00907: missing right parenthesis
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));
    INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'))
    ORA-01465: invalid hex number
    SQL> INSERT INTO BLOB_TABLE VALUES(5,('\\MWDIR_TST\TEST.ZIP'));

  • Read encrpted zip file and ftp unzip file

    Hi,
    I have a situation,where i need to read 3 zip files, which are encrpted, and each zip file may have lot of images and text files. all i want to do is, read these 3 zip files and unzip + ftp to another directory. No mapping is involved. if the three files are not there, it should error out.
    I have some ideas, but thought if any of you have better ideas.
    Thanks
    Pandari

    Hi Pandari
    File adapter
    module to zip and unzip
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    <b>Check this weblog:</b>
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    Check this out !
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework%3Fpage%3Dlast%26x-order%3Ddate%26x-showcontent%3Doff
    also
    https://service.sap.com/sap/support/notes/965256
    Check this weblog on how to zip the file using XI:
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    PayloadZip Bean
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework%3Fpage%3Dlast%26x-order%3Ddate%26x-showcontent%3Doff
    Through command line
    Check case 2 in this blog
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    or ref plsz go tru it,
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    Check this weblog on this from stefan:
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    http://help.sap.com/saphelp_nw70/helpdata/en/84/2e3842cd38f83ae10000000a1550b0/frameset.htm
    /people/michal.krawczyk2/blog/2005/12/18/xi-sender-mail-adapter--payloadswapbean--step-by-step
    Zip or Unzip your Payload with the new PayloadZipBean module of the XI Adapter
    /people/stefan.grube/blog/2007/02/20/working-with-the-payloadzipbean-module-of-the-xi-adapter-framework
    XI/PI: Command line sample functions -> go through case 2
    /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    Create encrypted ZIP files
    Thanks!!!

  • How to check & unzip zip file using java

    Dear friends
    How to check & unzip zip file using java, I have some files which are pkzip or some other zip I want to find out the type of ZIp & then I want to unzip these files, pls guide me
    thanks

    How to check & unzip zip file using java, I have
    ve some files which are pkzip or some other zip I
    want to find out the type of ZIp & then I want to
    unzip these files, pls guide meWhat do you mean "other zip"? Either they're zip archives or not, there are no different types.

  • Can we read a ZIP file through ESB file adapter?

    Hi,
    Is it possible to read a ZIP file from a specified locaiton either through a FTP adapter or file adapter as a opaque element and place it in another specified locaiton?
    So far the available options are to read a txt, csv, fixed length or cobol file.
    I tried to create a ESB reading ZIP file and place it in another locaiton. but it was not reading the ZIP file.
    Is it first possible for the ESB to read the ZIP file? if so then is there any specific configuratuion that we have to do for it to work?

    how can we read a MSWORD file through java?You can read it like any other file using FileInputStream
    and similar.
    Howvere, if you want do do something with it, like display
    it, you have a problem. AFAIK Microsoft do not release
    information about their document formats, and i have not
    seen a .doc viewer for java.

  • How to append to zip files

    I would like to know how to append to a zip file, I know how to write a zip file and I can put as many entries in the first time but if I run my program again and try to add a file to the same zip file it erases what was already in it. I use ZipOutputStream(new FileOutputStream), I have tried the FileOutputStream append but it does not seem to work for zip files, I have tried RandomAccessFile on my zip file but that just seems to add the bytes to the file that already in the zip file, and makes the file unopenable, corrupt. If you can help, please tell me how.

    You actually have to open the previous zipped file, read it's entries and their data and then rewrite a new zip file with these entries and their data. You can then delete your first file and rename the new one so the effect is that you have "appended" zip files to the existing archive.
    Here is an example which I pieced together from a larger bit of code that I have. This would need to be in a try/catch but this should give you a start.
    /** This method adds a new file to an existing zip file. It * includes all the zipped entries previously written.
    * @param file The old zip archive
    * @param filename The name of the file to be Added
    * @param data The data to go into the zipped file
    * NOTE: This method will write a new file and data to an archive, to
    * write an existing file, we must first read the data frm the file,
    * then you could call this method.
    public void addToArchive(File file, String filename, String data)
         ZipOutputStream zipOutput = null;
    ZipFile zipFile = null;
    Enumeration zippedFiles = null;
    ZipEntry currEntry = null;
    ZipEntry entry = null;
    zipFile = new ZipFile( file.getAbsolutePath() );
         //get an enumeration of all existing entries
    zippedFiles = zipFile.entries();
         //create your output zip file
    zipOutput = new ZipOutputStream( new FileOutputStream ( new File( "NEW" + file.getAbsolutePath() ) ) );
    //Get all the data out of the previously zipped files and write it to a new ZipEntry to go into a new file archive
    while (zippedFiles.hasMoreElements())
    //Retrieve entry of existing files
    currEntry = (ZipEntry)zippedFiles.nextElement();
    //Read data from existing file
    BufferedReader reader = new BufferedReader( new InputStreamReader( zipFile.getInputStream( currEntry ) ) );
    String currentLine = null;
    StringBuffer buffer = new StringBuffer();
    while( (currentLine = reader.readLine() ) != null )
    buffer.append( currentLine);
    //Commit the data
    zipOutput.putNextEntry(new ZipEntry(currEntry.getName()) ) ;
    zipOutput.write (buffer.toString().getBytes() );
    zipOutput.flush();
    zipOutput.closeEntry();
    //Close the old zip file
    zipFile.close();
    //Write the 'new' file to the archive, commit, and close
    entry = new ZipEntry( newFileEntryName );
    zipOutput.putNextEntry( entry );
    zipOutput.write( data.getBytes() );
    zipOutput.flush();
    zipOutput.closeEntry();
    zipOutput.close();
         //delete the old file and rename the new one
    File toBeDeleted = new File ( file.getAbsolutePath() );
    toBeDeleted.delete();
         File toBeRenamed = new File ( "NEW" + file.getAbsolutePath() );
    toBeRenamed.rename( file );
    Like I said I haven't tested this code as it is here but hopefully it can help. Good luck.

  • How to read a exe file in mac

    how to read a exe file in mac

    What is the .exe file?  Is it a self-extracting WinZip file?
    Or is it a Windows program?
    The contents of a self-extracting zip file can sometime be extracted by changing the .exe to .zip (no promises).
    A Windows program needs to have a Windows environment, as mentioned by Niel.

  • Read a zip file from Application server.

    Hi,
    Is there a way to read a zip file from the applicatoin server to internal table in ABAP program?  The operation system is running MS windows server.  The zip file contains only 1 text file.  I tried to use open dataset 'uncompress', and use read dataset, but read dataset gave me sy-subrc = 4.  Any feedback is greatly appreciated.
    Thanks.

    hi,
    to convert xstring to text you can use this:
    DATA unzipped_data TYPE xstring.
    DATA text_data TYPE string.
    DATA conv_x2c TYPE REF TO cl_abap_conv_in_ce.
    conv_x2c = cl_abap_conv_in_ce=>create( ).
    conv_x2c->convert( EXPORTING input = unzipped_data IMPORTING data = text_data ).
    moreover, if you want to split your text at "end of line" (CR LF in microsoft windows) into lines:
    DATA text_lines TYPE TABLE OF string.
    SPLIT text_data AT cl_abap_char_utilities=>cr_lf INTO TABLE text_lines.

  • How to read several text files at a time

    Dear all
          Read and write one text file is not a problem, but  what confusies me is how to read several text files at one time, in the meanwhile,
    is it possible to display the name of the text file?
    For example, assuming I want to load file" cha 1, cha 2 , cha 3, " at one time and show their names, how to hadle with it
    I have reviewed some files and it is not helpful

    Either with a 'for' loop like in the lib you have attached, or like this attached VI
    that's it
    Message Edited by devchander on 05-30-2006 05:11 AM
    Attachments:
    MULTIPLE READ.vi ‏44 KB

  • How to open a zip-file in Bridge for PC?

    How to open a zip-file in Bridge for PC?

    I think it's built in, just double click on it and it should open with Archive Utility. I dunno, maybe Unrar X might work for you>
    JB

  • How to read a XML file from BLOB column and insert in a table - PL/SQL Only

    Hi,
    To make data load more simple to end user instead placing file on the server and use SQL-LOADER, I came up with new idea that using oracle ebusiness suite attachment functionality. that loads a XML file from local PC to a database column(table is fnd_attachments, default data type is BLOB over here).
    I tried with DBMS_LOB and didnt get around.
    Please can anyone tell me how to read the BLOB column using PL/SQL and store the data in a oracle table. Here's the sample XML file and table structure FYI.
    <?xml version="1.0" encoding="UTF-8"?>
    <dataroot xmlns:od="urn:schemas-microsoft-com:officedata" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="Corporate_alloc.xsd" generated="2009-07-07T14:17:49">
    <Corporate_alloc>
    <PKG_CODE>BKCORP</PKG_CODE>
    <PKG_NAME>Corporate Edition - Books</PKG_NAME>
    <DET_CODE>B9780080543758</DET_CODE>
    <DET_NAME>Waves, Tides and Shallow-Water Processes</DET_NAME>
    <ALLOCATION_RATIO>0.000041</ALLOCATION_RATIO>
    </Corporate_alloc>
    <Corporate_alloc>
    <PKG_CODE>BKCORP</PKG_CODE>
    <PKG_NAME>Corporate Edition - Books</PKG_NAME>
    <DET_CODE>B9780080534343</DET_CODE>
    <DET_NAME>Hydrostatically Loaded Structures</DET_NAME>
    <ALLOCATION_RATIO>0.000127</ALLOCATION_RATIO>
    </Corporate_alloc>
    </dataroot>
    CREATE TABLE TEST_XML
    ( PKG_CODE VARCHAR2(50),
    PKG_NAME VARCHAR2(100),
    DET_CODE VARCHAR2(20),
    DET_NAME VARCHAR2(500),
    ALLOCATION_RATIO NUMBER )
    Thanks
    EBV

    In regards to #3, use the COLUMNS functionality of XMLTable instead of using Extract. Two simple examples are
    Re: XML Data - Caliculate fields
    Re: Extractvalue function not recognised

Maybe you are looking for

  • Next Slide Problem with Flash In PowerPoint

    When I embed a Flash file into a PPT presentation and play Slide Show, my page down (Slide Show advance) key doesn't work once the animation is underway.  If I mouse-click the outside borders, it advances properly. Any suggestions on preventing this?

  • Dock and finder not accessible after 10.5.8 update

    I updated my aluminum imac through the software update last night, unaware that I had only a few GB free space on the hard drive. Right after it restarted, it says the dock has crashed, and gives me the option of Ignore, Report(?), Relaunch. I select

  • Problem in add new fields in xk01

    i want to add new customer field in xk01,xk02,xk03, i have append new structure in lfa1. i am using badi  VENDOR_ADD_DATA & VENDOR_ADD_DATA_CS . when i saved new additional fields using xk02 ,no  additional fields values is coming in lfa1 structure .

  • How do I make things appear behind my navigation bar?

    I tried to send the bar to the front and the other stuff to the back but it is not working here is my master page

  • When will the itunes store update my podcast episodes?

    Well, here it is a month now, and iTunes is still not updating my recent episodes in the iTunes store. Yes, I know Subscribers can still get the episodes, and they show on my Podcast App, but for people searching for new Podcasts to listen to, they c