Writing blob data to a file

HI,
I have a table with following structure
Test_Mail(Attachment BLOB,Attachmentname varchar2(255),FileSize number)
The data in the table is like
Attachment|Attachmentname|FileSize
BLOB|test.txt|1236
I wants to read the data from the BLOB attachment in to new file.
The data in the file is
Ename|JOB|DEPTNO|SALARY
ford|salesman|10|5555
boye|salesman|10|3333
smith|clerk|20|3000
Iam using the following procedure to do the same
create or replace
procedure SAVE_TO_FILE as
vblob blob;
i2 number;
amt number := 10000;
len number;
my_vr raw(10000);
l_output utl_file.file_type;
p_dir varchar2(30) default '/home/test';
p_file varchar2(30) := 'output.txt';
begin
l_output := utl_file.fopen(p_dir, p_file,'w',32767);
for l_cur in (SELECT ATTACHMENT vblob FROM test_email)
loop
len :=DBMS_LOB.GETLENGTH(l_cur.vblob);
vblob := l_cur.vblob ;
dbms_output.put_line('Length of the Column : ' || to_char(len));
i2 := 1;
if len < 10000 then
DBMS_LOB.READ(vblob,len,i2,my_vr);
utl_file.put(l_output,UTL_RAW.CAST_TO_VARCHAR2(my_vr) );
else
DBMS_LOB.READ(vblob,amt,i2,my_vr);
utl_file.put(l_output, UTL_RAW.CAST_TO_VARCHAR2(my_vr) );
end if;
i2 := i2 + amt;
while (i2 < len)
loop
dbms_output.put_line('i2 : ' || to_char(i2));
DBMS_LOB.READ(vblob,amt,i2,my_vr);
utl_file.put(l_output, UTL_RAW.CAST_TO_VARCHAR2(my_vr));
utl_file.fflush(l_output);
i2 := i2 + amt ;
end loop;
utl_file.fclose(l_output);
end loop;
commit;
end SAVE_TO_FILE;
The problem here is it is reading only 19 bytes and output is
Ename|JOB|DEPTNO|SALAR
can any one please help me in sloving this isssue??
Thanks in advance
Balaji tk

Duplicate post.
Re: Reading the data from BLOB column

