Utl_file errors

create or replace procedure load_student
(pdir varchar2, pfile varchar2) is
vfile utl_file.file_type;
vtext varchar2(200);
vname varchar2(20);
vcourse varchar2(20);
vfee number(5);
fcomma number(3);
scomma number(3);
begin
vfile := utl_file.fopen(pdir,pfile,'r');
Loop
BEGIN
utl_file.get_line(vfile,vtext);
EXCEPTION
when no_data_found then
exit;
END;
fcomma := instr(vtext,',',1,1); -- 5
scomma := instr(vtext,',',1,2); -- 14
vname := substr(vtext,1,fcomma-1);
vcourse := substr(vtext,fcomma+1,scomma-fcomma-1);
vfee := substr(vtext,scomma+1);
insert into student values(student_sq.nextval,vname,vcourse,vfee);
end loop;
commit;
exception
when utl_file.read_error then
dbms_output.put_line(' Unable to read the file...... ');
end load_student;
when i am executing i get following error
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at "SYS.LOAD_STUDENT", line 11
ORA-06512: at line 3
View program sources of error stack?
please help me when you know the answer,immidiatly

Can you show the directory path. I think issue is there only. Anyways, i would repeat my prev replies for your help.
If your file is located on the client system, you dnt have to give ip address and exact path. You have to give machine name along with shared address. Suppose the file a.txt is located in C:\Files\. And you have put this folder on shared.
Grant R/W access to the server for the folder.
Create directory MYDIR as '\\Client_Name\Files\'Now Grant access priveleges to the user using UTL_FILE utility.
For server file location, you can specify the exact path in the directory path.
Hope my points helps you out.

