PL/SQL UTL_FILE FOPEN

If I use the FOPEN command to open a file, then how do I check if the file was not opened?

What I need to do in PL/SQL is to check if a file exists, if it does then I want to perform some database operations, that do not deal with the file.  Then delete the file.  I don't need to read or write to the file.

Thanks
LVL 1
InternAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

slightwv (䄆 Netminder) Commented:
How to check if it  opened:  No exception thrown:  probably opened.

When in doubt: UTL_FILE.IS_OPEN

Just to see if it exists:  ??? don't think there is a specific function for this.  I'd probably just do a quick readonly open then close.

delete the file: UTL_FILE.FREMOVE
0
slightwv (䄆 Netminder) Commented:
I was incorrect in the previos statement:

You can check if the file exists by using: FGETATTR

Check out:
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/u_file2.htm#1002542
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
InternAuthor Commented:
Thanks, could you give me a sample syntax of this command and checking if the file is open?

i.e.
DECLARE
vInHandle utl_file.file_type;
BEGIN
  vInHandle := utl_file.fopen('DIR', 'test.txt', 'R');
  IF utl_file.is_open(vInHandle) THEN
    utl_file.fclose(vInHandle);
    utl_file.fremove('DIR', 'test.txt);
  ELSE
   // Do something else
  END IF
END fopen;

Is this right??
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

InternAuthor Commented:
Guess I am to slow, I will check it out.
0
slightwv (䄆 Netminder) Commented:
Are you still in need of assistance?
0
InternAuthor Commented:
Thanks alot, worked like a charm.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Oracle Database

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.