UTL_FILE. OPEN_FILE question to check if a file exists and is not empty

Hello

I'm writing a code in 3 separate files are created based on certain conditions of parameter for the call of the extract.
Say that the parameters are NULL, 'A' and 'B '.
When the Null State is passed to the call of the extract then it should create file A and B if the records are found. If this isn't the case, then create empty files.
It is possible that the setting of the extract is just 'A', then it would create a file say no zero and B with file from scratch.
Now when the extract is called with the parameter 'B' and if the file already exists and is not empty then I shouldn't touch/crash with empty folders.
Is there a simple way I can do this to check if a file exists and is not empty?

I use
OPEN_FILE
(gv_utl_file_path
lv_file_name
lv_file_handle
);

Help, please.
Thank you

@OP: no need to open

SQL> declare
  2   lb_file_exist boolean;
  3   ln_size number;
  4   ln_block_size number;
  5  begin
  6   sys.utl_file.fgetattr('TEST_DIR','a.txt',lb_file_exist,ln_size,ln_block_size);
  7   if lb_file_exist then
  8    dbms_output.put_line('a Exists');
  9    dbms_output.put_line(to_char(ln_size));
 10   else
 11    dbms_output.put_line('a Not Exists');
 12   end if;
 13   sys.utl_file.fgetattr('TEST_DIR','b.txt',lb_file_exist,ln_size,ln_block_size);
 14   if lb_file_exist then
 15    dbms_output.put_line('b Exists');
 16    dbms_output.put_line(to_char(ln_size));
 17   else
 18    dbms_output.put_line('b Not Exists');
 19   end if;
 20   sys.utl_file.fgetattr('TEST_DIR','c.txt',lb_file_exist,ln_size,ln_block_size);
 21   if lb_file_exist then
 22    dbms_output.put_line('c Exists');
 23    dbms_output.put_line(to_char(ln_size));
 24   else
 25    dbms_output.put_line('c Not Exists');
 26   end if;
 27  end;
 28  /
a Exists
0
b Exists
3
c Not Exists

PL/SQL procedure successfully completed.

Published by: JAC on March 30, 2012 01:21

Tags: Database