Similar Messages

  • Error while writing the data into the file . can u please help in this.

    The following error i am getting while writing the data into the file.
    <bindingFault xmlns="http://schemas.oracle.com/bpel/extension">
    <part name="code">
    <code>null</code>
    </part>
    <part name="summary">
    <summary>file:/C:/oracle/OraBPELPM_1/integration/orabpel/domains/default/tmp/
    .bpel_MainDispatchProcess_1.0.jar/IntermediateOutputFile.wsdl
    [ Write_ptt::Write(Root-Element) ] - WSIF JCA Execute of operation
    'Write' failed due to: Error in opening
    file for writing. Cannot open file:
    C:\oracle\OraBPELPM_1\integration\jdev\jdev\mywork\
    BPEL_Import_with_Dynamic_Transformation\WORKDIRS\SampleImportProcess1\input for writing. ;
    nested exception is: ORABPEL-11058 Error in opening file for writing.
    Cannot open file: C:\oracle\OraBPELPM_1\integration\jdev\jdev\mywork\
    BPEL_Import_with_Dynamic_Transformation
    \WORKDIRS\SampleImportProcess1\input for writing. Please ensure 1.
    Specified output Dir has write permission 2.
    Output filename has not exceeded the max chararters allowed by the
    OS and 3. Local File System has enough space
    .</summary>
    </part>
    <part name="detail">
    <detail>null</detail>
    </part>
    </bindingFault>

    Hi there,
    Have you verified the suggestions in the error message?
    Cannot open file: C:\oracle\OraBPELPM_1\integration\jdev\jdev\mywork\BPEL_Import_with_Dynamic_Transformation\WORKDIRS\SampleImportProcess1\input for writing.
    Please ensure
    1. Specified output Dir has write permission
    2. Output filename has not exceeded the max chararters allowed by the OS and
    3. Local File System has enough space
    I am also curious why you are writing to a directory with the name "..\SampleImportProcess1\input" ?

  • Writing binary data to a file without carriage returns every 512 bytes

    Is there a VI for writing binary data to a file without carriage returns being inserted every 512 bytes?
    Thanks

    Hi Momolxg,
    I could be way off on this. I tried to simulate what you've done by
    making a for loop that would run a set number of times. For my example I
    used 1025. I wired the iteration terminal to a 'Write to SGL File.vi'
    outside the loop with indexing enabled. It wrote the SGL data from 0 to
    1024 to the file. I then read the file with a 'Read Characters from
    File.vi' and searched the output for a carriage return (0D hex). It was
    found five times. The reason why was the SGL number it was reading had a
    13 (0D hex) in it. Perhaps you're running into a similar problem?
    I tried it again, this time using the 'Write to I16 File.vi'. The
    carriage return was found five times: the 28th character the first time
    then on the 512th character four consecutive time
    s after that. I suppose
    that makes sense that you'd find a 0D in the numbers at equal spacings if
    they're incrementing this way... In this case the carriage returns you're
    seeing are actually numbers from your data.
    One big difference is that I'm using a set pattern of numbers. This
    doesn't appear to be your case. Is there a better way we can duplicate
    your problem? It sounds interesting. Again my simulation could be way
    off. (I'm also running this on LV60 for Linux so my results could be
    different)
    - Kevin
    In article <[email protected]>,
    "momolxg" wrote:
    > Is there a VI for writing binary data to a file without carriage returns
    > being inserted every 512 bytes? Thanks

  • Writing HTML data in TEXT File

    I am writing HTML content in TEXT file ...I read it in a string and then write using PrintStream...
    But it writes all content on one line ..I want to write it as it was in source HTML file...

    Perchance, the OP is referring to the lack of carriage returns in his outputted data, and querying where they have absconded to? An analysis of his posts to date reveals that he has read the contents of a File into a String variable, and wants to write the (presumably modified) String back to a file (uncertain as to whether this is the same file or a different one) In the process of outputting to said file, carriage returns previously contained in the original input file are not present in the output. I would hazard a guess that the OP does not want said carriage returns in the String to disappear.
    Is my analysis of the situation correct?
    An example of the code that you have written to date would be of extreme usefulness to us in aiding you in your noble quest.
    Without such a resource, I must rely on my intuition instead.
    Possible places that the carriage returns are being "dropped"
    1 - On reading in. Are you discarding carriage returns while building up your variable?
    2 - On manipulating. Are you processing this line by line, or reading it all into one large variable?
    3 - On output - are you using "print" or "println" in the output?
    I look forward to further correspondence with you sir
    kind regards,
    evnafets

  • Question around UTL_FILE and writing unicode data to a file.

    Database version : 11.2.0.3.0
    NLS_CHARACTERSET : AL32UTF8
    OS : Red Hat Enterprise Linux Server release 6.3 (Santiago)
    I did not work with multiple language characters and manipulating them. So, the basic idea is to write UTF8 data as Unicode file using UTL_FILE. This is fairly an empty database and does not have any rows in at least the tables I am working on. First I inserted a row with English characters in the columns.
    I used utl_file.fopen_nchar to open and used utl_file.put_line_nchar to write it to the file on the Linux box. I open the file and I still see English characters (say "02CANMLKR001".
    Now, I updated the row with some columns having Chinese characters and ran the same script. It wrote the file. Now when I "vi" the file, I see "02CANè¹æ001" (some Unicode symbols in place of the Chinese characters and the regular English.
    When I FTP the file to windows and open it using notepad/notepad++ it still shows the Chinese characters. Using textpad, it shows ? in place of Chinese characters and the file properties say that the file is of type UNIX/UTF-8.
    My question : "Is my code working and writing the file in unicode? If not what are the required changes?" -- I know the question is little vague, but any questions/suggestions towards answering my question would really help.
    sample code:
    {pre}
    DECLARE
       l_file_handle   UTL_FILE.file_type;
       l_file_name     VARCHAR2 (50) := 'test.dat';
       l_rec           VARCHAR2 (250);
    BEGIN
       l_file_handle := UTL_FILE.fopen_nchar ('OUTPUT_DIR', l_file_name, 'W');
       SELECT col1 || col2 || col3 INTO l_rec FROM table_name;
       UTL_FILE.put_line_nchar (l_file_handle, l_rec);
       UTL_FILE.fclose (l_file_handle);
    END;
    {/pre}

    Regardless of what you think of my reply I'm trying to help you.
    I think you need to reread my reply because I can't find ANY relation at all between what I said and what you responded with.
    I wish things are the way you mentioned and followed text books.
    Nothing in my reply is related to 'text books' or some 'academic' approach to development. Strictly based on real-world experience of 25+ years.
    Unfortunately lot of real world projects kick off without complete information.
    No disagreement here - but totally irrevelant to anything I said.
    Till we get the complete information, it's better to work on the idea rather than wasting project hours. I don't think it can work that way. All we do is to lay a ground preparation, toy around multiple options for the actual coding even when we do not have the exact requirements.
    No disagreement here - but totally irrevelant to anything I said.
    And I think it's a good practice rather than waiting for complete information and pushing others.
    You can't just wait. But you also can't just go ahead on your own. You have to IMMEDIATELY 'push others' as soon as you discover any issues affecting your team's (or your) ability to meet the requirements. As I said above:
    Your problems are likely:
    1. lack of adequate requirements as to what the vendor really requires in terms of format and content
    2. lack of appropriate sample data - either you don't have the skill set to create it yourself or you haven't gotten any from someone else.
    3. lack of knowledge of the character sets involved to be able to create/conduct the proper tests
    If you discover something missing with the requirements (what character sets need to be used, what file format to use, whether BOMs are required in the file, etc) you simply MUST bring that to your manager's attention as soon as you suspect it might be an issue.
    It is your manager's job, not yours, to make sure you have the tools needed to do the job. One of those tools is the proper requirements. If there is ANYTHING wrong, or if you even THINK something is wrong with those requirements it is YOUR responsibility to notify your manager ASAP.
    Send them an email, leave a yellow-sticky on their desk but notify them. Nothing in what I just said says, or implies, that you should then just sit back and WAIT until that issue is resolved.
    If you know you will need sample data you MUST make sure the project plan includes SOME means to obtain sample data witihin the timeline needed by your project. As I repeated above if you don't have the skill set to create it yourself someone else will need to do it.
    I did not work with multiple language characters and manipulating them.
    Does your manager know that? If the project requires 'work with multiple language characters and manipulating them' someone on the project needs to have experience doing that. If your manager knows you don't have that experience but wants you to proceed anyway and/or won't provide any other resource that does have that experience that is ok. But that is the manager's responsibility and that needs to be documented. At a minimum you need to advise your manager (I prefer to do it with an email) along the following lines:
    Hey - manager person - As you know I have little or no experience to 'work with multiple language characters and manipulating them' and those skills are needed to properly implement and test that the requirements are met. Please let me know if such a resource can be made available.
    And I'm serious about that. Sometimes you have to make you manager do their job. That means you ALWAYS need to keep them advised of ANY issue that might affect the project. Once your manager is made aware of an issue it is then THEIR responsibility to deal with it. They may choose to ignore it, pretend they never heard about it or actually deal with it. But you will always be able to show that you notified them about it.
    Now, I updated the row with some columns having Chinese characters and ran the same script.
    Great - as long as you actually know Chinese that is; and how to work with Chinese characters in the context of a database character set, querying, creating files, etc.
    If you don't know Chinese or haven't actually worked with Chinese characters in that context then the project still needs a resource that does know it.
    You can't just try to bluff your way through something like character sets and code conversions. You either know what a BOM (byte order mark) is or you don't. You have either learned when BOMs are needed or you haven't.
    That said, we are in process of getting the information and sample data that we require.
    Good!
    Now make sure you have notified your manager of any 'holes' in the requirements and keep them up to date with any other issues that arise.
    NONE of the above suggests, or implies, that you should just sit back and wait until that is done. But any advice offered on the forums about specifics of your issue (such as whether you need to even worry about BOMs) is premature until the vendor or the requirements actually document the precise character set and file format needed.

  • Writing blob value to a file

    I am using the below code to write the contents of a blob column in a table to a txt file. My procedure is getting executed successfully.But I am not able to find the text file in the given directory.
    SQL> CREATE OR REPLACE PROCEDURE Write_Binary_file
    2 (
    3 pcdir IN VARCHAR2
    4 ,pcflnm IN VARCHAR2
    5 ,P_raise IN BOOLEAN DEFAULT FALSE
    6 )
    7 -- -------------------------------------------
    8 -- Procedure to dump a BLOB column onto a file
    9 -- -------------------------------------------
    10 -- parameters:
    11 -- pcdir : name of an existing Oracle Directory
    12 -- pcflnm : name of the expected output file
    13 -- P_raise : boolean to indicate if the process
    14 -- would be stopped after an error
    15 --
    16 IS
    17 src_lob BLOB;
    18 buffer RAW(16384);
    19 amt BINARY_INTEGER := 16384;
    20 pos INTEGER := 1;
    21 out_file UTL_FILE.FILE_TYPE ;
    22 Err_msg VARCHAR2(2000) ;
    23 BEGIN
    24
    25 -- get the BLOB column --
    26 BEGIN
    27 select CONTENT_DATA INTO src_lob from pstars.REPORT_INSTANCES where id=29;
    28 EXCEPTION
    29 WHEN NO_DATA_FOUND THEN
    30 Err_msg := 'Write_Binary_File(): NO_DATA_FOUND' ;
    31 IF P_raise THEN
    32 RAISE_APPLICATION_ERROR( -20100, Err_msg ) ;
    33 END IF ;
    34 Dbms_Output.Put_Line(Err_msg) ;
    35 RETURN ;
    36 END ;
    37
    38 -- open the output file --
    39 out_file := UTL_FILE.FOPEN( pcdir, pcflnm, 'W', 32764 ) ;
    40
    41 -- write the file --
    42 while pos<dbms_lob.getlength(src_lob)
    43 LOOP
    44 -- read the chunks --
    45 Dbms_Lob.READ (src_lob, amt, pos, buffer);
    46 -- write the chunks --
    47 Utl_File.Put_Raw(out_file, buffer);
    48 pos := pos + amt;
    49 END LOOP;
    50 -- close the file --
    51 Utl_File.Fclose(out_file);
    52
    53 EXCEPTION
    54 WHEN NO_DATA_FOUND THEN
    55 utl_file.fclose(out_file);
    56 WHEN OTHERS THEN
    57 Err_msg := 'Write_Binary_File() Error : ' || TO_CHAR( SQLCODE ) || ' while managing file ('
    58 || pcdir || ') ' || pcflnm ;
    59 IF P_raise THEN
    60 RAISE_APPLICATION_ERROR( -20100, Err_msg ) ;
    61 END IF ;
    62 Dbms_Output.Put_Line(Err_msg);
    63 END Write_Binary_file;
    64 /
    Procedure created
    SQL> exec Write_Binary_file('dir_temp','rpt_inst.txt');
    PL/SQL procedure successfully completed
    SQL> select * from dba_directories;
    OWNER DIRECTORY_NAME DIRECTORY_PATH
    SYS VWC D:\Oracle9iserver\vwcode
    SYS MYDIR C:\load_SLD\
    SYS DIR_TEMP D:\temp
    SQL> exec Write_Binary_file('VWC','rpt_inst.txt');
    PL/SQL procedure successfully completed
    SQL>

    Your exception code is wrong because if P_RAISE is set to FALSE you won't see any exception.
    Run you code with P_RAISE set to TRUE and with:
    set serveroutput on

  • How to writing the data into the file at the same frequency of data acquisition using myRIO

    Hi everyone,
    I have a question regarding data acquisition fequency and data recording frequency of myRIO. Hope you guys can help me out.
    Basically, I want to acquire voltage input at analog input 0 at the frequency of 1kHz and then write the data into a file (tdms format). 
    However, I always found there were only 55 or 56 data points recorded every second in the data file (see the excel sheet). 
    To confirm my data acquisition was performed at the correct frequency, I added a small function in the main loop to indicate the time spent between two acquisition events. 
    To my surprise, the period of data acquistion is correct (1ms or 1kHz) but there are only 55 or 56 data point per second recorded in the data file.
    How can I record every data point acquired by the analog input?
    Thank you!
    P.S. I am very new to myRIO. How can I manually set the system time for myRIO? The default time of my myRIO is wrong. 
    Best,
    Tengyang
    Attachments:
    test result.xlsx ‏16 KB
    Main with timed loop.vi ‏122 KB
    test result.xlsx ‏16 KB

    Have a look at the Jakarta POI project, they have a Java API for creating Word documents.
    http://jakarta.apache.org/poi/hwpf/index.html

  • Writing the datas from 2 files into 3rd File?

    Hi,
    I am reading datas from 2 files Say,
    Example1.txt
    Ashok
    Babu
    Chenthil
    Danny
    Example2 .txt
    ^data1^data2^data3
    ^data1^data2^data3
    ^data1^data2^data3
    ^data1^data2^data3
    I want those data's to be written in a 3rd file. Say,
    Example3.txt
    Ashok^ data1^data2^data3
    Babu^ data1^data2^data3
    Chenthil^ data1^data2^data3
    Danny^ data1^data2^data3
    So that i can tokenize it with a delimeter(^) and get the values. Here how to append the datas in this form in Example3.txt. Eventhough u use FileWriter with append "true" as a parameter how they will apend like the Example3.txt file? Please do provide an answer for this..Since this is very urgent to be delivered...Expecting postive response.
    Thanx,
    JavaCrazyLover

    open the outputfile, open both input files (all three, of course, as their own stream, obviously, but I thought I might need to say this), first. Read a line from each inputfile, and write both of them together, to the outputfile, and repeat.
    Is there something you don't understand there?

  • Writing binary data to ASP file from applet through URLConnection

    Hi Everybody,
    I am facing a proble with HttpURLConnection.I want to write some binary data from applet to an ASP file.The other end ASP file read this binary data and process , Here problem is I have opened URLConnection to the page and Created OutputStream and writing byte by Write() method But other end we are not getting bytes...we are not getting error too at java side..can any body help me..do we need to set any property to URLConnection...here I am giving sample code...
    OutputStream os;
    URL uConnect2;
    HttpURLConnection hucConnect2;
    uConnect2= new URL("http://webserver/vnc/sendtoserver.asp?"); hucConnect2=(HttpURLConnection)uConnect2.openConnection();
    hucConnect2.setDoOutput(true);
    hucConnect2.setRequestMethod("POST")
    os=new DataOutputStream(hucConnect2.getOutputStream());
    os.writeBytes("Hello");
    Thanks in Advance
    Madhav

    Do you remember to flush() and close() the stream?

  • Writing BLOB column into a file (NT/WinWord)

    I need to create
    a file on NT and extract the contents of a BLOB
    column and put it in the file. It's a WORD-document
    and I'm using 8.1.7 on NT4SP5. I'm thinking some
    combination of the LOB package and UTL_FILE, but
    some far no luck. Example code would help me.
    Thanks in advance
    Dannys

    dbms_lob, utl_lob is not supported by oracle, written by an in-
    house analyst to demonstrate a concept.

  • Problems writing BLOB data into O8i (ADO and AppendChunk)

    We have a table where you want to store bianry data (BLOBs). I
    have used the LONG RAW datatype to store this information. Here
    is the code for the table:
    CREATE TABLE "CONTENTBLOBTABLE" (
    DIGEST NVARCHAR2(40) NOT NULL,
    BLOB LONG RAW,
    CHECK (DIGEST IS NOT NULL),
    PRIMARY KEY (DIGEST)
    Then we try to update this table with ADO 2.6 on a Windows 200
    machine with Oracle ODBC driver. Here is the relevant code
    snippet:
    // set the value of the field
    pRs->AddNew();
    pRs->Fields->GetItem("DIGEST")->PutValue(strDigest);
    pRs->Fields->GetItem("BLOB")->AppendChunk(varBLOB);
    if(!pRs->Update())
    C_LOG_CRITICAL(L"CC_CS_DAL::WriteBLOB - pRs->Update failed");
    *error = C_CS_CBT_ERROR;
    pRs->CancelUpdate();
    pRs->Close();
    m_pConn->Close();
    m_spObjectContext->SetAbort();
    return S_FALSE;
    OK, NO error occurs: no exception, HRESULT return values are all
    OK, method completes.
    BUT: there is no data in the table!?!?! When querying the exact
    same table we get an empty result!
    Any ideas please?
    Thanks,
    Christian

    Did you even get a reply to this message?

  • Is writing IPTC data in JPG files a lossless operation?

    When an opened JPG files is resaved it is lossy.
    In Bridge the file is not opened but is still resaved after entering IPTC data.

    I don't know for sure, but I don't see why it shouldn't be a lossless operation. Image data shouldn't be touched, and the metadata will just be appended to the file.

  • Reading the Blob and writing it to an external file in an xml tree format

    Hi,
    We have a table by name clarity_response_log and content of the column(Response_file) is BLOB and we have xml file or xml content in that column. Most probably the column or table may be having more than 5 records and hence we need to read the corresponding blob content and write to an external file.
    CREATE TABLE CLARITY_RESPONSE_LOG
      REQUEST_CODE   NUMBER,
      RESPONSE_FILE  BLOB,
      DATE_CRATED    DATE                           NOT NULL,
      CREATED_BY     NUMBER                         NOT NULL,
      UPDATED_BY     NUMBER                         DEFAULT 1,
      DATE_UPDATED   VARCHAR2(20 BYTE)              DEFAULT SYSDATE
    )The xml content in the insert statement is very small because of some reason and cannot be made public and indeed we have a very big xml file stored in the BLOB column or Response_File column
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (5, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (6, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (7, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (8, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');
    Insert into CLARITY_RESPONSE_LOG
       (REQUEST_CODE, RESPONSE_FILE, DATE_CRATED, CREATED_BY, UPDATED_BY, DATE_UPDATED)
    Values
       (9, '<?xml version="1.0" encoding="UTF-8"?><xml-response><phone-number>1212121212</tracking-number></xml-response>', TO_DATE('09/23/2010 09:01:34', 'MM/DD/YYYY HH24:MI:SS'), 1, 1, '23-SEP-10');THe corresponding proc for reading the data and writing the data to an external file goes something like this
    SET serveroutput ON
    DECLARE
       vstart     NUMBER             := 1;
       bytelen    NUMBER             := 32000;
       len        NUMBER;
       my_vr      RAW (32000);
       x          NUMBER;
       l_output   UTL_FILE.FILE_TYPE;
    BEGIN
    -- define output directory
       l_output :=
          UTL_FILE.FOPEN ('CWFSTORE_RESPONCE_XML', 'extract500.txt', 'wb', 32760);
       vstart := 1;
       bytelen := 32000;
    ---get the Blob locator
       FOR rec IN (SELECT response_file vblob
                     FROM clarity_response_log
                    WHERE TRUNC (date_crated) = TRUNC (SYSDATE - 1))
       LOOP
    --get length of the blob
    len := DBMS_LOB.getlength (rec.vblob);
          DBMS_OUTPUT.PUT_LINE (len);
          x := len;
    ---- If small enough for a single write
    IF len < 32760
          THEN
             UTL_FILE.put_raw (l_output, rec.vblob);
             UTL_FILE.FFLUSH (l_output);
          ELSE  
    -------- write in pieces
             vstart := 1;
             WHILE vstart < len AND bytelen > 0
             LOOP
                DBMS_LOB.READ (rec.vblob, bytelen, vstart, my_vr);
                UTL_FILE.put_raw (l_output, my_vr);
                UTL_FILE.FFLUSH (l_output);
    ---------------- set the start position for the next cut
                vstart := vstart + bytelen;
    ---------- set the end position if less than 32000 bytes
                x := x - bytelen;
                IF x < 32000
                THEN
                   bytelen := x;
                END IF;
                UTL_FILE.NEW_LINE (l_output);
             END LOOP;
    ----------------- --- UTL_FILE.NEW_LINE(l_output);
          END IF;
       END LOOP;
       UTL_FILE.FCLOSE (l_output);
    END;The above code works well and all the records or xml contents are being written simultaneously adjacent to each other but we each records must be written to a new line or there must be a line gap or a blank line between any two records
    the code which I get is as follow all all xml data comes on a single line
    <?xml version="1.0" encoding="ISO-8859-1"?><emp><empno>7369</empno><ename>James</ename><job>Manager</job><salary>1000</salary></emp><?xml version="1.0" encoding="ISO-8859-1"?><emp><empno>7370</empno><ename>charles</ename><job>President</job><salary>500</salary></emp>But the code written to an external file has to be something like this.
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <emp>
      <empno>7369</empno>
      <ename>James</ename>
      <job>Manager</job>
      <salary>1000</salary>
    </emp>
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <emp>
    <empno>7370</empno>
    <ename>charles</ename>
    <job>President</job>
    <salary>500</salary>
    </emp>Please advice

    What was wrong with the previous answers given on your other thread:
    Export Blob data to text file(-29285-ORA-29285: file write error)
    If there's a continuing issue, stay with the same thread, don't just ask the same question again and again, it's really Pi**es people off and causes confusion as not everyone will be familiar with what answers you've already had. You're just wasting people's time by doing that.
    As already mentioned before, convert your BLOB to a CLOB and then to XMLTYPE where it can be treated as XML and written out to file in a variety of ways including the way I showed you on the other thread.
    You really seem to be struggling to get the worst possible way to work.

  • Writing Data to Multiple Files

    Hi,
    I got a problem while writing the data to multiple files.
    Actually my requirement is,
    I want to read the data from multiple files and retrieve the required data from those and save that data into separate files.
    Meaning if i read the data from "D:\kiran\kk\123\kiran.txt" the retrieved data should be saved in "D:\kiran\kk\kiran.txt" the file name should be created with the input file name.
    here is my code,
    //here i am taking the files into loop
    for(int i=0;i<files.length;i++){
    try{                   
    //reading the files
    BufferedReader br=new BufferedReader(new FileReader(files));
    //creating a new file for writing the retrieved data
    pw=new PrintWriter("D:\\Kiran\\kk"+File.separator.concat(str[i]));
    String line=br.readLine();
    while(line!=null){
    line=br.readLine();
    //here i am matching the required data
    Matcher m = Pattern.compile("name(\\s*\\W*\\w*\\W*.\\w*.)|invoice (\\W*(\\d+))|amount(\\W*(\\d+),\\d*)|site(\\s*Rs\\.[\\d]*,[\\d]*/-)", Pattern.CASE_INSENSITIVE).matcher(line);
    while(m.find()){                           
    System.out.println(m.group());
    //here printing the retrieved data to a file
    pw.println(m.group());
    br.close();
    but i am ending up with some issues.
    Data is reading properly from all the files, but when i write that data into individual files the data which is retrieved from last file is only printing into the file which is created last.
    Please help me regarding this,
    Thanks,
    Kiran

    D:\kiran\kk\123\
    In this folder some files are there say,
    kk.txt,kiran.txt,praveen.txt and so on, i can read the entire data from those files and also retrieving the required data like name,data etc. from all the files. Now the retrieved data should be stored in individual files means, if the data is retrieved from kk.txt then that particular data should be stored in the file with the same file name but in different location likewise it should happen for all the files those are in that folder.
    Thanks,
    Kiran

  • Export BLOB data to a Word Document.

    Dear All,
    I am facing a problem during reading a blob data to a word file. My procedure work fine fine. But when I am about to open the Word Document. It gives me a message that "the document name or path is not valid. 1. Check the file permission for the document or drive. 2. Use the file open dialog box to locate the document."
    I am using 9i for this.
    Best Regards
    Umer Minhas

    Basically this happens when I write the blob data in Word File.
    I investigate this problem on MS sites and come to know that it was basically "328100 - WD2002: The Document Name or Path Is Not Valid".
    But after installation of hotfix, I again saw the same message. But when I use the utility of TOAD to export the data. It done all very well. This what basically estonished me.
    Best Regards
    Umer Minhas.

Maybe you are looking for

  • Hangs on Mac

    SQL Developer hangs on my mac with the following specs.  See error below OS X 10.9.1 java version "1.7.0_45" Java(TM) SE Runtime Environment (build 1.7.0_45-b18) Java HotSpot(TM) 64-Bit Server VM (build 24.45-b08, mixed mode) from the terminal sh /Ap

  • Orale 9i client for woindows does not appear to be a valid archive

    Can download the zip file but cannot open it because it does not appear to be a valid archive. Any hint ? Thanxs, Reno

  • OSX 10.5.6 Update -- Strange

    Strange problem with this MacBook pro with every update I've done.... Works absolutely great with speed and stability improvements... W000000000000T. Love my MBP. Can we get some apple love in the house?

  • Need StackTrace For Single request till Response

    As we all know in Jdevloper if we want to see the StackTrace we need to put a dubug point and then we can see the StackTrace for that request. but i need a StackTrace for Every single HTTP Request till Response that means no need to put break point.

  • Disable Auto-Centring When Printing Multiple Pages

    Hello, I am using Adobe Reader XI Version 11.0.04 (mac). I am trying to print multiple pages (specifically custom 1 by 3 portrait), but am finding that the 3 pages auto-centre (appear in the middle of the page). Is there a way to disable this auto-ce