Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

check for file existence on disk not working (utl_file.fgetattr)

user5716448Mar 4 2015 — edited Mar 4 2015

Hi

Using 11.2.0.3 and have the following code to try and check for file existence.

Directory and file definitely exists and user/schema has had grant all on directory specfifed granted to them.

Anything else need to do ?

Wjen run it says file does not exist - tried uppare and lower case.

declare 

v_file_exists    BOOLEAN;

      v_file_length    NUMBER;

      v_block_size     NUMBER;

  begin

 

 

-- Create a process to load data to archive

--A process will need to run on a regular basis to query the datain.txt_finance_gl table. If an error is raised that shows the file cannot be found then it exits and waits to run the next time.

--If data is returned, then the data can be queried and loaded into the archive table with the relevant sequence number and datestamp.

--The txt_load_control will be used to control and audit the transfer.

--The next sequence number in the txt_finance_gl_seq will be obtained along with the current datetime and used to create a new entry in the control table (edc_type will be ‘GL’) and given a status of running.

--On completion of the load, the flat file will be renamed (pre-fixing the sequence number onto the old name) and moved into the finance processed folder.

--The control table can then be updated to show the run as complete.

    

--  First check if file exists on disk in expected area.

  utl_file.fgetattr('big_tab_data', 'testfile', v_file_exists,v_file_length,v_block_size);

    IF v_file_exists THEN

        dbms_output.put_line('File Exists');

    ELSE

       dbms_output.put_line('File Does Not Exist');

    END IF;

end;

This post has been answered by Saubhik Banerjee on Mar 4 2015
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 1 2015
Added on Mar 4 2015
11 comments
2,558 views