Similar Questions

  • How can I check if a file exists in the CVI real-time?

    Also, it would be nice if designated so help file functions have been supported in real time or now.

    I tried this:

    If (GetFileAttrs (DataFileName, NULL, NULL, NULL, NULL) == - 1).

    You can check if a file exists in the CVI real-time using GetFileInfo.

    CVI provides a list of the available functions in the CVI real-time here: CVI real-time functions

  • Check if certain files exist

    Hi all

    I wrote a reference guide and I was wondering if I can check if certain files exist on a page.
    If it exists then I can send the user to a page.
    And if not, they will see another page.
    Grateful if someone points me to the right direction.

    Thank you
    Karen

    Hello Cognethos,

    You must use the double backslashes in your path of the file reference. Your script is OK except this line:
    If (FSO. FileExists ("C:\Program Files\Common Files\My file.txt Directory\My"))

    It should read this:
    If (FSO. FileExists ("file.txt C:\\Program Program Files\\My Directory\\My"))

    The technical reason for this is that there are special characters that you cannot use directly in a string. In this case, your path is the chain. Backslash is be one of the special characters that you cannot use directly in a string. To work around this problem, you must do what is called an escape sequence. In this case, the escape sequence for------is------.

  • SQL statement to check if a file exists

    Good afternoon

    I thought I saw once a post that had a SQL statement that would check a table to check if a record exists and return true or false... He would return all records, just a Boolean... Such a function exists? I searched the forums, but I don't remember what I was ready when I found this...

    Thanks in advance for any help you can offer.

    Donald

    Hi Donald,.

    Oracle SQL is not a Boolean data type (see: http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref19 for types available).

    As a general rule, a custom function returns 0 or 1 or 'Y' or ' no 'TRUE' or 'FALSE' or something similar, like a number or a varchar2.

    Depending on what you need to do and where you need to do, there are other options available. For example, a validation of the page, you could do a validation EXISTS of:

    SELECT 1 FROM TableX WHERE Field1 = value
    

    This would amount to true or false and validation would be success or failure as a result.

    Within a process, you would do something like:

    DECLARE
     vCOUNT NUMBER;
    BEGIN
     SELECT COUNT(*) INTO vCOUNT FROM TableX WHERE Field1 = value;
     IF vCOUNT > 0 THEN
      do something if there is a record;
     ELSE
      do something if there isn't a record;
     END IF;
    END;
    

    Andy

  • I have a problem with file compression and then not be able to extract their share at a later date

    original title: file compression

    I am running Vista Home Premium on my laptop. I have problems with file compression and then not be able to extract their share at a later date. For example, I sent a file compressed to my instructor and she pointed out that she had a .zipx extension and the fact that she was unable to extract the files of ranking. Can someone help me with this problem?

    Hello

    1. do you have a third party compression/extraction of software installed on your machine?
    2. do you get an error message when you try to extract the files?
    3. is the relevant question for the particular file type?
    4. don't you make changes to your computer before the problem?

    Follow the steps and check if they help.

    Step 1:

    Open zip files is to open the folder and drag the content to another folder.

    See article:
    Compress and uncompress files (zip files)

    Step 2:

    If you have a third party software to Compress/decompress, I'd Uninstall it employs the way Windows compression and decompression of files/folders and see if they help.

  • try to install Picture IT Publishing Platinum & get error 1305 D:\PIP\PIP2002\openscn6.its...verify file exists and you can access it... help

    It wont let me install Picture It! Publushing Platinum... error message 1305:
    Error reading file D:\PIP\PIP2002\openscn6.its... check the file exists and you can open it... help... what I do

    Hello
    1 did you change on your computer before this problem?
    2. in the place where you are trying to install?
    3. is this a problem install only Platinum edition or with all applications?

    You can follow the steps in the article and see if it helps.
    Problems installing and uninstalling programs on Windows computers
    http://support.Microsoft.com/kb/2438651
  • I went through all the steps to download the trial version of Adobe Photoshop elements 13. It is said download completed, but nothing happened then prompting to launch the program. I checked the finder (MAC OS) and could not find. Don't have Adobe downloa

    I went through all the steps to download the trial version of Adobe Photoshop elements 13. It is said download completed, but nothing happened then prompting to launch the program. I checked the finder (MAC OS) and could not find. Don't have Adobe download wizard. How to open and run the program?

    Jediii please see Photoshop elements 13 full download. What to do next? where this topic was just discussed.

  • Check if the file exists returns the value false. File is located in system32

    I'm having a problem to detect if there is a file that has been simply copied to the system32 directory.  I tried to move the file to various other directories and simply using a vi with action "check if a file or folder exists.  I narrowed down it to not be able to find the file if I copy into c:\windows or c:\windows\system32.

    I thought it could be a permissions problem, but not my best to assign the user full name control folders.

    Another interesting thing is that if I do file an input control and click on the "folder" icon to open a list of files, I see either the files newly copied to the system32 directory.  Very strange.

    It is on a PC, Dell, Windows 7 Professional/Labview 2010 SP1 (note that I use the vi. as an executable on this machine).  Would it be a setting in the generation of my project?

    If you are using Windows 7 64 bit, it may be related to problems that the user has been seen here:

    http://forums.NI.com/T5/LabVIEW/problem-using-quot-MSG-quot-command-with-quot-system-exec-VI/m-p/153...

    It may be that LabVIEW functions are 32-bit and are diverted.

  • How to run a job that will check if the files exist?

    I have a file in real time ' ' which has about 15 files (test1.txt, other.txt etc.) txt, theres is other jobs that nothing related to coldfusion that if something fails then the file no longer exists.

    So I want to create a job if there is no such thing as a txt file so he sent me an email.

    What would be the best way to do something like that?

    I have to check for every individual txt, something like file?

    <cfset Pathtest = "\\folder1\dept\Alerts\other.txt">
    
    <cfif !fileExists(Pathtest)>
      <cfmail ...>
      sent me a email
      </cfmail>
        
    </cfif>
    

    If all the files are in the same directory, you can create a list separated by commas (or even a table) file names, and that loop.

    
    
    
        
            ... email me ...
        
    
    

    HTH,

    ^_^

  • Fastest way to check if a file exists

    Hello

    I have a table with more than 100 M records. What is the fastest way to check if a record exists or not. Currently I use Oracle 11.2. Here is the SQL code I used, id is the primary key of the table_test.

    Select count (*) from existFlag
    of table_test
    where id = testID
    ;

    Yes, you could use double fusion using the clause, but a line of K + 10 k 10 inserts a line MERGE statements will be much less effective than 1 INSERTING rows 10 K + 1 MERGER of 10 K lines.

    SY.

  • Check if a file exists in the network dir (JS)

    I found an old post that made me to:

    If {(myFile.exists)

    Alert ("File Exists");

    }

    on the other

    Alert ("file does not exist");

    The problem is that when I use the macname/volumes/dir/folder/folder/file.indd path (which was created from variables) that myFile script is not conclude to the existence of a file that I know. All I get is the alert "file does not exist.

    I set myFile as being a string?

    I'm still fumbling my way around JS and conversion Applescripts for JS to work cross-platform. Thanks in advance...

    I set myFile as being a string?

    No, set it as follows:

    var myFile = new File("/Volumes/VolumeName/FolderName/SubFolderName/FileName.indd");

  • Playlist shows as file names and will not play in the order of songs

    Why did my playlist showing as file names and not using their iD3 tags as they do in my music folder? For example: "Feeder - 03 Helium.mp3" instead of "Feeder - helium" as it should be?

    EDIT: Thanks to bob for the help on this.

    I do not understand why, but I have a playlist in MTP mode folder but in MSC playlist folder disappeared. I just tried to create a playlist in MSC mode folder and put my m3u playlist, he sees the video, but when I choose it it says it's empty...

    Someone please help! I have to use my old 2 GB for my playlists until this issue is resolved.

    EDIT: just redid all my playlists and it works now.

  • MP2 file corrupted and does not play

    I have a few mp2 files, but they do not play. I would get this error message. Windows Media Player C00D1199. Thanks for your help.

    Seen elsewhere?
    http://Windows.Microsoft.com/en-us/Windows7/C00D1199

  • Version style phone is blank pages. But when I look at the files that they are not empty. What could cause this?

    desktop version.JPG


    mobile version.JPG




    All the files are there and they are empty. I did not use all the features and link to the model. That is why sound come in white?

    Try to save the file with a different name and open the new file. and if it does not,

    Please share your with us .muse file to study? Please send it to [email protected]. If your file is larger than 20 MB, you can use something like Adobe SendNow SendThisFile or Dropbox. Don't forget to mention the link to this forum thread in your email so that we can identify the file.

  • No file size and does not

    I have

    Download Flash Player 10.3 and he duly completed. When I open the Control Panel, add/remove the flashplayer of words is there, but the word size and file size numbers are not. I try to run video trackpass with octoshape and flashplayer for NASCAR site. I have windows xp IE8. I'm going to load video from the site, and it shows download OK until it reaches 80%, then nothing. Help!

    Hello marley, glad that worked for you. It may be confused here

    You can just mark your thread as answered and that should take care of it.

    Thank you

    eidnolb

