Re: Checking if a File Exists or not from PL/SQL
Date: 1 Aug 2001 03:05:17 -0700
Message-ID: <cc8172b4.0108010205.6a0f447c_at_posting.google.com>
Yes there is.
Read up on UTL_FILE package in Oracle Supplied Packages Reference (8i) or PLSQL dev guide in earlier releases...
Basically you use the function UTL_FILE.FOPEN to open the file you want to check in READ only mode (Do not open in Write Mode !!). If the file does not exist, it will raise an exception which can be trapped to take further action.. This will work whether it is on different platforms, or on server/client etc etc.
an eg. (UNTESTED !)
declare
FILE_EXIST_FLAG UTL_FILE.FILE_TYPE;
begin
FILE_EXIST_FLAG := UTL_FILE.FOPEN('/u01/oracle/8.1.6/','myfile.txt','r');
EXCEPTION
WHEN INVALID_PATH THEN /* Can use when others etc also */
DBMS_OUTPUT.PUT_LINE('File does not exist');
end;
you cannot use env variables in the path parameter...
HTH,
Deepak
> > Hi,
> > I have an anonymous PL/SQL block in which I have some processing to do
> > based on whether an operating system file exists or not. This file can
> > be on any machine, not necessarily on the machine where the Database
> > server is.
> >
> > Please let me know if this is possible and if possible, how.
> >
> > Thank You.
> > -Bakir
>
Received on Wed Aug 01 2001 - 12:05:17 CEST