Zip the file

Hi
Oracle 10g , Sunsolaris 5.9
I am generating csv file using utl_file option and i need to zip that file using plsql
I try to use this plsql to do this , but it will not zip the file i compile the procdeure but when i run it didnt
do any thing , where i did a mistake
procedure filezip as
--DECLARE
src_file BFILE;
v_content BLOB;
v_blob_len INTEGER;
v_file UTL_FILE.file_type;
v_buffer RAW(32767);
v_amount BINARY_INTEGER := 32767;
v_pos INTEGER := 1;
v_blob BLOB;
BEGIN
src_file := BFILENAME('*****','test1.txt');
DBMS_LOB.fileopen(src_file, dbms_lob.file_readonly);
v_content := utl_compress.lz_compress('src_file');
v_blob_len := DBMS_LOB.getlength(v_content);
v_file := UTL_FILE.fopen('EXPORT_DIR','test1.zip','w');
WHILE v_pos < v_blob_len
LOOP
DBMS_LOB.READ(v_content, v_amount, v_pos, v_buffer);
UTL_FILE.put_raw(v_file, v_buffer, TRUE);
v_pos := v_pos + v_amount;
END LOOP;
UTL_FILE.fclose(v_file);
EXCEPTION
WHEN OTHERS THEN
IF UTL_FILE.is_open(v_file) THEN
UTL_FILE.fclose(v_file);
END IF;
RAISE;
END;
rds

