Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2006
    Posts
    3

    Unanswered: how to find whether OS file exists or not

    hi


    iam using oracle9i as Db and Forms6i as frontend.

    i have one form to take the Backup of DATABASE In that iam entering one file path like d:\exp.dmp.I written code to takebackup in the when button pressed trigger.when i press the button the Db is exported in to the file which we r entered in the textitem.It is working Fine.

    BUT if next time i enter the same filepath and press the button the file will be overwrite.I dont want like this.I want to write some code in WHENVALIDATE ITEM TRIGGER to FIND whether the OS file exists or not.


    Is there any process to check.
    please help.
    Thanks in Advance

  2. #2
    Join Date
    Dec 2003
    Location
    Oklahoma, USA
    Posts
    354
    First, create an Oracle Directory pointer:

    Code:
    CREATE DIRECTORY backups AS 'd:\';
    GRANT READ ON DIRECTORY backups TO some_username;
    Then, your procedure to check for the file needs to contain the following:

    Code:
       ex    BOOLEAN;
       flen  NUMBER;
       bsize NUMBER;
    BEGIN
    
       utl_file.fgetattr('BACKUPS', 'exp.dmp', ex, flen, bsize);
    
       IF ex THEN
          dbms_output.put_line('File Exists');
          dbms_output.put_line('File Length: ' || TO_CHAR(flen));
          dbms_output.put_line('Block Size: ' || TO_CHAR(bsize));
       ELSE
          dbms_output.put_line('File Does Not Exist');
       END IF;
    
    END;
    Hope this helps.
    JoeB
    save disk space, use smaller fonts

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •