How do I create a binary file using PL/SQL

Hi
Can you help me with writing a binary file in PL/SQL? I like to load binary data from data file, process in database then write to a new binary file.
Thank you very much in advance.
regrds
Yongdong

DBMS_LOB won't help you write a BLOB to disk.
You need to an external procedure to do that. Eric K's java works great and he's helped me with his solution and probably about a thousand others.
Doing a search on this forum will yield many discussions on this often regurgitated topic.

Similar Messages

  • Creating a text file using pl/sql

    how can one create a text file using pl/sql?
    Say for example abcd.txt in the d: drive
    (d:\abcd.txt)
    on a windows nt server

    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by bhrigu nagal ([email protected]):
    thanks for your replies
    I had already set the utl_file_dir parameter
    I tried the utl package and wrote the following code but got some errors
    declare
    filehandler UTL_FILE.FILE_TYPE;
    begin
    filehandler:=UTL_FILE.fopen('d:/intel/','myfile.txt','w');
    utl_file.put_line(filehandler,'look masjdfgsd\n');
    utl_file.fclose(filehandler);
    exception when utl_file.invalid_path then
    raise_application_error(-20023,'bhrigu ,chk the path');
    end;
    the errors
    ERROR at line 1:
    ORA-06510: PL/SQL: unhandled user-defined exception
    ORA-06512: at "SYS.UTL_FILE", line 101
    ORA-06512: at "SYS.UTL_FILE", line 157
    ORA-06512: at line 4
    if u know what this is please tell me
    thanks bhrigu
    <HR></BLOCKQUOTE>
    U need :
    1) To have UTL_FILE_DIR param in the init file of the instance with the same directory (don't forget to stop and restart the base)
    2) Handled the exceptions listed in the utl_file package (Oracle_home\rdbms\admin\utlfile.sql) in your source.
    3) Turn set serveroutput on in SQL*Plus.
    Run your procedure and see the error message to debug.
    Good luck
    null

  • How to dynamically create sqlldr control file using stored procedure

    I am trying to dynamically create the control file (.ctl) and execute the same using a stored procedure.I would be passing the file name as a parameter to this procedure. How do I go about doing this?
    The control file has the following structure. The file name (mktg) varies and is passed as an input to the stored procedure.
    SPOOL mktg.ctl
    LOAD DATA
    INFILE 'mktg.csv'
    INTO TABLE staging
    FIELDS TERMINATED BY ','
    TRAILING NULLCOLS
    (COMPANY_NAME,
    ADDRESS,
    CITY,
    STATE,
    ZIP)
    SPOOL OFF ;
    sqlldr scott/tiger CONTROL= mktg.ctl LOG=mktg.log BAD=mktg.bad

    We are using oracle 9i rel 2.
    I have not had much success with the creation of log and bad files using external tables when they are being used within a dynamic sql.
    Plz check this:
    Re: problems related to data loads from excel, CSV files into an oracle 9i db

  • How do I create an exe file using Sun One?

    Hello everyone,
    I need help in creating an executable file in Sun One, can someone please help?

    Hi all I search the forum and came up with some suggestions so I'll run with these until I exaust all of them!!! thanks anyways

  • Create a Multiple Files using PL-SQL

    Hi Experts,
    I have a table which contains 360 records and want to create multiple files with each file containing 12 records.
    I tried to use the below code, however was unsuccessfull..
    Please help!!!!
    DECLARE
       num      NUMBER             := 1;
       f_file   UTL_FILE.file_type;
       row_sm   NUMBER             := 0.00;
    CURSOR c_cur
       IS
          SELECT   customer_key, all_columns_concat
              FROM demo;
    c_rec    c_cur%ROWTYPE;
    BEGIN
       OPEN c_cur;
       LOOP
          FETCH c_cur
           INTO c_rec;
         EXIT WHEN c_cur%NOTFOUND;
          WHILE num = c_rec.file_num
          LOOP
             f_file := UTL_FILE.fopen ('DM_DIR', 'FILE_' || num, 'w', 3267);
             num := num + 1;
          END LOOP;
          UTL_FILE.put_line (f_file, c_rec.all_columns_concat);
          row_sm := c_rec.sum_row + row_sm;
       END LOOP;
       UTL_FILE.fclose (f_file);
      CLOSE c_cur;
    END;
    Regards,
    RaviR.

    Thanks Ramin,
    Your Code really helped. I am now not getting no errors and files are also being created. However, if I replace the UTL_FILE with DBMS_OUTPUT, I get below output. In your code i replaced 12 with 3. Hence its dividing after 3 rows. (with 1st row duplicated)
    Output
    1
    1
    2
    3
    ========================================
    4
    4
    5
    6
    ========================================
    7
    7
    8
    9
    ========================================
    10
    10
    11
    12
    ========================================
    13
    13
    14
    15
    ========================================
    16
    16
    Now my concern is that i my table I have a flag which determines the seperation...
    Column1
    File_Num
    1
    1
    2
    1
    3
    1
    4
    2
    5
    2
    6
    2
    7
    3
    8
    3
    9
    3
    10
    3
    11
    3
    Hence if the file_Num is 1 it will go to File1, file_num=2 will be written to File2 and so on.
    Please help me to get this logic.
    Thanks in advance.
    Regards,
    RaviR

  • Create crystal report file using JAVA

    Can someone tell me how to a Create crystal report file using JAVA Programming
    I want a very simple example

    Please help me. It's urgent.[http://catb.org/~esr/faqs/smart-questions.html#urgent]
    Be back in an hour or two...

  • How can I create an Excel file?

    Hi,
    How can I create an Excel file using Forms 6i.
    What I'm doing is to create a file using TEXT_IO package an name it .XLS. If a read it double-clicking over the file, it opens Ok but If I open directly from Excel it opens the Convert dialog.
    I need to create an excel file as it was made from within Excel.
    Thank in advance,
    Benjamin

    When you are talking about subfiles, are you talking like Package contents of an application?
    Terminal application in Applications -> Utilities can give a command line grasp of all your files using the du command.
    Type
    man du
    when entering the terminal, followed by the enter key.
    Note, by default the terminal opens at the Home folder.   To navigate outside the Home folder enter "/Volumes/name of mounted drive/folder/subfolder" as your path.  If there are spaces in the name, putting quotes around the whole path can help.    If you end your du command with a > name.txt a text file with the name name.txt will be plugged into your Home directory.  That you can open with Excel and parse by /es thus giving you everything in Excel.

  • How can I create an csv/excel file using pl/sql and then sending that file

    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.

    968776 wrote:
    How can I create an csv/excel file using pl/sql and then sending that file to a clients site using pl/sql?
    I know how to create the csv/excel file but I can't figure out how I would get it to the clients site.You are trying to do it at a wrong place..
    Whay do you want database (pl/sql) code to do these things?
    Anyhow, you may be interested in :
    {message:id=9360007}
    {message:id=9984244}

  • How to create the trace file using run_report_object at runtime

    Dear All
    using :
    Oracel Application Server 10g
    Oracle Database 11g
    Windows XP/sp3
    I'm using run_report_object to call a report inside the form. THis report is running OK from reports builder, however it's too slow when run from Application server.
    How Can I create a trace file (at runtime) that contains the time spent in sql and formating the layout of the report ??
    Here is My code :
    repid := find_report_object('report5');
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_FILENAME,'INVOICE.REP');
    v_url :='paramform=no';
    v_url := v_url||' FROM_NO=' || :PRINT_BLOCK.FROM_NO ;
    v_url := v_url ||' TO_NO=' || :PRINT_BLOCK.TO_NO ||' FROM_DATE=' || v_from_date ||' TO_DATE='|| v_to_date ||' NO_DATE=' ;
    v_url := v_url ||:PRINT_BLOCK.NO_DATE||' IDENT=' ||:PRINT_BLOCK.IDENT_NO||' REPORT_HEADING='''||V_REPORT_HEADING||'''' ;
    v_url := v_url||' COMPANY_NO='||:global.company_no;
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_OTHER,v_url);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_SERVER,:GLOBAL.INV_REPORT_SERVER_NAME);
    SET_REPORT_OBJECT_PROPERTY(repid,REPORT_DESFORMAT,'pdf');
    v_rep := RUN_REPORT_OBJECT(repid);
    IF rep_status = 'FINISHED' THEN
    V1:='/reports/rwservlet/getjobid'||substr(v_rep,instr(v_rep,'_',-1)+1);
    WEB.SHOW_DOCUMENT('/reports/rwservlet/getjobid'||substr(v_rep,instr(v_rep,'_',-1)+1)||'?server='||REPORT_SERVER_NAME,'_blank');
    END IF;
    Thanks a lot

    Slow running reports often are not the result of a flawed report, but rather a flawed configuration. For example:
    1. If you call your reports (from Forms) via the default or inProcess Reports Server, often because startup time is slow, it will appear that it took too long for the report to be delievered. Using a stand-alone Rep Server is the preferred way to do this.
    2. If your Forms application makes numerous calls to RRO (RUN_REPORT_OBJECT), this can tend to result in what might appear as a memory leak (although it is not). The result is delayed processing because of the excessive memory use. This problem has been overcome in Forms/Reports 11 by the use of JVM pooling. However in v10 enabling "6i compatibility" mode is the way to overcome the issue. See Note 266073.1
    3. If the report runs fine from the Builder and it is connecting to the same db as when you run it from App Server, the issue is unlikely a db problem. However, if you want to look anyway, enable sqlnet tracing.
    4. To enable Reports tracing and investigate other tuning options, refer to the Reports 10 documentation:
    http://docs.oracle.com/cd/B14099_11/bi.1012/b14048/pbr_tune.htm
    Almost forgot to mentioned this one....
    If you are using a v11 db with App Server 10, you will probably want to consider reviewing Note 1099035.1 as it discusses an issue related to performance with such a configuration.
    Edited by: Michael Ferrante on Apr 10, 2012 8:49 AM

  • How to create new XML file using retreived XML content by using SAX API?

    hi all,
    * How to create new XML file using retreived XML content by using SAX ?
    * I have tried my level best, but output is coming invalid format, my code is follows,
    XMLFileParser.java class :-
    import java.io.StringReader;
    import java.io.StringWriter;
    import javax.xml.transform.OutputKeys;
    import javax.xml.transform.Transformer;
    import javax.xml.transform.TransformerConfigurationException;
    import javax.xml.transform.TransformerException;
    import javax.xml.transform.TransformerFactory;
    import javax.xml.transform.dom.DOMResult;
    import javax.xml.transform.sax.SAXSource;
    import javax.xml.transform.sax.SAXTransformerFactory;
    import javax.xml.transform.sax.TransformerHandler;
    import javax.xml.transform.stream.StreamResult;
    import org.w3c.dom.Document;
    import org.xml.sax.Attributes;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import org.xml.sax.helpers.XMLFilterImpl;
    public class PdfParser extends XMLFilterImpl {
        private TransformerHandler handler;
        Document meta_data;
        private StringWriter meta_data_text = new StringWriter();
        public void startDocument() throws SAXException {
        void startValidation() throws SAXException {
            StreamResult streamResult = new StreamResult(meta_data_text);
            SAXTransformerFactory factory = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
            try
                handler = factory.newTransformerHandler();
                Transformer transformer = handler.getTransformer();
                transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
                transformer.setOutputProperty(OutputKeys.INDENT, "yes");
                handler.setResult(streamResult);
                handler.startDocument();
            catch (TransformerConfigurationException tce)
                System.out.println("Error during the parse :"+ tce.getMessageAndLocation());
            super.startDocument();
        public void startElement(String namespaceURI, String localName,
                String qualifiedName, Attributes atts) throws SAXException {
            handler.startElement(namespaceURI, localName, qualifiedName, atts);
            super.startElement(namespaceURI, localName, qualifiedName, atts);
        public void characters(char[] text, int start, int length)
                throws SAXException {
            handler.characters(text, start, length);
            super.characters(text, start, length);
        public void endElement(String namespaceURI, String localName,
                String qualifiedName) throws SAXException {
            super.endElement("", localName, qualifiedName);
            handler.endElement("", localName, qualifiedName);
        public void endDocument() throws SAXException {
        void endValidation() throws SAXException {
            handler.endDocument();
            try {
                TransformerFactory transfactory = TransformerFactory.newInstance();
                Transformer trans = transfactory.newTransformer();
                SAXSource sax_source = new SAXSource(new InputSource(new StringReader(meta_data_text.toString())));
                DOMResult dom_result = new DOMResult();
                trans.transform(sax_source, dom_result);
                meta_data = (Document) dom_result.getNode();
                System.out.println(meta_data_text);
            catch (TransformerConfigurationException tce) {
                System.out.println("Error occurs during the parse :"+ tce.getMessageAndLocation());
            catch (TransformerException te) {
                System.out.println("Error in result transformation :"+ te.getMessageAndLocation());
    } CreateXMLFile.java class :-
    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();
    Sax.endElement("", "basic-metadata", "basic-metadata");* In CreateXMLFile.java
    class, I have retreived the xml content in the meta_data object, after that i have converted into character array and this will be sends to SAX
    * In this case , the XML file created successfully but the retreived XML content added as an text in between basic-metadata Element, that is, retreived XML content
    is not an XML type text, it just an Normal text Why that ?
    * Please help me what is the problem in my code?
    Cheers,
    JavaImran

    Sax.startDocument();
    Sax.startValidation();
    Sax.startElement("", "pdf", "pdf", new AttributesImpl());
    Sax.startElement("", "basic-metadata", "basic-metadata", new AttributesImpl());          
    String xmp_str = new String(meta_data.getByteArray(),"UTF8");
    char[] xmp_arr = xmp_str.toCharArray();
    Sax.characters(xmp_arr, 0, xmp_arr.length);
    </code><code>Sax.endElement("", "basic-metadata", "basic-metadata");</code>
    <code class="jive-code jive-java">Sax.endElement("", "pdf", "pdf");
    Sax.endValidation();
    Sax.endDocument();     
    * I HAVE CHANGED MY AS PER YOUR SUGGESTION, NOW SAME RESULT HAS COMING.
    * I AM NOT ABLE TO GET THE EXACT OUTPUT.,WHY THAT ?
    Thanks,
    JavaImran{code}

  • I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel

    I was given an assingment, but have no idea where to begin. The assingment is to create a text file using notepad with all of my digital inputs and some how make those imputs show up on my digital indicators on my control pannel.
    When it was explained to me it didn't sound to hard of a task, I have no LabVIEW experience and the tutortial sucks.

    StevenD: FYI, I did NOT give you the one star rating. I would never do that!
    StevenD wrote:
    Ow. Someone is grumpy today.
    Well, this is an assignment, so it is probably homework.
    Why else would anyone give HIM such an assigment, after all he has no LabVIEW experience and the tutorials are too hard for him?
    This would make no sense unless all of it was just covered in class!
    This is not a free homework service with instant gratification.
    OK! Let's do it step by step. I assume you already have a VI with the digital indicators.
    "...but have no idea where to begin".
    open notepad.
    decide on a format, possibly one line per indicator.
    type the document.
    close notepad.
    open LabVIEW.
    Open the existing VI with all the indicators.
    (are you still following?)
    look at the diagram.
    Who made the program?
    Does the code make sense so far?
    Is it a statemachine or just a bunch of crisscrossed wires?
    Where do you want to add the file read?
    How should the file be read (after pressing a read button, at the start of the program ,etc.)
    See how far you get!
    Message Edited by altenbach on 06-24-2008 11:23 AM
    LabVIEW Champion . Do more with less code and in less time .

  • SAX: How to create new XML file using SAX parser

    Hi,
    Please anybody help me to create a XML file using the Packages in the 5.0 pack of java. I have successfully created it reading the tag names and values from database using DOM but can i do this using SAX.
    I am successful to read XML using SAX, now i want to create new XML file for some tags and its values using SAX.
    How can i do this ?
    Sachin Kulkarni

    SAX is a parser, not a generator.Well,
    you can use it to create an XML file too. And it will take care of proper encoding, thus being much superior to a normal textwriter:
    See the following code snippet (out is a OutputStream):
    PrintWriter pw = new PrintWriter(out);
          StreamResult streamResult = new StreamResult(pw);
          SAXTransformerFactory tf = (SAXTransformerFactory) TransformerFactory.newInstance();
          //      SAX2.0 ContentHandler.
          TransformerHandler hd = tf.newTransformerHandler();
          Transformer serializer = hd.getTransformer();
          serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");//
          serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"pdfBookmarks.xsd");
          serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"http://schema.inplus.de/pdf/1.0");
          serializer.setOutputProperty(OutputKeys.METHOD,"xml");
          serializer.setOutputProperty(OutputKeys.INDENT, "yes");
          hd.setResult(streamResult);
          hd.startDocument();
          //Get a processing instruction
          hd.processingInstruction("xml-stylesheet","type=\"text/xsl\" href=\"mystyle.xsl\"");
          AttributesImpl atts = new AttributesImpl();
          atts.addAttribute("", "", "someattribute", "CDATA", "test");
          atts.addAttribute("", "", "moreattributes", "CDATA", "test2");
           hd.startElement("", "", "MyTag", atts);
    String curTitle = "Something inside a tag";
              hd.characters(curTitle.toCharArray(), 0, curTitle.length());
        hd.endElement("", "", "MyTag");
          hd.endDocument();
    You are responsible for proper nesting. SAX takes care of encoding.
    Hth
    ;-) stw

  • How to Create a Flat File using FTP/File Adapter

    Can any body done workaround on creating the Flat file using FTP/File Adapter?.
    I need to create a simple FlatFile either using of delimiter/Fixed length. using the above said adapters we can create XML file, i tried concatinating all the values into a single String and writing into a file, but it does not have proper structure
    Can any body help me out on this..
    Thanks
    Ram

    You can create a text schema while creating a File Adapter. If schema is specified for File Adapter, it takes care of converting XML into fixed length or delimited format.
    Thanks,
    -Ng.

  • How do i create one source file that feeds two users on the same pro book?

    how do i create one source file/folder of photos that feeds two users on the same pro book?

    Well you can do exactly the same with a folder of photos, just put in the Users/Shared folder.
    Iphoto is a mite more complex than this. It's a database and so there's a bit more involved.
    For iPhoto 09 (version 8.0.2) and later:
    What you mean by 'share'.
    If you want the other user to be able to see the pics, but not add to, change or alter your library, then enable Sharing in your iPhoto (Preferences -> Sharing), leave iPhoto running and use Fast User Switching to open the other account. In that account, enable 'Look For Shared Libraries'. Your Library will appear in the other source pane.
    Any user can drag a pic from the Shared Library to their own in the iPhoto Window.
    Remember iPhoto must be running in both accounts for this to work.
    If you want the other user to have the same access to the library as you: to be able to add, edit, organise, keyword etc.
    Quit iPhoto in both accounts. Move the Library to the Users / Shared Folder
    (You can also use an external HD set to ignore permissions, a Disk Image or even partition your Hard Disk.)
    In each account in turn: Double click on the Library to open it. (You may be asked to repair the Library Permissions.) From that point on, this will be the default library location. Both accounts will have full access to the library, in fact, both accounts will 'own' it.
    However, there is a catch with this system and it is a significant one. iPhoto is not a multi-user app., it does not have the code to negotiate two users simultaneously writing to the database, and trying will cause db corruption. So only one user at a time, and back up, back up back up.

  • Creating an output  file using 'GUI_DOWNLOAD' function

    Hi SapAll.
    when i try to create an out put text file using the FM 'GUI_DOWNLOAD' by wiring the follwoing below source code
    CONCATENATE 'ASORT' c_tab 'ASORTYP' c_tab
                    'VKORG' c_tab 'DATAB' c_tab
                    'DATBI' INTO outtab-txt.
    iam not able to create the text file with more than 16 fields.i have tried to create an out put file with 24 fields but i can only see 16 fields in it.so could any body help me in finding out how i can create an Output file with more than 16 fields in the file.
    your help will be appreciated.
    regards.
    Varma

    check your output definition....are you doing something like below?  SAP will transfer 1024 bytes per line with GUI_DOWNLOAD.    After you download, how do you view the data?  Be sure you're looking at the data with something that will show all 1024 bytes, and not jsut 256 or 512.
    types: begin of outline,
               txt(1024),
             end of outline.
    data: outtab type table of outline,
             ls_out type outline.

Maybe you are looking for

  • Writing an XML file using a Servlet

    Hello, I'm trying to code a servlet that receives a POST from a HTTP and output its data to a XML file, the problem is that I get the following error: The XML page cannot be displayed Cannot view XML input using style sheet. Please correct the error

  • F110 performance issue

    Hi guys, We have been using F110 for a very long time. From the past few weeks, the speed performance of the program has become very slow. No enhancements were made or no changes were made. Can anyone help to me to fix this and make it work at a fast

  • InfoPackage loading giving IDOC Error: Status 51

    Hello Experts, 1) I created a DB view (ZZVIEW05) in the SD area on R3    and it extracts data OK in RSA3. 2) I replicated the DataSource in BW, Created InfoSOurce    activated and created an InfoPackage. 3) Scheduling the InfoPackage is failing with

  • How to delete Folders and Files older than 10 day ?

    If I use this below command, I am able to delete only the files and files in sub-folders older than 10 day, forfiles /p "D:\Testing\Sample" /s /d -10 /c "cmd /c del /s /q @file" Please help... Thanks

  • Superdrive not appearing on Finder on my iMac will not burn JPG files

    Superdrive is not appearing on Finder and in drive Utilities it will not burn JPG files - says doesn't recognize the file type.  The more I am exposed to Apple the more they look like Microsoft.  If the drive doesn't work with the IMAC then why the *