Similar Messages

  • UTL_FILE error when using UTL_FILE.PUT instead of UTL_FILE.PUT_LINE?

    We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
    l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
    The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 77
    ORA-06512: at "SYS.UTL_FILE", line 690
    ORA-06512: at "ADVCONV.P_WRITE", line 244
    ORA-06512: at line 2.
    If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks

    893730 wrote:
    We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
    l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
    The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 77
    ORA-06512: at "SYS.UTL_FILE", line 690
    ORA-06512: at "ADVCONV.P_WRITE", line 244
    ORA-06512: at line 2.
    If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks
    >We need to export a large amount of data from some Oracle tables to be uploaded into a Sybase database using BCP. I had no issues exporting the data using the PUT_LINE command using the open command below.
    l_file := utl_file.fopen( l_dir, l_name, 'W',32767);
    The problem is, we do not want to use system's default line terminators because our data may contain embedded line terminators; We want to defined our own line terminators. But when we changed from UTL_FILE.PUT_LINE to UTL_FILE.PUT the application will run for a few seconds and then produce the following errors:
    ORA-29285: file write error
    ORA-06512: at "SYS.UTL_FILE", line 77
    ORA-06512: at "SYS.UTL_FILE", line 690
    ORA-06512: at "ADVCONV.P_WRITE", line 244
    ORA-06512: at line 2.
    If I use UTL_FILE.PUT to export smaller tables these errors do not occur so it looks like our data is larger then some limit. Does anyone have any suggestions/solutions? Thanks
    consider using PUT_RAW instead of PUT_LINE

  • Reg UTL_FILE error

    hi all,
    iam using utl_file in my procedure.while executing the script its showing error as
    ERROR at line 1:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    ORA-06512: at line 1
    ORA-06512: at "DBUSER.INPUT_AS", line 60
    ORA-06512: at line 1
    but i have created directory as output and granted permission to the user also.
    but still its showing error .can anybody pls help me out...
    thanks in advance,
    Ratheesh

    Have you assigned that value in the parameter file of
    your database. If not this will give you error.
    In your parameter file UTL_FILE_DIRECTORY should be
    set to that directory path or as * .
    I have to keep saying this, but NO IT SHOULD NOT!!!!
    UTL_FILE_DIR parameter is the "old" way of doing things and leaves your operating system open to security issues. You should not use this parameter and more importantly, you should NEVER set that parameter to "*" otherwise someone may gain access to your whole operating system.
    The correct way of using UTL_FILE is to create Directory Objects on the database and grant the relevant permissions to the users who require access.

  • UTL_FILE errors,  invalid directory path ???

    Hi All,
    I am trying to create a csv output file through pl/sql.
    However i am having some issues since its my first time.
    Please have a look at the following code:
    create or replace
    PROCEDURE amer_main_proc (start_sent_date date,
                        end_sent_date date,
                        senttype number) IS
    CURSOR main_cur IS
    SELECT
              s.sent_id,
              s.ussc_id,
              s.sent_upd_date,
              s.alt_docket,
              s.amend_year,
              s.def_num,
              s.dep_status_code,
              s.var_status_code,
              s.disp_type_code,
              s.docket,
              s.oth_sent_code,
              substr(s.oth_text,1,100) oth_text,
              s.po_code,
              ind.prim_offn_code,
              s.prob_mons
    FROM      sentences s,
              submission sub,
              ind_sent ind,
              defendants def,judges j
    WHERE      s.sent_id = sub.sent_id
    AND      s.sent_id = ind.sent_id
    AND      ((sub.case_type_code in (10,11) 
    AND      trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (10)  AND trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (11) AND trunc(sent_vio_date) between start_sent_date and end_sent_date) or
              (sub.case_type_code in (11) and  s.amend_code = 10 AND trunc(sub.create_date) between start_sent_date and end_sent_date))
              AND s.def_id=def.def_id
              AND s.ao_judge_id = j.ao_judge_id
              AND sent_creator_id is not null
              AND dist_id != 99
    ORDER BY s.ussc_id, s.sent_id;
    --Define output file variables
    out_file UTL_FILE.FILE_TYPE;        /* file type */
    path_name VARCHAR2(50);            /* file path */
    file_name VARCHAR2(50);            /* file name */
    line_buffer VARCHAR2(2000);        /* store all the elements that make up one line in the output file */
    BEGIN
        path_name := 'C:\SQL';  // this folder does exist in my C drive
        file_name := 'main.txt';
        out_file := UTL_FILE.FOPEN(path_name, file_name, 'W');
        line_buffer := 'data main;';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        line_buffer := 'infile cards delimiter='','';';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        line_buffer := 'input ' ||
        'USSCIDN ' ||
        'ALT1DOC $ ' ||
        'DEPART ' ||
        'VARIAN ' ||
        'DISPOSIT ' ||
        'DOCKETID $ ' ||
        'TYPEOTHS ' ||
        'TYPEOTTX $ ' ||
        'POOFFICE $ ' ||
        'MONOFFTP ' ||
        'PROBATN ';
        UTL_FILE.PUT_LINE (out_file, line_buffer);
        FOR main_cur_rec IN main_cur LOOP
         --Writes to file
              line_buffer := main_cur_rec.ussc_id ||
              ',' || nvl(main_cur_rec.alt_docket,' ') ||
              ',' || nvl(to_char(main_cur_rec.dep_status_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.var_status_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.disp_type_code),' ') ||
              ',' || nvl(main_cur_rec.docket,' ') ||
              ',' || nvl(to_char(main_cur_rec.oth_sent_code),' ') ||
              ',' || nvl(main_cur_rec.oth_text,' ') ||
              ',' || nvl(to_char(main_cur_rec.po_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.prim_offn_code),' ') ||
              ',' || nvl(to_char(main_cur_rec.prob_mons),' ');
              UTL_FILE.PUT_LINE (out_file, line_buffer);
         END LOOP;
         --Write SAS footer
         line_buffer := ';';
         UTL_FILE.PUT_LINE (out_file, line_buffer);
         line_buffer := 'run;';
         UTL_FILE.PUT_LINE (out_file, line_buffer);
         --Close file
         UTL_FILE.FCLOSE(out_file);
    EXCEPTION
    -- Write error messages to the screen and file
        WHEN OTHERS THEN
        DBMS_OUTPUT.PUT_LINE(SUBSTR(SQLERRM,1,50));     // this is line 106
        UTL_FILE.PUT_LINE(out_file, SUBSTR(SQLERRM,1,50));
       UTL_FILE.FCLOSE(out_file);
    END amer_main_proc;I know I am having issues regarding the path, please have a look at the ERRORS below:
    Error starting at line 1 in command:
    DECLARE
      START_SENT_DATE DATE;
      END_SENT_DATE DATE;
      SENTTYPE NUMBER;
    BEGIN
      START_SENT_DATE := '01-JAN-2001';
      END_SENT_DATE := '01-MAR-2001';
      SENTTYPE := 10;
      AMER_MAIN_PROC(
        START_SENT_DATE => START_SENT_DATE,
        END_SENT_DATE => END_SENT_DATE,
        SENTTYPE => SENTTYPE
    END;
    Error report:
    ORA-29282: invalid file ID
    ORA-06512: at "SYS.UTL_FILE", line 878
    ORA-06512: at "USSC_CASES.AMER_MAIN_PROC", line 106
    ORA-29280: invalid directory path
    ORA-06512: at line 10
    29282. 00000 -  "invalid file ID"
    *Cause:    A file ID handle was specified for which no corresponding
               open file exists.
    *Action:   Verify that the file ID handle is a value returned from a
               call to UTL_FILE.FOPEN.thanks guys.
    Edited by: Rooney on Feb 20, 2012 12:29 PM

    You'll need to create an Oracle Directory object that contains 'C:\SQL' and use that in your UTL_FILE call if you are using a 10g+ version of the database and the UTL_FILE_DIR parameter does not include your path.
    CREATE DIRECTORY my_dir AS 'C:\SQL';
    GRANT READ WRITE ON DIRECTORY my_dir TO <user>;You can then use the directory object name in the path of your UTL_FILE call.
    ORA-29280: invalid directory path Cause: A corresponding directory object does not exist.
    Action: Correct the directory object parameter, or create a corresponding directory object with the CREATE DIRECTORY command.>
    Hope this helps!

  • Utl_file error

    Hi Guys,
    I am running Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production on RHEL 5.
    I have procedure that uses utl_file package, but now the procedure fails with the error:
    ERROR at line 1:
    ORA-29283: invalid file operation
    ORA-06512: at "SYS.UTL_FILE", line 536
    ORA-29283: invalid file operation
    ORA-06512: at "my_package.my_procedure", line 804
    ORA-06512: at line 1
    My directory object is pointing to the NS shared filesystem.
    But if I try it several times it works perfect.
    What might be the problem here:
    Please help!!!!!!!!!
    Thanks in advance...

    Thanks Helios,
    I went through the document and I don't find anything that is related to my issue.
    I can write at some point then I can't at some point. This looks like the permissions changes now and then.
    Can this be the O/S related issue where the NFS can't be accessed as some point?
    Please Help !!!!!!!!

  • Create directory utl_file errors

    I thought that I would be able to answer my problem with all the help I've seen online. I don't seem to be able to.
    I have the following code (snippet) below from my procedure:
    v_file varchar2(100);
    v_direc constant varchar2(30) := 'c:\output\';
    v_testfile UTL_FILE.FILE_TYPE;
    BEGIN
    v_testfile := utl_file.fopen('C:\output', 'JohnsUIICounts.txt', 'w');
    open csr_uii;
    loop
    fetch csr_uii into csr_uii_a, csr_uii_b, csr_uii_c, csr_uii_d;
    exit when csr_uii%NOTFOUND;
    utl_file.put_line(v_testfile, csr_uii_a || ' ' || csr_uii_b || ' '|| csr_uii_c || ' '|| csr_uii_d);
    end loop;
    I logged on to SQL Developer and did:
    CREATE DIRECTORY V_DIREC AS 'C:\output\';
    GRANT WRITE ON DIRECTORY V_DIREC TO PUBLIC;
    I got the message back that the directory was created. When I go to the c:\ drive, I don't see the directory.
    Any ideas? I've gone through all sorts of iterations like changing the drive from c to e, different folder names, upper and lower case, nothing works.
    Victoria

    Thanks. Now that I understand that, I created the directory on the server. I reran the code. I'm still getting:
    ORA-29280: invalid directory path
    ORA-06512: at "SYS.UTL_FILE", line 33
    ORA-06512: at "SYS.UTL_FILE", line 436
    I notice that on the Windows Server, when I create the directory (as an admin user), I check on the properties, and it keeps staying read only. I can modify it, but the change doesn't save. I heard something about group permissions. Is it possible that the problem is because of permissions on the server? I would think that might be the real problem at this point.
    Thanks,
    Victoria
    Edited by: user3804901 on May 20, 2009 4:31 AM

  • Line size in UTL_FILE

    Hi,
    Can someone please tell me what is the max. number of characters that can be written using UTL_FILE in Oracle 8.1.7?

    Perhaps I should have been more specific; I wanted to know how many characters can PUT_LINE or PUT function take at one time to write. Well, in 8.1.7, it is only 1000 characters on UNIX platform. Though it is not mentioned anywhere so I am not sure if this is OS limitation. However I had to do a lot of trial and error before e finding this out. Hope this would help people on the forum.
    Thanks guys for your help. I know I can always count on you all.
    Here is the sample code. In this, although, I had defined a buffer of 4000, but it consistently gave me 'WRITE_ERROR' for PUT_LINE or PUT function, until I reduced the buffer size used with these functions to 1000. Alternatively now I will use PUT function recursively and add NEW_LINE character after the entire buffer is read.
    declare
    vstr varchar(4000);
    file_handle UTL_FILE.FILE_TYPE;
    begin
    select rpad('Testiing',990,'xyz') into vstr from dual;
    file_handle := UTL_FILE.FOPEN ('/usr/users/cornwas/workplace', 'a.txt', 'w');
    for i in 1..20 loop
    UTL_FILE.PUT_LINE(file_handle, vstr);
    UTL_FILE.FFLUSH(file_handle);
    end loop;
    UTL_FILE.FCLOSE(file_handle);
    EXCEPTION
    WHEN UTL_FILE.INVALID_PATH THEN
    RAISE_APPLICATION_ERROR(-20100,'Invalid Path');
    WHEN UTL_FILE.INVALID_MODE THEN
    RAISE_APPLICATION_ERROR(-20101,'Invalid Mode');
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    RAISE_APPLICATION_ERROR(-20102,'Invalid Filehandle');
    WHEN UTL_FILE.INVALID_OPERATION THEN
    RAISE_APPLICATION_ERROR(-20103,'Invalid Operation -- May signal a file locked by the OS');
    WHEN UTL_FILE.READ_ERROR THEN
    RAISE_APPLICATION_ERROR(-20104,'Read Error');
    WHEN UTL_FILE.WRITE_ERROR THEN
    RAISE_APPLICATION_ERROR(-20105,'Write Error');
    WHEN UTL_FILE.INTERNAL_ERROR THEN
    RAISE_APPLICATION_ERROR(-20106,'Internal Error');
    WHEN NO_DATA_FOUND THEN
    RAISE_APPLICATION_ERROR(-20107,'No Data Found');
    WHEN VALUE_ERROR THEN
    RAISE_APPLICATION_ERROR(-20108,'Value Error');
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR(-20109,'Unknown UTL_FILE Error');
    end;

  • Error using UTL File

    Hi,
    I am using UTL file to export data to an external file and getting an error which i am unable to reslove... Can anyone help me with this
    SQL> create or replace
    2 procedure MEXICO_NAFTA_CERTIFICATE_EXT (
    3 f_org_id varchar2,
    4 f_customer_nbr_base varchar2,
    5 f_customer_nbr_sufx varchar2,
    6 f_year VARCHAR2)
    7 is
    8 output_file utl_file.file_type;
    9 o_filename VARCHAR2(50):= 'MEXICO_NAFTA_CERTIFICATE_EXT.txt';
    10 o_DataDir CONSTANT VARCHAR2 (30) := '/d014/oradata/temp';
    11 v_CERTIFICATE_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERTIFICATE_NBR%type;
    12 v_PART171 fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART171%type;
    13 v_INACTIVE_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.INACTIVE_IND%type;
    14 v_HTS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.HTS_CDE%type;
    15 v_ORIGINATING_IND fta.SAP_CERTIFICATES_EXTRACT_VIEW.ORIGINATING_IND%type;
    16 v_ISO_COUNTRY_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.ISO_COUNTRY_CDE%type;
    17 v_BASIS_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.BASIS_CDE%type;
    18 v_PRODUCER_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.PRODUCER_CDE%type;
    19 v_CERT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.CERT_CDE%type;
    20 v_REGIONAL_VALUE_CONTENT_CDE fta.SAP_CERTIFICATES_EXTRACT_VIEW.REGIONAL_VALUE_CONTENT_CDE%type;
    21 v_PART_NBR fta.SAP_CERTIFICATES_EXTRACT_VIEW.PART_NBR%type;
    22 v_EFFECTIVE_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_DATE%type;
    23 v_EFFECTIVE_FROM_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_FROM_DATE%type;
    24 v_EFFECTIVE_TO_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.EFFECTIVE_TO_DATE%type;
    25 v_TRANSACTION_DATE fta.SAP_CERTIFICATES_EXTRACT_VIEW.TRANSACTION_DATE%type;
    26
    27
    28 CURSOR Cert_ext IS select certificate_nbr ,
    29 part171,
    30 inactive_ind,
    31 hts_cde,
    32 originating_ind,
    33 iso_country_cde,
    34 basis_cde,
    35 producer_cde,
    36 cert_cde,
    37 regional_value_content_cde,
    38 part_nbr,
    39 effective_date,
    40 effective_from_date,
    41 effective_to_date,
    42 transaction_date
    43 from fta.SAP_CERTIFICATES_EXTRACT_VIEW
    44 where org_id= f_org_id AND
    45 customer_nbr_base= f_customer_nbr_base AND
    46 customer_nbr_sufx = f_customer_nbr_sufx AND
    47 to_char(effective_from_date, 'yy') = f_year AND
    48 to_char(effective_to_date, 'yy') = f_year;
    49
    50 begin
    51
    52 output_File := UTL_FILE.FOPEN (o_DataDir, o_FileName, 'w');
    53
    54 OPEN Cert_ext;
    55 loop
    56
    57 fetch Cert_ext into v_CERTIFICATE_NBR ,
    58 v_PART171 ,
    59 v_INACTIVE_IND,
    60 v_HTS_CDE ,
    61 v_ORIGINATING_IND ,
    62 v_ISO_COUNTRY_CDE ,
    63 v_BASIS_CDE ,
    64 v_PRODUCER_CDE ,
    65 v_CERT_CDE ,
    66 v_REGIONAL_VALUE_CONTENT_CDE ,
    67 v_PART_NBR,
    68 v_effective_date,
    69 v_effective_from_date,
    70 v_effective_to_date,
    71 v_transaction_date ;
    72
    73 UTL_FILE.PUT_LINE (output_File, v_CERTIFICATE_NBR || ' '||
    74 v_PART171 || ' '||
    75 v_INACTIVE_IND || ' '||
    76 v_HTS_CDE || ' '||
    77 v_ORIGINATING_IND || ' '||
    78 v_ISO_COUNTRY_CDE || ' '||
    79 v_BASIS_CDE || ' '||
    80 v_PRODUCER_CDE || ' '||
    81 v_CERT_CDE || ' '||
    82 v_REGIONAL_VALUE_CONTENT_CDE || ' '||
    83 v_PART_NBR || ' '||
    84 to_char(v_EFFECTIVE_DATE, 'mm-dd-yy') || ' '||
    85 to_char(v_EFFECTIVE_FROM_DATE, 'mm-dd-yy') || ' '||
    86 to_char(v_EFFECTIVE_TO_DATE, 'mm-dd-yy') || ' '||
    87 to_char(v_TRANSACTION_DATE, 'mm-dd-yy'));
    88
    89 UTL_FILE.FCLOSE (output_File);
    90 DBMS_OUTPUT.PUT_LINE ('Data Extracted');
    91 end loop;
    92 close Cert_ext;
    93 END MEXICO_NAFTA_CERTIFICATE_EXT;
    94 /
    Procedure created.
    SQL> declare
    2 begin
    3 MEXICO_NAFTA_CERTIFICATE_EXT('0048', '00254101', '11', '03');
    4 end;
    5 /
    Data Extracted
    declare
    ERROR at line 1:
    ORA-29282: invalid file ID
    ORA-06512: at "SYS.UTL_FILE", line 774
    ORA-06512: at "FTA_SOURCE.MEXICO_NAFTA_CERTIFICATE_EXT", line 72
    ORA-06512: at line 3

    what is the datatype of your column org_id for the table fta.SAP_CERTIFICATES_EXTRACT_VIEW? also try to put this exceptions to see what might be the exact cause of the error.
      EXCEPTION
        WHEN utl_file.invalid_mode THEN
          RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
        WHEN utl_file.invalid_path THEN
          RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
        WHEN utl_file.invalid_filehandle THEN
          RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
        WHEN utl_file.invalid_operation THEN
          RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
        WHEN utl_file.read_error THEN
          RAISE_APPLICATION_ERROR (-20055, 'Read Error');
        WHEN utl_file.internal_error THEN
          RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
        WHEN utl_file.charsetmismatch THEN
          RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR But Later I/O Inconsistent');
        WHEN utl_file.file_open THEN
          RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
        WHEN utl_file.invalid_maxlinesize THEN
          RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
        WHEN utl_file.invalid_filename THEN
          RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
        WHEN utl_file.access_denied THEN
          RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
        WHEN utl_file.invalid_offset THEN
          RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
        WHEN others THEN
          RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');

  • UTL_FILE don't work  ?

    Hi everybody;
    I have an issue with UTL_FILE.
    I have defined ORACLE directories with SYSTEM :
    select * from all_directories;
    OWNER                          DIRECTORY_NAME
    DIRECTORY_PATH
    SYS                            TEST
    /home/support/I gave the grants to the user A:
    grant all on directory TEST to A;And try to write in a file :
    declare
      2  file_handle UTL_FILE.FILE_TYPE;
      3  begin
      4  file_handle := UTL_FILE.FOPEN('TEST','test.txt','w');
      5    6  utl_file.put_line(file_handle,'Heure de début : ' || TO_CHAR(SYSDATE,'HH:MI:SS'));
      7  EXCEPTION
      8  WHEN utl_file.invalid_mode THEN
      9  RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
    10  WHEN utl_file.invalid_path THEN
    11  RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
    12  WHEN utl_file.invalid_filehandle THEN
    13  RAISE_APPLICATION_ERROR (-20053, 'Invalid Fileh  2    3    4    5  andle');
    14  WHEN utl_file.invalid_operation THEN
    15  RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
    16  WHEN utl_file.read_error THEN
    17  RAISE_APPLICATION_ERROR (-20055, 'Read Error');
    18  WHEN utl_file.internal_error THEN
    19  RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
    20  WHEN utl_file.charsetmismatch THEN
    21  RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR But Later I/O Inconsistent');
    22  WHEN utl_file.file_open THEN
    23  RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
    24  wHEN utl_file.invalid_maxlinesize THEN
    25  RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
    26  WHEN utl_file.invalid_filename THEN
    27  RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
    WHEN utl_file.access_denied THEN
    28   29  RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
    30  WHEN utl_file.invalid_offset THEN
    31  RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
    32  WHEN others THEN
    33  RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    34  end;
    35  /
    PL/SQL procedure successfully completed.But the file did'nt get the new lines !
    !ls -ltr /home/support/test.txt
    -rwxrwxrwx   1 bdidv    dba            0 Feb 16 13:46 /home/support/test.txtWhat's the matter ?!
    Please help me, regards

    You're not closing the file nor using the FFLUSH procedure...
    add
    utl_file.fclose(file_handle );after line 6..
    Just to be more clear, the utl_file.put_line procedure doesn't write in the file but in a buffer.
    The buffer is copied to the file when you close the file or calling the FFLUSH procedure. So you're not writing the file at all...
    Max
    http://oracleitalia.wordpress.com
    Edited by: Massimo Ruocchio on Feb 16, 2010 2:08 PM
    Added last comment

  • Need Help: UTL_FILE Reading and Writing to Text File

    Hello I am using version 11gR2 using the UTL_FILE function to read from a text file then write the lines where it begins with word 'foo' and end my writing to the text file where the line with the word 'ZEN' is found. Now, I have several lines that begin with 'foo' and 'ZEN' Which make for one full paragraph, and in this paragraph there's a line that begins with 'DE4.2'. Therefore,
    I need to write all paragraphs that include the line 'DE4.2' in their beginning and ending lines 'foo' and 'ZEN'
    FOR EXAMPLE:
    FOO/234E53LLID
    THIS IS MY SECOND LINE
    THIS IS MY THIRD LINE
    DE4.2 THIS IS MY FOURTH LINE
    THIS IS MY FIFTH LINE
    ZEN/DING3434343
    FOO/234E53LLID
    THIS IS MY SECOND LINE
    THIS IS MY THIRD LINE
    THIS IS MY FIFTH LINE
    ZEN/DING3434343
    I am only interested in writing the first paragraph tha includes line DE4.2 in one of ther lines Not the Second paragraph that does not include the 'DE4.2'
    Here's my code thus far:
    CREATE OR REPLACE PROCEDURE my_app2 IS
    infile utl_file.file_type;
    outfile utl_file.file_type;
    buffer VARCHAR2(30000);
    b_paragraph_started BOOLEAN := FALSE; -- flag to indicate that required paragraph is started
    BEGIN
    -- open a file to read
    infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
    -- open a file to write
    outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
    -- check file is opened
    IF utl_file.is_open(infile)
    THEN
    -- loop lines in the file
    LOOP
    BEGIN
    utl_file.get_line(infile, buffer);
         --BEGINPOINT APPLICATION
    IF buffer LIKE 'foo%' THEN
              b_paragraph_started := TRUE;          
         END IF;
         --LOOK FOR GRADS APPS
              IF b_paragraph_started AND buffer LIKE '%DE4%' THEN
              utl_file.put_line(outfile,buffer, FALSE);
    END IF;
         --ENDPOINT APPLICATION      
              IF buffer LIKE 'ZEN%' THEN
         b_paragraph_started := FALSE;
              END IF;
    utl_file.fflush(outfile);
    EXCEPTION
    WHEN no_data_found THEN
    EXIT;
    END;
    END LOOP;
    END IF;
    utl_file.fclose(infile);
    utl_file.fclose(outfile);
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2;
    When I run this code I only get one line: DE4.2 I AM MISSING THE ENTIRE PARAGRAPH
    PLEASE ADVISE...

    Hi,
    Look at where you're calling utl_file.put_line. The only time you're writing anything is immediately after you find the the key word 'DE4', and then you're writing just that line.
    You need to store the entire paragraph, and when you reach the end of the paragraph, write the whole thing only if you found the key word, like this:
    CREATE OR REPLACE PROCEDURE my_app2 IS
        TYPE  line_collection  
        IS       TABLE OF VARCHAR2 (30000)
               INDEX BY BINARY_INTEGER;
        infile               utl_file.file_type;
        outfile                      utl_file.file_type;
        input_paragraph          line_collection;
        input_paragraph_cnt          PLS_INTEGER     := 0;          -- Number of lines stored in input_paragraph
        b_paragraph_started      BOOLEAN      := FALSE;     -- flag to indicate that required paragraph is started
        found_key_word          BOOLEAN          := FALSE;     -- Does this paragraph contain the magic word?
    BEGIN
        -- open a file to read
        infile := utl_file.fopen('TEST_DIR', 'mytst.txt', 'r');
        -- open a file to write
        outfile := utl_file.fopen('TEST_DIR', 'out.txt', 'w');
        -- check file is opened
        IF utl_file.is_open(infile)
        THEN
         -- loop lines in the file
         LOOP
             BEGIN
              input_paragraph_cnt := input_paragraph_cnt + 1;
                 utl_file.get_line (infile, input_paragraph (input_paragraph_cnt));
              --BEGINPOINT APPLICATION
              IF LOWER (input_paragraph (input_paragraph_cnt)) LIKE 'foo%' THEN
                  b_paragraph_started := TRUE;
              END IF;
              --LOOK FOR GRADS APPS
              IF b_paragraph_started
              THEN
                  IF  input_paragraph (input_paragraph_cnt) LIKE '%DE4%'
                  THEN
                   found_key_word := TRUE;
                  END IF;
                  --ENDPOINT APPLICATION
                  IF input_paragraph (input_paragraph_cnt) LIKE 'ZEN%' THEN
                      b_paragraph_started := FALSE;
                   IF  found_key_word
                   THEN
                       FOR j IN 1 .. input_paragraph_cnt
                       LOOP
                           utl_file.put_line (outfile, input_paragraph (j), FALSE);
                       END LOOP;
                   END IF;
                   found_key_word := FALSE;
                   input_paragraph_cnt := 0;
                  END IF;
              ELSE     -- paragraph is not started
                  input_paragraph_cnt := 0;
              END IF;
              EXCEPTION
                  WHEN no_data_found THEN
                   EXIT;
              END;
          END LOOP;
        END IF;
        utl_file.fclose (infile);
        utl_file.fclose (outfile);
    --EXCEPTION
    --    WHEN OTHERS THEN
    --        raise_application_error(-20099, 'Unknown UTL_FILE Error');
    END my_app2;
    SHOW ERRORSIf you don't have an EXCEPTION section, the default error handling will print an error message, spcifying exactly what the error was, and which line of your code caused the error. By using your own EXCEPTION section, you're hiding all that information. I admit, the error messages aren't always as informative as we'd like, but they're never less informative than "Unknown UTL_FILE Error'. Don't use your own EXCEPTION handling unless you can improve on the default.
    Remember that anything inside quotes is case-sensitive. If your file contains upper-case 'FOO', then it won't be "LIKE 'foo%' ".
    Edited by: Frank Kulash on Dec 7, 2011 1:35 PM
    You may have noticed that this site normally doesn't display multiple spaces in a row.
    Whenever you post formatted text (such as your code) on this site, type these 6 characters:
    \{code}
    (small letters only, inside curly brackets) before and after each section of formatted text, to preserve spacing.

  • Help UTL_FIle

    Hi,
              In utl file i have a reqruriment as " if file doesnt exit or unable to open the file for write  "
    For that i have coded below for checking a file is exit or not,
    how to do the coding for " a file is been unable to open the file for write". 
    please advice.
    BEGIN
    var_out_file_name_1 BFILE := BFILENAME('path', 'x.rpt');
    IF DBMS_LOB.FILEEXISTS (var_out_file_name_1)    = 1 THEN
            DBMS_OUTPUT.PUT_LINE ('File exists.');
         ELSIF DBMS_LOB.FILEEXISTS (var_out_file_name_1) = 0 THEN
            DBMS_OUTPUT.PUT_LINE ('File does not exist');
         ELSE
           DBMS_OUTPUT.PUT_LINE ('Unable to test existence for x.rpt');
         END IF;
    ENDoracle version : 8i
    thanks in advance :-) Edited by: USER_X on Sep 10, 2008 3:26 PM

    maybe exceptions might help if you will use the <a href="http://www.psoug.org/reference/utl_file.html" target="_blank">UTL_FILE</a> function.
      BEGIN
      EXCEPTION
        WHEN utl_file.invalid_mode THEN
          dbms_output.put_line ('Invalid Mode Parameter');
        WHEN utl_file.invalid_path THEN
          dbms_output.put_line ('Invalid File Location');
        WHEN utl_file.invalid_filehandle THEN
          dbms_output.put_line ('Invalid Filehandle');
        WHEN utl_file.invalid_operation THEN
          dbms_output.put_line ('Invalid Operation');
        WHEN utl_file.read_error THEN
          dbms_output.put_line ('Read Error');
        WHEN utl_file.internal_error THEN
          dbms_output.put_line ('Internal Error');
        WHEN utl_file.charsetmismatch THEN
          dbms_output.put_line ('Opened With FOPEN_NCHAR But Later I/O Inconsistent');
        WHEN utl_file.file_open THEN
          dbms_output.put_line ('File Already Opened');
        WHEN utl_file.invalid_maxlinesize THEN
          dbms_output.put_line('Line Size Exceeds 32K');
        WHEN utl_file.invalid_filename THEN
          dbms_output.put_line ('Invalid File Name');
        WHEN utl_file.access_denied THEN
          dbms_output.put_line ('File Access Denied By');
        WHEN utl_file.invalid_offset THEN
          dbms_output.put_line ('FSEEK Param Less Than 0');
        WHEN others THEN
          dbms_output.put_line ('Unknown UTL_FILE Error');
      END;

  • Problem in using CLOB Data from a Data and exporting into File

    Hi,
    UTL_FILE Error Occured while using UTL_FILE with CLOB Data.
    UTL_FILE: A write error occurred.
    The Below Code is for reference:
    DECLARE
    C_AMOUNT CONSTANT BINARY_INTEGER := 32767;
    L_BUFFER VARCHAR2(32767);
    L_CHR10 PLS_INTEGER;
    L_CLOBLEN PLS_INTEGER;
    L_FHANDLER UTL_FILE.FILE_TYPE;
    L_POS PLS_INTEGER := 1;
    BEGIN
         FILE_NAME:=UTL_FILE.FOPEN('EXPORT_DIR','EXPORT_FILE'||'.sql','W');
         FOR C1_EXP IN (SELECT INSERT_STRING FROM EXPORTED_DUMP) LOOP
         L_CLOBLEN := DBMS_LOB.GETLENGTH(C1_EXP.INSERT_STRING);
         DBMS_OUTPUT.PUT_LINE('THE CLOB LEN '||L_CLOBLEN);
         DBMS_OUTPUT.PUT_LINE('THE POSITION '||L_POS);
         WHILE L_POS < L_CLOBLEN LOOP
    L_BUFFER := DBMS_LOB.SUBSTR(C1_EXP.INSERT_STRING, C_AMOUNT, L_POS);
         DBMS_OUTPUT.PUT_LINE('THE BUFFER IS '||L_BUFFER);
    EXIT WHEN L_BUFFER IS NULL;
    UTL_FILE.PUT_LINE(FILE_NAME, C1_EXP.INSERT_STRING);
    L_POS := L_POS + LEAST(LENGTH(L_BUFFER)+1,c_amount);
    END LOOP;
         END LOOP;
    UTL_FILE.FCLOSE(FILE_NAME);
    EXCEPTION
    WHEN UTL_FILE.INTERNAL_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An internal error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_FILEHANDLE THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: The file handle was invalid.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_MODE THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid open mode was given.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_OPERATION THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid operation was attempted.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.INVALID_PATH THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: An invalid path was give for the file.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.READ_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A read error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN UTL_FILE.WRITE_ERROR THEN
    DBMS_OUTPUT.PUT_LINE ('UTL_FILE: A write error occurred.');
    UTL_FILE.FCLOSE_ALL;
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE ('Some other error occurred.');
    UTL_FILE.FCLOSE_ALL;
    END;

    Hi user598986!
    OK, I understood that there is a problem with your code. But please would you be so kindly to tell us here what error exactly happens (the errormessage). Mabay after that someone will be able to help you.
    yours sincerely
    Florian W.
    P.S. If you enclose your code into tags it will be shown formated.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Solution to execute sql from mysql application logs

    We have some custom mysql application, which generate logs that are stored on common location on open linux box which has below format
    $ cat minor20100809.log
    20100809001^Aselect count(prod_id) from product_logs;
    20100809002^Aselect count(order_id) from order_logs;
    ID and the SQL statement with control A as seperater and daily 1000 logs files are generated
    Now we have one oracle DWH, where we import all the mysql data and we need to test these counts on daily basis.
    Could you please suggest a solution in oracle for this?
    at high level we need to follow below steps
    a) Import these logs in a table --> which is better way sqlldr, impdp, or plsql read file ?
    b) execute these sql statement one by one
    c) store the counts in log table on daily basis

    Hi,
    It is a simple two step process.
    Step 1. Convert your log files statements to meaningful oracle statements. like removing prefixes 20100809001^A from each line.
    This can be done in two ways.
    (a). Using OS editors OR
    (b). Following PL/SQL code...
    -- Connect as sysdba
    create or replace directory dir_tmp as '/tmp';                        -- If oracle server is on Unix
    create or replace directory dir_tmp as 'C:\your_folder';            -- If oracle server is on Windows
    -- Grant permission to your_schema
    grant read, write on directory dir_tmp to your_schema;    Removing prefixes using:
           SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
             INTO vStmt
             FROM DUAL;
    CREATE OR REPLACE PROCEDURE convert_to_sql_stmts
    ( input_file     in varchar2,
      output_file   in varchar2
    AUTHID CURRENT_USER
    IS
        InFile   utl_file.file_type;
        OutFile  utl_file.file_type;
        vNewLine VARCHAR2(4000);
        vStmt    VARCHAR2(4000);
        i        PLS_INTEGER;
        j        PLS_INTEGER := 0;
        SeekFlag BOOLEAN := TRUE;
    BEGIN
      -- open a file to read
      InFile := utl_file.fopen(dir_tmp, input_file,'r');
      -- open a file to write
      OutFile := utl_file.fopen(dir_tmp, output_file, 'w');
      -- if the file to read was successfully opened
      IF utl_file.is_open(InFile) THEN
        -- loop through each line in the file
        LOOP
          BEGIN
            utl_file.get_line(InFile, vNewLine);
            i := utl_file.fgetpos(InFile);
            dbms_output.put_line(TO_CHAR(i));
            SELECT regexp_replace (vNewLine, '([[:alnum:]]{1,})\^A', '\2')
              INTO vStmt
              FROM DUAL;
            utl_file.put_line(OutFile, vStmt, FALSE);
            utl_file.fflush(OutFile);
            IF SeekFlag = TRUE THEN
              utl_file.fseek(InFile, NULL, -30);
              SeekFlag := FALSE;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        COMMIT;
      END IF;
      utl_file.fclose(InFile);
      utl_file.fclose(OutFile);
    EXCEPTION
      WHEN OTHERS THEN
        RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    END convert_to_sql_stmts;
    Step 2. Directly executing above output log file
    Use spool to generate the count....
        set termout off
        set feedback off
        set trimspool on
        set pagesize 0
        set timing OFF
        spool   count.log
        @new_file.log
        spool off;Hope this helps...

  • Import data

    Hi,
    I have one table
    Create Table emp
    (emp_id number(10),
    Emp_name varchar2(10),
    Sal number(10),
    Appr_sal number(10),
    Tot_sal number(10));
    and Data which is in excel file
    <pre>
    EMP_ID     EMP_NAME     Sal
    1     A     20000
    2     B     30000
    3     C     35000
    </Pre>
    Now i want to import them in oracle from excel.
    And for last 2 columns
    1) Appr_sal : it should have 10% of sal.
    2) Tot_sal : it should have sum of Sal and appr_sal.
    So it should import first 3 column from csv or excel file and insert them into oracle table emp and calculate value for last 2 columns while importing and stored them in there columns.

    There is one thing i found on internet is to open a file and read the data.But how to use that in my case and to read the file and update in old records.
    create table test (
    fld1 VARCHAR2(20),
    fld2 VARCHAR2(20));
    CREATE OR REPLACE PROCEDURE read_demo(file_name VARCHAR2) IS
    vSFile utl_file.file_type;
    vNewLine VARCHAR2(200);
    BEGIN
    vSFile := utl_file.fopen('ORALOAD', file_name,'r');
    IF utl_file.is_open(vSFile) THEN
    LOOP
    BEGIN
    utl_file.get_line(vSFile, vNewLine);
    IF vNewLine IS NULL THEN
    EXIT;
    END IF;
    INSERT INTO test
    (fld1, fld2)
    VALUES
    (vNewLine, file_name);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    COMMIT;
    END IF;
    utl_file.fclose(vSFile);
    utl_file.frename('ORALOAD', 'test.txt', 'ORALOAD', 'x.txt', TRUE);
    EXCEPTION
    WHEN utl_file.invalid_mode THEN
    RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
    WHEN utl_file.invalid_path THEN
    RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
    WHEN utl_file.invalid_filehandle THEN
    RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
    WHEN utl_file.invalid_operation THEN
    RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
    WHEN utl_file.read_error THEN
    RAISE_APPLICATION_ERROR (-20055, 'Read Error');
    WHEN utl_file.internal_error THEN
    RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
    WHEN utl_file.charsetmismatch THEN
    RAISE_APPLICATION_ERROR (-20058, 'Opened With FOPEN_NCHAR
    But Later I/O Inconsistent');
    WHEN utl_file.file_open THEN
    RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
    WHEN utl_file.invalid_maxlinesize THEN
    RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
    WHEN utl_file.invalid_filename THEN
    RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
    WHEN utl_file.access_denied THEN
    RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
    WHEN utl_file.invalid_offset THEN
    RAISE_APPLICATION_ERROR (-20063,'FSEEK Param Less Than 0');
    WHEN others THEN
    RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    END read_demo;
    /

  • Want to upload file in server as a physical file from my d2k program

    Friends,
    i have created a procedure which render a web page, in that web page i added a button called "browse", where user can select any file from local pc.
    and there is another button called "upload". then i want to save this file to Application server or data base server as a phisical file under directory called
    "c:\myfiles"
    please advice,
    thanks

    i found the solution, see below. I know you people can only direct to any documents in oracle related site. you don't have any working experience.
    i am posting this for others , it might usefull to others.
    create DIRECTORY FLOYID_DIR as '\home\Floyid\apps';
    select directory_name, directory_path from all_directories
    --// I don’t this alter command necessary.
    --ALTER SYSTEM SET utl_file_dir='E:\TEST_DIR' SCOPE=SPFILE;
    Grant read, write on directory Floyid_dir to <you shema name/db user>
    Sample code below.
    Declare
    InFile utl_file.file_type;
    OutFile utl_file.file_type;
    vNewLine VARCHAR2(4000);
    i PLS_INTEGER;
    j PLS_INTEGER := 0;
    SeekFlag BOOLEAN := TRUE;
    BEGIN
    InFile := utl_file.fopen('FLOYID_DIR', 'in.txt','r');
    OutFile := utl_file.fopen('FLOYID_DIR', 'out.txt', 'w');
    IF utl_file.is_open(InFile) THEN
    LOOP
    BEGIN
    utl_file.get_line(InFile, vNewLine);
    i := utl_file.fgetpos(InFile);
    dbms_output.put_line(TO_CHAR(i));
    utl_file.put_line(OutFile, vNewLine, FALSE);
    utl_file.fflush(OutFile);
    IF SeekFlag = TRUE THEN
    utl_file.fseek(InFile, NULL, -30);
    SeekFlag := FALSE;
    END IF;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    EXIT;
    END;
    END LOOP;
    COMMIT;
    END IF;
    utl_file.fclose(InFile);
    utl_file.fclose(OutFile);
    EXCEPTION
    WHEN others THEN
    RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    END

Maybe you are looking for