Generaly you need use Java as Procedure. Read this: [http://asktom.oracle.com/pls/asktom/f?p=100:11:0::NO::P11_QUESTION_ID:952229840241]

Similar Messages

  • Operating system command to zip the file

    Hi Experts,
    I got proxy to file scenario, i can place the text file successfully in reciever side, i want to zip the file in reciever side using operating system command option in reciever Communication Channel.
    Can anyone please give me the operating system command to create the zip file in reciever side.
    Kind Regards,
    Praveen.

    Hi Praveen,
    >>Can anyone please give me the operating system command to create the zip file in reciever side.
    Why OS commands and not the PayloadZipModule?
    If you need OS commands check this blog of Michal /people/michal.krawczyk2/blog/2007/02/08/xipi-command-line-sample-functions
    Update
    You can try this command too
    cmd /C "jar cMf \\<folderpath>test1.zip \\<folderpath>*.*"
    Regards
    Suraj

  • Tablet Zip the file through the algorithm

    My requirment is that I am to zip the file in xi and send to receiver using Soap Adapter. From Receiver again response will go to sender via XI. At the sender side again I want zipped file. Is it possible...
    Do i need to unzip the file at receiver end to make a request.

    Hi Jaideep,
    Ya its possible. You can use the PayloadZipBean for the same. You can both zip and unzip the file using this bean. Use this blog for the same:
    Working with the PayloadZipBean module of the XI Adapter Framework
    And ya you will have to unzip the content of the file if you are to get back a response from the rceiver.
    Regards,
    Sanjeev.

  • How to ZIP the files and folders/sub folder files using java

    HI All,
    I'm New to this Forum, Could anybody tell me how to zip the files and folders/sub folders using java. For example I have a folder with the name testfolder and side that folder I have some files and some sub folders inside subfolders I have some other files. I need to ZIP the files and folders as they are in same hierarchy.
    Any pointers or help wolud be appritiated.
    Thanks,
    Rajeshbabu V

    [http://www.devx.com/tips/Tip/14049]

  • Need help to zip the files? ? ? ?

    hello friends
    i am unable to zip the files in my directory by using this program
    import java.io.*;
    import java.util.zip.*;
    public class Zip {
    static final int BUFFER = 2048;
    public static void main (String argv[]) {
    try {
    BufferedInputStream origin = null;
    FileOutputStream dest = new
    FileOutputStream("c:\\zip\\myfigs.zip");
    ZipOutputStream out = new ZipOutputStream(new
    BufferedOutputStream(dest));
    //out.setMethod(ZipOutputStream.DEFLATED);
    byte data[] = new byte[BUFFER];
    // get a list of files from current directory
    File f = new File(".");
    String files[] = f.list();
    for (int i=0; i<files.length; i++) {
    System.out.println("Adding: "+files);
    FileInputStream fi = new
    FileInputStream(files[i]);
    origin = new
    BufferedInputStream(fi, BUFFER);
    ZipEntry entry = new ZipEntry(files[i]);
    out.putNextEntry(entry);
    int count;
    while((count = origin.read(data, 0,
    BUFFER)) != -1) {
    out.write(data, 0, count);
    origin.close();
    out.close();
    } catch(Exception e) {
    e.printStackTrace();
    but it is working fine for compress the files in the current directory
    but
    File f = new File("C:\\ramu");
    it shows the error like this
    C:\j2sdk1.4.2_09\bin>javac Zip.java
    C:\j2sdk1.4.2_09\bin>java Zip
    Adding: okh.txt
    java.io.FileNotFoundException: C:\ramu (Access is denied)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at Zip.main(Zip.java:21)
    can any body help to rectify this problem

    Don't cross-post!
    http://forum.java.sun.com/thread.jspa?threadID=5184841&tstart=0
    And use code tags already.
    The referenced thread already has advice for you (and no, we will not do it for you, you've already been given an example of how to do it, it is up to you to at least attempt it).

  • Need a free cold fusion utility that zip the files

    Hi,
    I Need a free cold fusion 5 utility that zip the files or
    folder on my server .
    i already have a cfc file that successfully did this work.
    but i need a script that did this work on cold fuison
    5.

    An
    old
    thread on a zip utility for Coldfusion.
    edit: I have just seen that a zip utility for CF5 might be hard
    to come by. Most people now write code for CFMX. Even the links to
    custom tags have changed.
    Go and search in the
    Exchange.
    You might be lucky. You have to pay for most of the zip utility
    code.

  • Unable to send mp3 with mail attachment. Zip the file doesn't work same

    Tried to send an mp3 file several times and kept getting this message. The file was only 11 mg.
    Unable to send with mail attachment.
    Your message couldn't be sent because a server error occurred. To send this message,please delete the current attachment,then re-attach.
    iMac, Mac OS X (10.7.2)
    Toad replyed try zip file (compress) I did and still got the same message

    Many mail servers cap their message sending or receiving at 4MB.  If you are sending your own work that you want distributed by someone else, check with your internet provider if they can temporarily raise that restriction and the recipient's mail server can temporarily raise those restrictions.   Better would be for both of you to be able to access a webhosting site to share the material and use some FTP programs to send the file to each other.    If it is an MPEG-3 of a commercial CD's music, we can't help you as such distribution is illegal.

  • Zipping the File

    Dear Friends,
    I need to know if the below scenario is possible in XI.
    I have file placed in the source FTP server, my goal is to move the file to the target FTP server, with the below criteria.
    Source FTP
    File name - ABC.txt
    Target FTP
    File name - ABC.zip , the zip file must contain ABC.txt
    Please let me know if you need more informations.
    Thanks,
    raj.

    Prateek,
    Thanks for your reply. I tried PayloadZipbean module, but it doesn't seems to be working correctly. If I used the payloadzipbean module, I'm getting the following results...
    ABC.txt, source file
    ABC.txt -target file (which is actually zip- contains unknown.xml)
    Note: I'm using the Dynamic Configuration parameters, since the file name is not always going to be the same. Sometimes ABC.txt, sometimes CDE.txt.......
    raj.

  • How to zip all the files generated using file adapter

    Hello Everyone,
    I have a scenario in place where i split a message into multiple messages. I used to generate multiple file using the file name present in the payload of the splitted message using variable substitution.
    This is working fine.
    Now the requirement has changed and i want to zip all these file and create a single zip file.
    I think it could be done using run OS command option in file adapter, but have no clue how to do it.
    Please help me.
    Regards
    Rahul Nawale

    Hi,
    you can use on of the command line ZIP utilities:
    http://www.winzip.com/prodpagecl.htm
    http://www.7-zip.org/
    then when your file adapter puts the file
    you can use commnad line to zip the files
    Regards,
    michal

  • Help with util.zip up files... does not work

    I am writing a program so my mum can zip up new photos she takes and then send them to me. The program creates a html file for the webpage plus a smaller version of her original photo and places them all in a 1 folder with a new name. Al this part works... I want to afterwards place my files in a zipped up folder that she can e-mail me with her normal client. How... I picked up this code on the net and have changed it to incoporate my parameters. The files which are created ..paths are (String in an String[]) I then send to my zipping method.
    The zip file is created but does not work when I try to extract from it ??? I also know that the String [] works becuse I have made a loop to check its properties at each index.
    what am I doing wrong?
    This is a modified code I found on the internet but with no author??
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.util.zip.ZipEntry;
    import java.util.zip.*;
    public class Test{
        private File zipDir;
        private String[] filename;
        public Test(String[] recivedFilename){
            filename = recivedFilename;
            try {
                ZipOutputStream zos = new
                        ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
                from,
                zipDir("c:\\batviapictures\\", zos);
                zos.close();
            } catch(Exception e) {
                //handle exception
        public void zipDir(String dir2zip, ZipOutputStream zos) {
            try {File
                zipDir = new File(dir2zip);
                String[] dirList = filename;
                byte[] readBuffer = new byte[2156];
                int bytesIn = 0;
                //loop through dirList, and zip the files
                for(int i=0; i<dirList.length; i++) {
                    File f = new File(zipDir, dirList);
    if(f.isDirectory()) {
    String filePath = f.getPath();
    zipDir(filePath, zos);
    continue;
    FileInputStream fis = new FileInputStream(f);
    ZipEntry anEntry = new ZipEntry(f.getPath());
    zos.putNextEntry(anEntry);
    while((bytesIn = fis.read(readBuffer)) != -1) {
    zos.write(readBuffer, 0, bytesIn);
    fis.close();
    catch(Exception e) {

    I make no guarantees that this will completely solve all your problems, but I just know these calls are needed but missing from your OP:
    try {
        ZipOutputStream zos = new
                        ZipOutputStream(new FileOutputStream("c:\\curDir.zip"));
                        from,
                        zipDir("c:\\batviapictures\\", zos);
        zos.flush(); // ADD THIS after all files have been written to the zos
        zos.close();
    } catch(Exception e) {
        //handle exception
    }And
    while((bytesIn = fis.read(readBuffer)) != -1) {
        zos.write(readBuffer, 0, bytesIn);
    zos.closeEntry(); // ADD THIS after each file is written to the zos
    fis.close();

  • How to Zip server files(in a directory) and throwing back to client

    Can someone tell me how to zip all the files in a particular directory of my web application and throwing back to client to give option for save that zipped file.
    i have used the below used function to zip in servlet. But I cann't zip a particular directory of my application in server.
    Please help
    private void zipDir(String dir2zip, ZipOutputStream zos)
    try
    //create a new File object based on the directory we
    // have to zip File
    File fileDir2Zip = new File(dir2zip);
    System.out.println("is directory ..."+fileDir2Zip.isDirectory());
    //get a listing of the directory content
    String[] dirList = fileDir2Zip.list();
    for(int i = 0 ; i < dirList.length ; i++)
    System.out.println("Dir list ..."+dirList);
    byte[] readBuffer = new byte[2156];
    int bytesIn = 0;
    //loop through dirList, and zip the files
    for(int i=0; i<dirList.length; i++)
    File f = new File(fileDir2Zip, dirList[i]);
    if(f.isDirectory())
    //if the File object is a directory, call this
    //function again to add its content recursively
    String filePath = f.getPath();
    zipDir(filePath, zos);
    //loop again
    continue;
    //if we reached here, the File object f was not
    //a directory
    //create a FileInputStream on top of f
    FileInputStream fis = new FileInputStream(f);
    //create a new zip entry
    ZipEntry anEntry = new ZipEntry(f.getPath());
    //place the zip entry in the ZipOutputStream object
    zos.putNextEntry(anEntry);
    //now write the content of the file to the ZipOutputStream
    while((bytesIn = fis.read(readBuffer)) != -1)
    zos.write(readBuffer, 0, bytesIn);
    System.out.println("Last");
    //close the Stream
    fis.close();
    catch(Exception e)
    e.printStackTrace();

    Hi
    Whatever file exist in directory should execute with out any condition because they delete all files after exection of my process chain. They are using another process chain once a day for deletion of all files in that directory.
    So directory always contains fresh files.
    Here by using routine in infopackge i am unable to run all files one by one at a time.
    As of my knowledge  by using infopackage we can run only one file at a time.
    Here my question is , can we run more than one file in single run of infopackage?
    or can we have any function module to run the infopackage from externally? so that i can use function module in abap program? any ideas..
    Regards
    Raju

  • How to Zip Excel files using File Adapter?

    Hi,
    We have tried to ZIP the Excel file with  PayloadZipBean in File adapter. But we faced some issue while zipping.
    We have seen some zunk data in excel file after zipping with PayloadZipBean. Someone please help how to zip Excel files in PI with File Adapter.
    Regards,
    Sreeramulu Konjeti.

    Hi Sree,
    If you are facing any issue with PayloadZipBean then you can use java mapping to Zip the files.
    Please find the complete Java mapping code to zipt the file
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/50ce0433-4309-2b10-4bb4-d421e78463f7?quicklink=index&overridelayout=true

  • Unzip the file archived by the File adapter

    Hi Experts,
    we have a scenario where we are archiving a xml file using the File adapter and also it is being zipped by the OS command.
    the script not only zips the file, it also rename the file from *.zip to *.xml.
    Hence after archiving when I am trying to open it, the content appears to be junk.
    Please suggest how to unzip the file as it got a extension *.xml.
    And I also tried renaming the file to *.zip and then to uncompress, but it shows below error
    Cannot open : it does not appear to be a valid archive
    Thanks in advance,
    MK

    hi Mk,
    instead of using OS command try using the exesting module provided by the SAP, so your job will be easy.
    follow this steps in the module processing for UN ZIP
    Processing sequence:
    Module name: AF_Modules/PayloadZipBean
    Type: Local Enterprise Bean
    Module key: 3
    u2022 Module configuration:
    Module key: 3
    Parameter name: zip.mode
    Parameter value: unzip.
    in the commincation channel specify filename.xml
    so you can open the file in XML format
    Thanks,
    Madhav
    Note:points if useful
    Edited by: madhav poosarla on Aug 14, 2008 8:31 AM

  • A client has sent me an indesign file I cannot open. She says she has updated to Indesign CC 2014. I am a CC member and fully updated my own software but cannot open the file she has sent me, not even if she saves as an IDML, how do I resolve the problem?

    A client has sent me an indesign file I cannot open. She says she has updated to Indesign CC 2014. I am a CC member and fully updated my own software but cannot open the file she has sent me, not even if she saves as an IDML, how do I resolve the problem?

    There are a few things to try.
    First, if this file came to you vial email attachment, it could have been corrupted. Ask her to zip the file and send it again. That sometimes helps.
    I suppose there's a chance that the file is already zipped, so see if that's the case and unzip it if so.
    If the file name doesn't end with .indd, add it and see if that helps.
    If you are double-clicking, try File>Open from within InDesign.
    Last (and I know this sounds like a joke, but I've seen it many times), sometimes people attach a Mac Alias or Windows Shortcut instead of the actual file. What is the file size? If it's really small, that might be the reason.
    Also, no offense intended if some of this sounds like stuff you have already tried. I don't know what you know, so I'm just spit-balling.

  • How do I prevent Mail from Zipping the attachment?

    When I send a .pages file by e-mail, Mail zips the file to .pages.zip.
    The network software at this University blocks .zip. How do I prevent Mail from zipping the file? I tried turning off the "send windows-friendly", but but still zips.

    Assuming this is iWork '08 or earlier, the "documents" are actually packages. A package is really a folder hierarchy. A folder cannot be emailed unless it is archived somehow. Mail does this automatically; most other email programs would be incapable of sending a bare Pages document at all.
    You could use some other non-blocked archive format, like tar or StuffIt. Or maybe you could rename it so that the mail servers don't recognize it as zip. You would have to instruct your recipient to rename it back. I understand that iWork '09 archives documents by default, although they are not named .zip, so that should be no longer an issue.

Maybe you are looking for