Maybe you are looking for

  • I deleted a confidentiality in Thunderbird. I find back? (and replace)?

    I'Have been stupid. Unable to change a Pop one account Imap, I decided to make a new. Thunderbird told me that the account exists already (emailadres even). Then I thougt remove the old one and make a new early... Removal of the old, I lost all of my

  • Firefox does not send the file entries via iframe

    I know that this is not a forum for programming, but I have problems with firefox while trying to send file entries via IFRAME. This is my code <form id="popup_form_archivo" method="post" action="'subir_imagen.php" target="wk_iframe" enctype="multipa

  • PRS-600 USB device not recognized

    I am unable to get ereader PRS-600 to be recognized by the computer (Win7).I tried to update the software (even if I think it's in)(date) but the window 'connect a PRS-600 to update' does not progress and the update button is dimmed.I deleted the "un

  • Using dual-boot provided drive recovery XP on Portege R500 - 11 c

    I have a new Portege R500 - 11 c that came with Vista Business installed, but has also a recovery disk XP Pro as a Vista recovery disk. Also, the laptop came with a partitioned hard drive. I would use the XP Recovery disk to install XP on the 2nd par

  • ReadyNas 314, impossible to access via Windows Explorer

    Have spend the last 3 hours trying to find a solution on other posts, but nothing helps. Novice at most, so when you can, please explain as I am 5. I have a new 4-Bay ReadyNAS and installed 4 new 4 TB drives. Currently connected to the router by ethe