Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PL/SQL UTL_FILE FOPEN

Posted on 2004-10-27
6
Medium Priority
?
6,563 Views
Last Modified: 2012-06-21
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
0
Comment
Question by:Intern
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12425462
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
 
LVL 77

Accepted Solution

by:
slightwv (䄆 Netminder) earned 2000 total points
ID: 12425488
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
 
LVL 1

Author Comment

by:Intern
ID: 12425533
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:Intern
ID: 12425541
Guess I am to slow, I will check it out.
0
 
LVL 77

Expert Comment

by:slightwv (䄆 Netminder)
ID: 12426203
Are you still in need of assistance?
0
 
LVL 1

Author Comment

by:Intern
ID: 12447704
Thanks alot, worked like a charm.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Working with Network Access Control Lists in Oracle 11g (part 1) Part 2: http://www.e-e.com/A_9074.html So, you upgraded to a shiny new 11g database and all of a sudden every program that used UTL_MAIL, UTL_SMTP, UTL_TCP, UTL_HTTP or any oth…
Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and the…
Via a live example, show how to take different types of Oracle backups using RMAN.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question