Utl_file.fseek

Hi all,
I want to know about the procedure fseek in utl_file
I know that we can use this procedure to move back or forward in a file without closing and opening it
but what i cant get is how this works
say this is the example
declare
name varchar2(30);
f1 utl_file.file_type;
pos number;
begin
   f1 := utl_file.fopen('VIR','SEARCH.TXT','R');
   utl_file.fseek(f1,10);
       pos := utl_file.fgetpos(f1);
dbms_output.put_line ('SUCCESS Seek to abs offset 10, currect position is '||to_char(pos));          
   utl_file.fseek(f1,NULL,5);
       pos := utl_file.fgetpos(f1);
dbms_output.put_line ('SUCCESS Seek to relative offset 5, currect position is'||to_char(pos));
   utl_file.fseek(f1,10,5);
       pos := utl_file.fgetpos(f1);
dbms_output.put_line ('SUCCESS Seek to absolute 10 relative offset 5, currect position is'||to_char(pos));
   utl_file.fseek(f1,NULL,-5);
       pos := utl_file.fgetpos(f1);
dbms_output.put_line ('SUCCESS Seek to rel offset -5, currect position is '||to_char(pos));
   utl_file.fclose(f1);
end;
o/p is
SQL> /
SUCCESS Seek to abs offset 10, currect position is 10
SUCCESS Seek to relative offset 5, currect position is15
SUCCESS Seek to absolute 10 relative offset 5, currect position is10
SUCCESS Seek to rel offset -5, currect position is 5
PL/SQL procedure successfully completed.What i dont understand is when i am using both absolute and relative offset i.e abs = 10 and rel = 5
then why its current position is 10 when i thought it would be 15?
please correct me if i am wrong.
or does it not consider the relative offset when the absolute is given
What i am thinking is when absolute and relative offset in fseek is present then the position should be
absolute + relative.
when absolute is null and relative is present the position would be
current position +/- relative offset
and if relative offset is null and absolute is present the current position is
absolute offset
thanks

Although it is not explicitly stated in the documentation, I beleieve that fseek is an either or proposition. That is, you supply either absolute or relative position. If you supply both, then only the first parameter (absolute) is evaluated.
My guess would be that somewhere in the internals, the utl_file.fseek procedure calls the c function fseek which is defined as:
int fseek(FILE *stream, long offset, int whence);where whence is a constant defined in stdio.h as:
SEEK_SET  Set position equal to offset bytes.
SEEK_CUR  Set  position  to  current   location   plus
SEEK_END  Set position to EOF plus offset.So, in psuedo code
IF absolute_offset is not null then
   call c.fseek (filepointer, absolute_offset, SEEK_SET);
elsif relative_offset is not null then
      call c.fseek (filepointer, relative_offset, SEEK_CUR);
else
   do nothing
end if;John

