Home » Developer & Programmer » Forms » Re: checking for file on system????????
Re: checking for file on system???????? [message #80257] Fri, 30 August 2002 06:50
Julie
Messages: 98
Registered: February 2002
Member
It depends on whether you want to know if the file exists on the server or on the client machine. If you want to know about the server, you have to use the UTL_FILE package and try to FOPEN. IF it fails, the file does not exists.
If you want to know if it exists on the client, you use TEXT_IO and similarly try to open the file. An example follows:

FUNCTION FileExists (p_filename VARCHAR2)
RETURN BOOLEAN IS
l_file_id TEXT_IO.FILE_TYPE;
BEGIN
l_file_id := TEXT_IO.FOPEN(p_filename);
TEXT_IO.FCLOSE(l_file_id);
RETURN TRUE;
EXCEPTION
WHEN others THEN
RETURN FALSE;
END FileExists;

Then in your code you just need to do something like
IF FileExists('c:tempmyfile.txt') THEN
.....
ELSE
.....
END IF;
Previous Topic: ADD years
Next Topic: Newbie 's question:How to layout the object on a canvas in form builder?
Goto Forum:
  


Current Time: Fri Apr 26 22:00:00 CDT 2024