Similar Messages

  • How to write from beginning of text file?

    Hello all,
    All we have to do is to modify just first 2 lines of a 200,000 line files. I can do UTL_FILE.FCOPY to copy from line 3 to end of file and create a new file (FILE1). Now open a new file (say FILE2) and write the modified version of first two lines and then read the file (FILE1) which has rest of the original contents to write to this FILE2. But this process is taking for ever (around 30 minutes).
    It would have been easy if I can open FILE1 and just write the first 2 lines. But when I open in append mode I can only write only at the bottom of the file. I tried UTL_FILE.FSEEK but it is not working when the file is opened in Append mode.
    Anyone with a solution / suggestion / workaround is greatly appreciated.
    Thanks in advance,
    Manohar

    Francois,
    I know the command in Unix to concatenate. There are other easy ways if I can make HOST command work on the application server instead of my local machine. To my surprise both HOST and TEXT_IO are able to work only on my local machine.
    I was under the same impression as you are and trying to execute HOST providing Unix commands. Nothing working ... finally when I tried
    HOST('echo abc > c:\sample.txt');
    it crreated sample.txt on my local machine c:\
    Let me know if I am missing something.
    Thanks
    Manohar

  • 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...

  • 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

  • How to save files on the server?

    I want to save a log on the server, how can I do this using Oracle?
    In SQL Server I used the "bcp" command.
    Thanks.

    as forbrich suggested you can use the UTL_FILE built-in package. here is an example code to read and write to a file.
    CREATE OR REPLACE PROCEDURE Read_Write_File (pvInFile Varchar2,
                                                 pOutFile Varchar2) IS
    vInFile   utl_file.file_type;
    vOutFile  utl_file.file_type;
    vNewLine  VARCHAR2(4000);
    x         PLS_INTEGER;
    vFlag  BOOLEAN := TRUE;
    BEGIN
      -- assuming Your_Directory is $HOME/myTxtFiles in a Unix Platform
      -- to check if definition is existing Select Directory_Name, Directory_Path From All_Directories;
      vInFile := utl_file.fopen('Your_Directory',pInFile,'r');
      vOutFile := utl_file.fopen('Your_Directory',pOutFile, 'w');
      IF utl_file.is_open(vInFile) THEN
        LOOP
          BEGIN
            utl_file.get_line(vInFile, vNewLine);
            x := utl_file.fgetpos(vInFile);
            dbms_output.put_line(TO_CHAR(x));
            utl_file.put_line(vOutFile, vNewLine, FALSE);
            utl_file.fflush(vOutFile);
            IF vFlag = TRUE THEN
              utl_file.fseek(vInFile, NULL, -30);
              vFlag := FALSE;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        COMMIT;
      END IF;
      utl_file.fclose(vInFile);
      utl_file.fclose(vOutFile);
    EXCEPTION
      WHEN others THEN
        RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
    END;
    /

  • Table to file

    Hi everybody...
    I want to extract data from database table and insert into a file. What is the best method performance wise. I am writing this in Proc.
    Thanks in advance....

    You can make use of the utility UTL_FILE_DIR.
    Demo:-Read/Write
    CREATE OR REPLACE PROCEDURE rw_demo IS
    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('CTEMP', 'in.txt','r');
    OutFile := utl_file.fopen('CTEMP', '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 rw_demo;
    /

  • How to create procedure to mail ORA-error

    hi all,
    anyone please tell me how to create a procedure to mail the ORA-error when ORA- error comes in alert.log

    Ok, I can't really do this for you. It's not hard, just a lot of back-and-forth testing needs to be done. To do it solely in PL/SQL you need to monitor the alter_<sid>.log file for changes and filter the changed records for ORA- errors.. So, first step is to create, or get the dba to create a directory for that bdump directory. This will allow you to open the file for reading in PL/SQL
    This is on an XE 10g database as SYSTEM user, with poly being the database user that is monitoring the file.
    select value from v$parameter where name like 'background_dump_dest';
    /usr/lib/oracle/xe/app/oracle/admin/XE/bdump
    SQL> CREATE DIRECTORY BDUMP_DIR AS '/usr/lib/oracle/xe/app/oracle/admin/XE/bdump';
    create directory succeeded.
    SQL> grant read on directory alert_dir to poly;
    grant read succeeded.After this, you need to read the file and search for ORA- messages. You use the UTL_FILE package to do this. The following subprograms in UTL_FILE will be useful to you.
    Function: UTL_FILE.FOPEN You use this to open the file in readonly mode. Please look at the UTL_FILE documentation examples.
    Procedure: UTL_FILE.GET_LINE You use this to read lines into PL/SQL
    Procedure: UTL_FILE.GETATTR You use this to get the filelength. If the filelength is different from your previous call, you know some writes occurred.
    Procedure UTL_FILE.FSEEK You use this to position the reading stream to the first byte of new data read. You've detected the file has grown in size and do something like utl_file.fseek(file_desc,last_file_length+1)
    Procedure UTL_FILE.FCLOSE Close file when done.
    Pseudologic:
    This logic assumes you have a table which stores the filelength from the last time you executed the procedure. This allows you to only process records that have not already been processed.
    1. Read last file length from persistent storage such as a table. Default to zero if no value.
    2. Get filelength using UTL_FILE.GETATTR
    3. Compare filelength. If equal to prior value, exit. If greater, than more lines added. If less, then dba must have rolled the log, reset prior filelength to zero to process entire new file.
    4. Use UTL_FILE.FSEEK to position reader to one byte past last file length. This is why we default it to zero, 0+1=1.
    5. Open file using UTL_FILE.FOPEN
    6. Loop while data is avaliable, read each line, use instr or whatever to detect ORA- messages, call SMTP mailer as needed. You may want to log each email into a log table.
    7. After loop, set persisted last file length (update a table and commit maybe) to value returned from UTL_FILE.FGETPOS.
    8. Sleep for some interval of time. Start back at step 1.
    You should consider using DBMS_SCHEDULER to set up this job.
    There are lots of other ways of doing this. Remember that it's possible for your database to crash and your procedure might not be able to send an email. If someone edits the alter file and adds lines anywhere other than at the end, your program may resend some messages.
    Edited by: david.sweet on Feb 19, 2011 10:16 AM: changed the word function to procedure for most of them

  • 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

  • Sys.utl_file has many errors. How to re-create

    hi all,
    I tried using the utility utl_file in my procedures and it showed out
    sys.utl_file has many errors
    and when i went through like
    $ sqlplus /nolog
    SQL*Plus: Release 9.2.0.8.0 - Production on Tue Mar 4 12:50:08 2008
    Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
    SQL> connect / as sysdba;
    Connected.
    SQL> select name from v$database;
    NAME
    TEST
    SQL> alter package sys.utl_file compile body;
    Warning: Package Body altered with compilation errors.
    SQL> show errors;
    Errors for PACKAGE BODY SYS.UTL_FILE:
    LINE/COL ERROR
    100/12 PLS-00323: subprogram or cursor 'FOPEN_NCHAR' is declared in a
    package specification and must be defined in the package body
    160/13 PLS-00323: subprogram or cursor 'GET_LINE' is declared in a
    package specification and must be defined in the package body
    181/13 PLS-00323: subprogram or cursor 'GET_LINE_NCHAR' is declared in a
    package specification and must be defined in the package body
    213/13 PLS-00323: subprogram or cursor 'PUT_NCHAR' is declared in a
    package specification and must be defined in the package body
    LINE/COL ERROR
    245/13 PLS-00323: subprogram or cursor 'PUT_LINE' is declared in a
    package specification and must be defined in the package body
    261/13 PLS-00323: subprogram or cursor 'PUT_LINE_NCHAR' is declared in a
    package specification and must be defined in the package body
    311/13 PLS-00323: subprogram or cursor 'PUTF_NCHAR' is declared in a
    package specification and must be defined in the package body
    336/7 PLS-00307: too many declarations of 'PUT_LINE' match this call
    LINE/COL ERROR
    336/7 PL/SQL: Statement ignored
    344/13 PLS-00323: subprogram or cursor 'PUT_RAW' is declared in a
    package specification and must be defined in the package body
    363/13 PLS-00323: subprogram or cursor 'GET_RAW' is declared in a
    package specification and must be defined in the package body
    386/13 PLS-00323: subprogram or cursor 'FSEEK' is declared in a package
    specification and must be defined in the package body
    403/13 PLS-00323: subprogram or cursor 'FREMOVE' is declared in a
    LINE/COL ERROR
    package specification and must be defined in the package body
    423/13 PLS-00323: subprogram or cursor 'FCOPY' is declared in a package
    specification and must be defined in the package body
    447/13 PLS-00323: subprogram or cursor 'FGETATTR' is declared in a
    package specification and must be defined in the package body
    463/12 PLS-00323: subprogram or cursor 'FGETPOS' is declared in a
    package specification and must be defined in the package body
    LINE/COL ERROR
    481/13 PLS-00323: subprogram or cursor 'FRENAME' is declared in a
    package specification and must be defined in the package body
    SQL>
    can anyone help me out of this issue

    What had happened to your database?
    You could try to run $ORACLE_HOME/rdbms/admin/utlfile.sql
    to recreate the package.

  • Utl_file how to start reading from a certain position?

    Hi all,
    i'm currently using utl_file to read a text file and import to db. i have managed to do it. however i would like to avoid reading the first line as it is the header. i would also like to avoid the last line as it is the footer.
    how do i use the function of get line to start reading at a certain position? i am also able to get the length but i do not know how to make it start reading from a certain position.
    the length of the first line will always be 9 and length for the last line would be 51.
    here's my code so far:
    set serveroutput on
    declare
    vSFile   utl_file.file_type;
    vNewLine VARCHAR2(4000);
    file_name VARCHAR2(200) := 'read.txt';
    v_exist     BOOLEAN;
    v_length number;
    blocksize   NUMBER;
    temp_value varchar2 (4000);
    BEGIN
      vSFile := utl_file.fopen('MYDIR', 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;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              EXIT;
          END;
        END LOOP;
        UTL_FILE.FGETATTR('MYDIR',file_name,v_exist,v_length,blocksize);
        dbms_output.put_line(v_length);
        COMMIT;
      END IF;
      utl_file.fclose(vSFile);
    END read_demo;

    Hi,
    utl_file has an fseek procedure for moving the file pointer around in a file, either absolute or relative number of bytes.
    It's in the documentation, I'm surprised you didn't see it there when you looked before going to the hassle of asking us a question.
    Andre

  • 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;

  • Saving UTL_FILE from Oracle 9i DataBase

    Hi all!
    I have a problen saving an XML file generated from a SQL sentence in my Oracle 9i Database when the file is higer than 32K bytes.
    To save file i use UTL_FILE library and i have found that there is the problem.
    The code i use is the following:
    CREATE OR REPLACE PROCEDURE SIGADMIN.PRUEBA_CAUC0004_EXT AUTHID CURRENT_USER IS
    xml clob;
    vxml varchar2(100);
    xfile utl_file.file_type;
    doc xmldom.DOMDocument;
    BEGIN
    --Inicializamos el CLOB
    DBMS_LOB.CreateTemporary(xml,TRUE);
    --Pasar el DOM document a CLOB
    xmldom.writeToClob(doc,xml);
    xfile := utl_file.fopen('TEMP_DIR','PRUEBA_CAUC0004.xml','w');
    WHILE (pos < len) LOOP
    vxml := dbms_lob.substr(xml,100,pos);
    utl_file.put(xfile,vxml);
    pos := pos+100;
    END LOOP
    --Liberamos los recursos
    xmldom.freeDocument(doc);
    utl_file.fclose(xfile);
    ..

    thx,
    the problem is that when i need to save a file higher tanh 32K, for example 150K, i save it in "blocks" of 20K, and it saves all the data, the problem is that between the 20K blocks it adds a <CR> character, and as i am saving an XML document, that is not correct due to that <CR>.
    So, i need to know if there is a way to save that files without the <CR>,
    i am trying using FSEEK, but i am not how to use it.

  • Help needed in utl_file

    Hi,
    I have two groups in data model of my report. I am using utl_file in a formula column of report last group.it's working fine.
    but my problem is if customer has more than one invoice lines
    then all that lines not comes under only particular customer only at a time.
    For example my output is coming like this:
    Customer address: 3345 LIMITED-STUDIOS : 00033-45 PARR STREETLIVERPOOLCHESHIRE
    Invoice Lines: 0001000402106-JUL-07INV 10.47
    Customer address: 3345 LIMITED-STUDIOS : 00033-45 PARR STREETLIVERPOOLCHESHIRE
    Invoice Lines: 0001000402713-JUL-07INV 10.77
    But I am trying to get output like this:
    Customer address: 3345 LIMITED-STUDIOS : 00033-45 PARR STREETLIVERPOOLCHESHIRE
    Invoice Lines: 0001000402106-JUL-07INV 10.47
              0001000402713-JUL-07INV 10.77
    I am using fallowing code in my formula column:
    function CF_UTL_FILEFormula return Char is
    v_file_data utl_file.file_type;
    begin
    utl_file.put_line(v_file_data,:SEND_CUSTOMER_NAME:SEND_ADDRESS1:SEND_ADDRESS2:SEND_ADDRESS3:SEND_ADDRESS4:SEND_CITY:SEND_STATE:SEND_COUNTRY_DESC:SEND_POSTAL_CODE);
    utl_file.put_line(v_file_data,LN1:CF_LOCATION:C_DELIVERY_DATE:INVOICE_NUMBER:TRX_DATE:c_transaction_type:CD_TRX_AMOUNT);
    utl_file.fclose(v_file_data);
    end;
    Please help me how can I do this?

    What's the source of your Summary Column? It's not allowed to choose here the formula column in whcih you reference the summary column back. But another column should work.
    As alternativ add a formula column in the upper group with
    utl_file.put_line(v_file_data,:SEND_CUSTOMER_NAME:SEND_ADDRESS1:SEND_ADDRESS2:SEND_ADDRESS3:SEND_ADDRESS4:SEND_CITY:SEND_STATE:SEND_COUNTRY_DESC:SEND_POSTAL_CODE);
    and remove the same line out of the other formula column.

  • Problems with moving files to ora directory UTL_FILE.PUT_RAW - ORA-29285

    hi,
    i'm using apex 4.1
    i have a procedure which moves my file from apex_application_files to ORA directory.
    if i choose a text file or small word document which is 1kb, it works. but if i have pdf file (85kb) or word document (16kb) it gives me ORA-29285: file write error
    what's my problem?
    PROCEDURE put_file_to_server (p_filename IN VARCHAR2,p_cert_type IN VARCHAR2,p_cert_pk IN NUMBER)
    AS
    l_file UTL_FILE.file_type;
    l_blob_len INTEGER;
    l_pos INTEGER := 1;
    l_amount BINARY_INTEGER := 32767;
    l_buffer RAW (32767);
    v_new_filename VARCHAR2(100);
    v_bfile BFILE ;
    BEGIN
    -- delete from apex_application_files;
    --Neuen Dateinamen generieren
    v_new_filename := p_cert_type||'_'||p_cert_pk;
    v_bfile := BFILENAME (v_directory, v_new_filename);
    --Datei erstellen
    l_file := UTL_FILE.fopen(v_directory,v_new_filename,'w');
    IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
    FOR rec IN (select blob_content lblob from apex_application_files where rownum = 1)
    LOOP
    l_blob_len := DBMS_LOB.getlength(rec.lblob);
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '||l_blob_len);
    WHILE l_pos < l_blob_len LOOP
    DBMS_LOB.read (rec.lblob, l_amount, l_pos, l_buffer);
    UTL_FILE.put_raw (l_file, l_buffer, FALSE);
    l_pos := l_pos + l_amount;
    END LOOP;
    COMMIT;
    END LOOP;
    --Datei schließen
    UTL_FILE.fclose(l_file);
    else
    cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesn't exist');
    end if;
    EXCEPTION
    WHEN OTHERS
    THEN
    -- Close the file if something goes wrong.
    IF UTL_FILE.is_open (l_file) THEN
    UTL_FILE.fclose (l_file);
    END IF;
    delete from apex_application_files;
    RAISE;
    delete from apex_application_files;
    END put_file_to_server;

    Sorry but din't test this...Can you give it a try and see if this works?
    PROCEDURE put_file_to_server(
        p_filename  IN VARCHAR2,
        p_cert_type IN VARCHAR2,
        p_cert_pk   IN NUMBER)
    AS
      l_file UTL_FILE.file_type;
      l_blob_len INTEGER;
      l_pos      INTEGER      := 1;
      l_amount BINARY_INTEGER := 32767;
      l_buffer RAW (32767);
      v_new_filename VARCHAR2(100);
      v_bfile BFILE ;
      vblob BLOB;
      vstart NUMBER := 1;
      my_vr RAW(32000);
      bytelen NUMBER := 32000;
      LEN     NUMBER;
    BEGIN
      -- delete from apex_application_files;
      --Neuen Dateinamen generieren
      v_new_filename := p_cert_type||'_'||p_cert_pk;
      v_bfile        := BFILENAME (v_directory, v_new_filename);
      --Datei erstellen
      --l_file                          := UTL_FILE.fopen(v_directory,v_new_filename,'w');
      l_file                          := UTL_FILE.fopen(v_directory,v_new_filename, 'WB', 32760);
      IF DBMS_LOB.FILEEXISTS (v_bfile) = 1 THEN
        cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'File exists');
        FOR rec IN
        (SELECT blob_content lblob,
          LENGTH(blob_content) LEN
        FROM apex_application_files
        WHERE rownum = 1
        LOOP
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Filesize is '|| LEN);
          IF LEN < 32760 THEN
            utl_file.put_raw(l_file,lblob);
            utl_file.fflush(l_file);
          ELSE -- write in pieces
            vstart      := 1;
            WHILE vstart < LEN
            LOOP
              dbms_lob.read(vblob,bytelen,vstart,my_vr);
              utl_file.put_raw(l_file,my_vr);
              utl_file.fflush(l_file);
              -- 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;
            END LOOP;
          END IF;
         END LOOP;
        ELSE
          cert_log_pkg.m(p_module => 'CERT_FILE_PKG.PUT_FILE_TO_SERVER',p_msg => 'Datei doesnt exist');
        END IF;
        utl_file.fclose(l_file);
      EXCEPTION
      WHEN OTHERS THEN
        -- Close the file if something goes wrong.
        IF UTL_FILE.is_open (l_file) THEN
          UTL_FILE.fclose (l_file);
        END IF;
        DELETE FROM apex_application_files;
        RAISE;
        DELETE FROM apex_application_files;
      END put_file_to_server;Edited by: Vitor Rodrigues on 17/Fev/2012 12:03

  • (ORA-06508: PL/SQL: could not find program unit being called) utl_file

    hi all,
    I am using Oracle XE and forms 6i and am facing the above error when i try to use the utl_file utility.
    WHEN BUTTOn PRESSED
         IF (:EXPORT_IMPORT_DATA = 'E') THEN
              message(lc_status);
                             SECURITY.PKG_gen_trnsfr_data_flat_file.PROC_gen_trnsfr_data_flat_file(:DATA_FILE_PATH, :DATA_FILE_NAME, lc_status);
    PKG_GEN_TRNSFR_DATA_FLAT_FILE body
    create or replace PACKAGE BODY PKG_gen_trnsfr_data_flat_file IS
    PROCEDURE proc_gen_trnsfr_data_flat_file(p_file_location IN VARCHAR2, p_file_name IN VARCHAR2, po_status OUT VARCHAR2) IS
         lh_filename UTL_FILE.FILE_TYPE;
         ls_data VARCHAR2(2000);
         ln_count NUMBER;
         lc_error VARCHAR2(10000);
    CURSOR cur_FPM_DAMAGE_COMPENSATION IS SELECT RPAD(nvl(PDCO_CASE_CLASS,' '),1) || RPAD(nvl(PDCO_CASE_DISPOSAL_PENDING,' '),1) || RPAD(nvl(PDCO_CASE_DISPOSAL_TYPE,' '),1) || RPAD(nvl(PDCO_CC_NO,0),9) || RPAD(nvl(PDCO_CF_NO,0),9) || RPAD(nvl(PDCO_COMPEN_REALISED,0),18) || RPAD(nvl(PDCO_CONFISCATED_PRODUCE,' '),25) || RPAD(nvl(PDCO_CR_NO,0),9) || RPAD(nvl(PDCO_DAMAGE_DETAILS,' '),90) || RPAD(nvl(PDCO_DAMAGE_REPORT_NO,0),13) || RPAD(NVL(TO_CHAR(PDCO_DATE_ORDER_COMPOUNDING,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PDCO_DATE_PROSECUTION,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PDCO_DISPOSAL_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PDCO_DR_NO,0),9) || RPAD(nvl(PDCO_FOREST_NAME,' '),50) || RPAD(NVL(TO_CHAR(PDCO_ISSUE_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PDCO_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PDCO_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PDCO_NO_OF_PERSONS_IN_THE_CASE,0),6) || RPAD(nvl(PDCO_NO_ORDER_FOR_COMPOUNDING,' '),15) || RPAD(nvl(PDCO_OFFENCE_DETAILS,' '),90) || RPAD(nvl(PDCO_OFFENCE_TYPE,' '),1) || RPAD(nvl(PDCO_OFFENDER_ADDRESS,' '),90) || RPAD(nvl(PDCO_OFFENDER_NAME,' '),200) ||
    RPAD(nvl(PDCO_OFFICIAL_NAME,' '),30) || RPAD(nvl(PDCO_RA_SIGN,' '),30) || RPAD(NVL(TO_CHAR(PDCO_RA_SIGN_DATE,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PDCO_RECEIPT_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PDCO_RR_NO,0),18) || RPAD(nvl(PDCO_TOOLS,0),18) || RPAD(nvl(PDCO_TOTAL,0),18) || RPAD(nvl(PDCO_VALUE_CONFISCATED_PROD,0),18) || RPAD(nvl(PDCO_VFP,0),18) || RPAD(nvl(PDCO_YDIV_DIVISION_CODE,' '),8) || RPAD(nvl(PDCO_YRAN_RANGE_CODE,' '),8) outstring FROM FPM_DAMAGE_COMPENSATION;
    CURSOR cur_FPM_DAMAGE_COMPENSATION_R IS SELECT RPAD(nvl(CIRCLE,' '),90) || RPAD(nvl(DIVISION,' '),90) || RPAD(nvl(PREV_A,0),9) || RPAD(nvl(PREV_B,0),9) || RPAD(nvl(PREV_TOTAL,0),11) || RPAD(nvl(TOT_A,0),11) || RPAD(nvl(TOT_B,0),11) || RPAD(nvl(TOT_C,0),11) || RPAD(nvl(T_A,0),9) || RPAD(nvl(T_B,0),9) || RPAD(nvl(T_C,0),9) || RPAD(nvl(X_A,0),9) || RPAD(nvl(X_B,0),9) || RPAD(nvl(X_C,0),9) || RPAD(nvl(Y_A,0),9) || RPAD(nvl(Y_B,0),9) || RPAD(nvl(Y_C,0),9) || RPAD(nvl(Z_A,0),9) || RPAD(nvl(Z_B,0),9) || RPAD(nvl(Z_C,0),9) outstring FROM fpm.FPM_DAMAGE_COMPENSATION_R;
    CURSOR cur_FPM_ENCROACHMENT IS SELECT RPAD(nvl(PENC_AREA_UNDER_ENCROACH,0),18) || RPAD(nvl(PENC_BALANCE_AREA_UN_ENC,0),18) || RPAD(nvl(PENC_ENCROACH_ID,' '),8) || RPAD(nvl(PENC_FOREST_NAME,' '),50) || RPAD(nvl(PENC_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PENC_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PENC_LEGAL_STATUS_OF_FOREST,' '),90) || RPAD(NVL(TO_CHAR(PENC_PERIOD_FROM_UNDER_ENC,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PENC_PRESENT_STATUS,' '),90) || RPAD(nvl(PENC_YDIV_DIVISION_CODE,' '),8) outstring FROM FPM_ENCROACHMENT;
    CURSOR cur_FPM_ENCROACHMENT_REMOVALS IS SELECT RPAD(nvl(PENR_ACTION_TAKEN,' '),90) || RPAD(nvl(PENR_AREA_REMOVED_ENCMNT,0),18) || RPAD(NVL(TO_CHAR(PENR_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PENR_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PENR_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PENR_PENC_ENCROACHMENT_ID,' '),8) || RPAD(nvl(PENR_PENC_YDIV_DIVISION_CODE,' '),8) outstring FROM FPM_ENCROACHMENT_REMOVALS;
    CURSOR cur_FPM_FIRE IS SELECT RPAD(nvl(PFIR_ACTION_TAKEN,' '),90) || RPAD(nvl(PFIR_AREA_EFFECTED,0),18) || RPAD(nvl(PFIR_CAUSE_OF_FIRE,' '),2) || RPAD(nvl(REPLACE(REPLACE(PFIR_DAMAGE_DETAILS,CHR(13),' '),CHR(10),' '),' '),200) || RPAD(nvl(PFIR_DAMAGE_VALUE,0),18) || RPAD(NVL(TO_CHAR(PFIR_DATE_OF_FIRE,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PFIR_DATE_VISIT_DFO,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PFIR_DATE_VISIT_RANGEOFFICER,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PFIR_DFO_COMMENTS,' '),90) || RPAD(nvl(PFIR_DFO_SIGN,' '),30) || RPAD(NVL(TO_CHAR(PFIR_DFO_SIGN_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PFIR_FIRE_NO,' '),10) || RPAD(nvl(PFIR_FOREST_NAME,' '),50) || RPAD(nvl(PFIR_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PFIR_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PFIR_NO_OF_TREES,0),18) || RPAD(nvl(PFIR_QTY_OTH_FORST_PROD_BRNT,0),18) || RPAD(nvl(PFIR_RANGEOFFICER_COMMENTS,' '),90) || RPAD(nvl(PFIR_REPORTING_PERSON,' '),30) || RPAD(nvl(PFIR_VALUE_OTH_FORST_PROD_BRNT,0),18) || RPAD(nvl(PFIR_VALUE_TREES_BURNT,0),18) || RPAD(nvl(PFIR_VOLUME_TREES_BURNT,0),18) || RPAD(nvl(PFIR_YDIV_DIVISION_CODE,' '),8) || RPAD(nvl(PFIR_YRAN_RANGE_CODE,' '),8) outstring FROM FPM_FIRE;
    CURSOR cur_FPM_JFM_MASTER IS SELECT RPAD(nvl(PJFM_BSCM_SCHEME_CODE,' '),8) || RPAD(nvl(PJFM_JFM_ID,0),13) || RPAD(nvl(PJFM_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PJFM_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(NVL(TO_CHAR(PJFM_LAUNCH_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PJFM_LOCATION,' '),20) || RPAD(nvl(PJFM_YDIV_DIVISION_CODE,' '),8) outstring FROM FPM_JFM_MASTER;
    CURSOR cur_FPM_JFM_DETAILS IS SELECT RPAD(NVL(TO_CHAR(PJFD_DATE,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PJFD_EXPENDITURE,0),18) || RPAD(nvl(PJFD_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PJFD_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PJFD_NO_OF_FPS,0),13) || RPAD(nvl(PJFD_OTHER_AREA_INCLUDED,0),18) || RPAD(nvl(PJFD_OVERALL_AREA_REGENERATED,0),18) || RPAD(nvl(PJFD_PF_AREA_INCLUDED,0),18) || RPAD(nvl(PJFD_PJFM_JFM_ID,0),13) || RPAD(nvl(PJFD_RF_AREA_INCLUDED,0),18) || RPAD(nvl(PJFD_VALUE_BENEFIT_CASH,0),18) || RPAD(nvl(PJFD_VALUE_BENEFIT_GOODS,0),18) outstring FROM FPM_JFM_DETAILS;
    CURSOR cur_FPM_PROTECTION_FIRE_MASTER IS SELECT RPAD(nvl(PPFM_AREA_ATTEM_TO_BE_PROT,0),18) || RPAD(nvl(PPFM_FINANCIAL_YEAR,' '),9) || RPAD(nvl(PPFM_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PPFM_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PPFM_YDIV_DIVISION_CODE,' '),8) outstring FROM FPM_PROTECTION_FIRE_MASTER;
    CURSOR cur_FPM_PROTECTION_FIRE_DET IS SELECT RPAD(nvl(PPFD_AREA_ACTUALLY_PROTECTED,0),18) || RPAD(nvl(PPFD_COST,0),18) || RPAD(nvl(PPFD_FAILURE,0),18) || RPAD(nvl(PPFD_LASTUPDATE_BY,' '),30) || RPAD(NVL(TO_CHAR(PPFD_LASTUPDATE_ON,'DD-MON-RRRR'),' '),15) || RPAD(nvl(PPFD_PPFM_FINANCIAL_YEAR,' '),9) || RPAD(nvl(PPFD_PPFM_YDIV_DIVISIN_CODE,' '),8) outstring FROM FPM_PROTECTION_FIRE_DETAILS;
    BEGIN
    lc_error := 'begin';
    lc_error := p_file_location || p_file_name ;
         lh_filename := UTL_FILE.FOPEN(p_file_location, p_file_name, 'w',32767);
    lc_error := 'filename';
         SELECT COUNT(*) INTO ln_count FROM FPM_DAMAGE_COMPENSATION;
         lc_error := 'line 1';
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10) || 'FPM_DAMAGE_COMPENSATION');
         lc_error := 'line2';
         FOR i IN cur_FPM_DAMAGE_COMPENSATION LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM fpm.FPM_DAMAGE_COMPENSATION_R;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_DAMAGE_COMPENSATION_R LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_FIRE;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10)||'FPM_FIRE');
         FOR i IN cur_FPM_FIRE LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_JFM_MASTER;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_JFM_MASTER LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_JFM_DETAILS;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_JFM_DETAILS LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_PROTECTION_FIRE_MASTER;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_PROTECTION_FIRE_MASTER LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_PROTECTION_FIRE_DETAILS;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_PROTECTION_FIRE_DET LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_ENCROACHMENT;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_ENCROACHMENT LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         SELECT COUNT(*) INTO ln_count FROM FPM_ENCROACHMENT_REMOVALS;
         UTL_FILE.PUT_LINE(lh_filename, RPAD(ln_count,10));
         FOR i IN cur_FPM_ENCROACHMENT_REMOVALS LOOP
         UTL_FILE.PUT_LINE(lh_filename, i.outstring);
         END LOOP;
         UTL_FILE.FCLOSE_ALL;
         po_status := 'NO ERROR';      
         EXCEPTION
                   WHEN UTL_FILE.INVALID_PATH      OR UTL_FILE.INVALID_MODE THEN
                                       po_status := 'I 1';
                   WHEN UTL_FILE.INVALID_FILEHANDLE OR UTL_FILE.INVALID_OPERATION OR UTL_FILE.INTERNAL_ERROR OR UTL_FILE.WRITE_ERROR THEN
                                       po_status := 'I 2';
                   WHEN OTHERS THEN
                                       po_status := lc_error;
                                       LC_ERROR:='I 4';
                                       dbms_output.put_line(LC_ERROR);
    END;
    END;
    If i uncomment UTL_FIle.Fopen statement, the error text will be the path name and file name.
    Can anyone advise as to what should be done to resolve this on XE. It worked fine on 8i.
    I have runcatproc.sql and utlfile.sql also
    regards
    kunal

    Hi
    On 8i you would have set the UTL_DIR_PATH parameter
    in the init.ora file. Did you do this for your XE
    database? I hope you are referring to the UTL_FILE_DIR parameter. I have set this parameter to value *.
    Although the better approach would be to
    create a directory object for the file path, an
    option which was introduced in 9i..
    Can you please elaborate me on this. I tried declaring the create directory statement in the package, but that didnt help. I have already created one through sql command line. How can i use this directory as an alternative to utl_file

Maybe you are looking for

  • AffectsFormMode property of User defined field in system matrix

    Hallo I added one UDF in System matrix of  service call id at panel  Solution. I  set formated search for that UDF field to populate Symptons data from  system knowldge base form (table). I set the fromatted search property for that UDF Column is Aut

  • Upgrade from 8.1.6 to 9.2.0.7 via export/import

    Has anyone done this or know if it's possible to simply build a 9.2.0.7 instance, then use export/import to perform the upgrade from 8.1.6 to 9.2.0.7 since a direct manual upgrade from 8.1.6 is not supported?? TIA

  • RAID 5 Question - separate volume for OS/Apps: pros/cons

    What are the pros & cons of having 2 volumes on a Mac Pro RAID 5 (instead of one big volume): Vol 1: OS & Applications Vol 2: Home Folders (basically everything else) 1) Is this a good idea/bad idea? 2) For what purposes would this setup be best used

  • Get IP of interface

    I have a computer with two interfaces (eht0 and eth1). This computer receives broadcast datagrams from any interface... I would like to know the ip address of the interface in which arrive the datagram. How can I get the ip address of MY interface fr

  • Same sync interface, multiple receivers

    I have to make the same syncronous call into two R3 systems out of BPM. So the sender service and interface are the same, how the receiver service is different. I get the error that you cannot make multiple sync calls at once. So I have to use two se