PL SQL block - Check for empty file

Hello,
I need help in writing pl sql code to check a file to verify if it has 0 records (file size = zero kb.) In a preceding pl sql block, I am performing a SELECT on data and writing it to a file. If that file is empty/has no records, then I would like to stop the process from continuing on to my next pl sql block which performs an update function.
Summary:
1) Create file from SELECT
2) Check file for zero data, if true, trigger error, if false, continue to next pl sql block.
3) Run update on records if data exists in the file.
Thanks in advance!

Thanks John,
You've been of great help so far and a really appreciate it. I'm so close to getting this, I just need help with how to create an error when the file shows no data. I will be running this as an Oracle Apps Concurrent request. I'd like for the job to end in error when no data exists for the file. In unix, I can enter "EXIT 1" and it signals to the concurrent manager to put end the job with an error status. How can I do something similar using pl sql? Here is my code so far, with the missing piece. Thanks!
DECLARE
  vFile UTL_FILE.FILE_TYPE;
  vrecs BOOLEAN := FALSE;
  vnodata EXCEPTION;
BEGIN
  vFile := UTL_FILE.FOPEN('/devlop, 'norecs.txt', 'w', 32767);
FOR x IN (
SELECT
     node_name AS txt
FROM
     applsys.fnd_nodes
WHERE
     node_name = 'blahblahblah'
LOOP
        vrecs := TRUE;
        UTL_FILE.PUT_LINE (vFile, x.txt);
END LOOP;
        UTL_FILE.FCLOSE(vFile);
        IF NOT vrecs THEN
            RAISE vnodata;
        END IF;     
EXCEPTION
       WHEN vnodata THEN
    *<what can I put here to cause the pl sql block to error???>*
END;
/

Similar Messages

  • Check for empty visa resource?

    When I am developing the VI at my desk and not a the test station PC, the VISA resource name is empty.
    Once the VI is moved to the test station PC, the user can select a VXI board.
    How do I make sure the user has selected a VISA resource before continuing?
    I can wire a Comparision to check for Empty String, and that works. But is there any method that I should use?
    Solved!
    Go to Solution.

    Additionally, you can limit the selectable items by interface type. Right-click VISA Resource Name Control and select I/O Name Filtering.
    National Instruments
    Product Support Engineer

  • Can't get Firefox to load at all after trying fixes from support web site. Have checked for lock file, processes running, reboot, reinstall. NO JOY.

    I'm running Vista for operating system on an HP laptop that's about 2 years old. I've installed all current updates.
    I've always used Firefox. It started crashing and creating processes but not launching. Went to support and scoped it out -- there was a lock file my profile directory. I deleted it, and Firefox started loading.
    Used it a few times -- closed the app each time on exist as per suggestions on support site info. One time -- back to square one, wouldn't load, just created a process. Reboot, ending process, checking for lock file, reinstalling -- all unsucessful.

    Brian
    Below is from using a SIP build.  It does offer G722, but it's way down on the list so it's never used...
    m=audio 32678 RTP/AVP 0 8 18 102 9 116 101
    a=rtpmap:0 PCMU/8000
    a=rtpmap:8 PCMA/8000
    a=rtpmap:18 G729/8000
    a=fmtp:18 annexb=no
    a=rtpmap:102 L16/16000
    a=rtpmap:9 G722/8000
    a=rtpmap:116 iLBC/8000
    a=fmtp:116 mode=20
    a=rtpmap:101 telephone-event/8000
    Taking Sreekanth's suggestion to try a Skinny build, I get the following when I make a call.  It offers codecs in the order I SET THEM AND ONLY THE CODECS I SET!  YAY!
    m=audio 19374 RTP/AVP 9 0 101
    a=rtpmap:9 G722/8000
    a=fmtp:9 bitrate=64
    a=rtpmap:0 PCMU/8000
    a=rtpmap:101 telephone-event/8000
    Using a Skinny build on the phones also solved other issues.  The phones use G711 when the whole path supports G711 and G722 when the whole path supports G722.  It doesn't always use G722 and rely on transcoding for the call paths that can't use it.  It's fantastic..  The phones also receive the QoS tagging that I set and that seems to result in better audio quality than on the SIP builds, which never did get those settings.  Finally, it even solved a slow Exchange 2013 answer issue I have been experiencing for quite some time.  I practically fell out of my chair when I saw everything that was fixed just by switching...
    Cisco, PLEASE FIX YOUR SIP BUILDS!  It's insane how the SCCP builds work perfectly and the SIP builds don't, especially with how much these phones cost..  I was thinking of possibly acquiring some 9951s, which are SIP only.  I'm a little leery about that at this point.  If they have the same kinds of issues as the SIP builds for the 7975g, there's no SCCP alternative to use..
    Sreekanth
    Thank you for suggesting a Skinny build..  That was about the only thing I didn't try.  I am happy beyond belief that this is working so well now, even though the SIP builds should be just as well developed as the SCCP ones.

  • File Handling (Check for existing file)

    now my problems is that i need to have a code that upon a request checks for a file (in the home dir) and if the file exists reads the information and ouputs it. here is an example:
    check if file TEST.DATA exists?
    check approved TEST.DATA exists
    information outputed...
    if the file is missing i need to have an error message...
    PS. sorry if the question falls under "lame" but i am fairly new to java and i dont know the commands that well... thank you in advance!

    File.exists()
    Reading Text from a File
    Useful places to seek for information:
    - Java API documentation
    - The Java Tutorial
    - Code examples from Java developpers Almanac
    - Google
    - ...

  • Check for source file

    Hi,
    My requirement is as below:
    In source FTP directory, I have to check if source file exists or not. If exists, that file shuld be picked up and created at target side with header, line items and detail record.
    If the file does not exist, then a file should be created at target side with only header and detail record with no line item records.
    In any case, a file should be created at target side.
    Please suggest if Dynamic configuration is the better option for this or any other way gives better results.
    Thanks and Regards,
    Anil.

    @ Babu,
    The query is like...
    If the file does not exist, then a file should be created at target side with only header and detail record with no line item records.
    In any case, a file should be created at target side.
    so i answered as,
    Now when the file is not present, u will get only the empty tags..(message type name in XML Payload)
    If you read the question carefully, it is not being asked "how to handle empty files". It is about "what to do if there are no files in the source directory", which implies that if there are no files present, then create one.
    u said as,
    This option won't "create" an empty file.
    Correct me if i am wrong, DID I SAY IT WILL CREATE an EMPTY FILE IN SOURCE FOLDER???
    No, you don't need to say that .. it was evident from your answer. In this forum post, nothing is being asked regarding empty files, so please don't provide such answers which has nothing to do in this situation.
    -- Abhi

  • How do I send a email notification with PL/SQL to Check for Columns

    I want to be able to use PL/SQL to check my columns and makes sure that all required columns were populated, and if any were not populated to send an email notification.
    Thanks
    Hank

    I would still suggest that adding appropriate constraints (well, logical constraints) to the table is the right way to go.
    When you get the file back, you load the data into the table. If the constraint is satisfied, the data is loaded. If the constraint is violated, the loader gets an error, writes the affected data to another table, to another file, etc. That way, the data in the database is always correct and you have a log of the rows that were bad.
    create table t( status varchar2(10), cost number );
    create or replace trigger trg_t
    before insert or update
    on t
    for each row
    begin
       if :new.status = 'Approved' and :new.cost is null
       then
         raise_application_error( -20001, 'Cost must not be null if status is approved' );
       end if;
    end;
    SCOTT @ hp92 Local> insert into t values( 'Reject', 1 );
    1 row created.
    SCOTT @ hp92 Local> insert into t values( 'reject', null );
    1 row created.
    SCOTT @ hp92 Local> insert into t values( 'Approved', 2 );
    1 row created.
    SCOTT @ hp92 Local> insert into t values( 'Approved', null );
    insert into t values( 'Approved', null )
    ERROR at line 1:
    ORA-20001: Cost must not be null if status is approved
    ORA-06512: at "SCOTT.TRG_T", line 4
    ORA-04088: error during execution of trigger 'SCOTT.TRG_T'If you don't want to touch the loader, you can rename the table, create a view with the same name, and use an INSTEAD OF trigger on the view to populate the real table or a reject table.
    Either way, you're better off, in general, rejecting invalid records than trying to expend a lot of effort reporting on them.
    Justin
    Distributed Database Consulting, Inc.
    http://www.ddbcinc.com/askDDBC

  • Check for Duplicate files.

    I have multiple folders with duplicate files, i was wondering what is the best way to check for duplication based on file content even if the file name is slightly different.

    There are several commercial software options. I suggest that you use the ones that use SHA1 matching.
    Decloner is pretty good, and it comes with a 30-day trial that is FULL FEATURED.
    http://www.pixelespressoapps.com/decloner/
    Only works on snow leopard and up.
    Their website conviniently compares other duplicate file software packages.
    I purchased Twins, which is also great.
    http://www.rockysandstudio.com/apps/twins
    Only works on Lion and up.
    Remember, SHA1 is the way to go if you want to find duplicates with highest accuracy.

  • Check for a file to exist

    Hi all, I have a script which returns the path for a file in this way:
    set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
    the path is then passed to the shell. Now, I want the script to check whether that file exists and if it does, the script needs to be stopped.
    I tried some ways I found on the web but none seems to work.
    Any help would be appreciated.
    Thank you!
    Lorenzo

    Try using:
    set outfile to (choose file name with prompt "Choose output file." default name "out.iso")'s POSIX path
    set thefile to POSIX file outfile
    tell application "Finder"
    if exists thefile then
    return --or other commands to stop script
    end if
    end tell
    (57077)

  • Checking for a file in a dir + all subdir's

    i'm checking if a file exists in C:/, and all sub directories of C:/. It's easy enough to scan for it in the parent directory, but how would i go about checking all the sub directories also? I couldn't get a system of using the boolean isDirectory working, here's what I have though:
    import java.io.File.*;
    import java.io.*;
    class Readit {
         File file;
         Readit(String fileName) {
              file = new File(fileName);
              check(file);
         void check(File file) {
              try {
                   if(file.exists()) {
                        String files[] = file.list();
                        for(int i = 0; i < files.length; i++) {
                             System.out.println(files);
                             File subdir = new File(files[i]);
                             if(subdir.isDirectory()) {
                                  String infil[] = subdir.list();
                             }{color}
              } catch(NullPointerException nul) {}
         public static void main(String[] args) {
              Readit r = new Readit(args[0]);
    }Edited by: Pattylulz on Jun 10, 2008 8:43 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    It is not clear what exactly you need.
    I assume that you want to find recursively a file/folder with given name:
       private static final FileSystemView fsv =
                FileSystemView.getFileSystemView();
       private static final File checkFile(File pathParent,
                                           String name) {
          final File[] list = pathParent.listFiles();
          if (null == list)
             return null;
          File pathFound = null;
          for (int i = 0; i < list.length && null == pathFound; i++) {
             final File pathCur = list;
    // Can use system display name or name (pathCur.getName())
    final String nameCur = fsv.getSystemDisplayName(pathCur);
    // If you need to search only files, use: pathCur.isFile()
    if (name.equalsIgnoreCase(nameCur)) {// or equals
    pathFound = pathCur;
    } else {
    // All traversable items, but skip links to folders
    boolean isLink = false;
    try {
    isLink = ShellFolder.getShellFolder(pathCur).isLink();
    } catch (FileNotFoundException e) {
    if (fsv.isTraversable(pathCur) && false == isLink) {
    // Recursive is subfolders
    pathFound = checkFile(pathCur, name);
    return pathFound;
    public static void main(String[] args) {
    File file = checkFile(new File("C:\\"), args[0]);
    if (null != file)
    System.out.println("File is found: " + file);
    else
    System.err.println("Cannot find file with name: " + args[0]);
    Mimo                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • SQL Loader tool for control file creation

    We are planning to use SQL*Loader to move a lot of data from mainframe to Oracle 10g database. We will write the data in flat files and use SQL*Loader to load these files into tha database. There are more than 100 tables with lot of columns in each. So, I was just wondering if there is any tool available (visual mappings etc.) that can help create the control files for the SQL*Loader, so that I don't have to manually type all the lengthy control files
    Thanks for any help,
    Sam

    sql*loader is capable to generate the controlfile for external tables which are pretty much the same
    Something like
    sqlldr scott/tiger ulcase1 EXTERNAL_TABLE=GENERATE_ONLYhttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96652/ch08.htm#1006964

  • Check for closed files?

    Hi,
    I created a thread that "scans" a given folder for files. If any file is found then i move that file to another location, the problem arises if i have one application(example: Microsoft Word) saving the files there, and the thread "grabs" the file, before the process of saving is completed.
    How do i solve the problem? I thought in checking if the file is open, then the thread should touch it, but how do i check if the file is open or closed?
    Thanks in Advance,
    MrNiceLife

    The claim has been made that "NIO" in jdk 1.4.x gives methods for dealing with this problem.

  • Checking for sender file

    Hi
    Is there a way for checking the availability of a file in the sender system folder in PI 7.0?

    hi
    if you done all these desingn and configuring part
    copy the xml format file and paste in to the source file in your woek space
    then check the Runtime workBench
    in that check the component monitoring
    in that check the communication
    and check your sender file is going to the XI or not. if it is green then it is send atherwise having the problem
    check
    thanks
    Regards
    vijay

  • Need script to check for duplicate file names when copying a folder

    Hello,
    I am a new applescript user trying to write what I believe should be a simple script. I was planning on using the "add-new item alert" script as a template.
    Basically I have people copying folders of photos into a library folder, but I don't want the Finder to copy the photo if it already exists in the library. The images in the library are organized into subfolders.
    I need a script that will check all the file names in the new folder against all the file names in the library, and NOT add the new one if it already exists.
    If anyone can help it would be greatly appreciated,
    Thanks,
    C

    I have a script that "kind of" works. The only problem I've seen is that it gets confused when filenames contain characters that are fine in Macland but not good in Unixland. Forward slashes are a good example of this.
    In this case I have a folder in my home named "copytest" Inside copytest are two folders:
    Source (containing the images to be added)
    Dest (My existing library of images)
    It also assumes that the folder of images to be added contains no sub-folders. Hope this helps.
    tell application "Finder"
    set theSource to folder "source" of folder "copytest" of home
    set imagesToBeCopied to name of every file of theSource
    end tell
    repeat with theFile in imagesToBeCopied
    try
    if (do shell script "find -r ~/copytest/dest -name " & quoted form of (theFile as string)) is not equal to "" then
    --The file exists. Don't copy it
    else
    --the file doesn't already exist. Copy it.
    end if
    on error
    return "Failed while trying to check for existence of a file"
    end try
    end repeat

  • Check for empty session variable

    Hey there we're making a login for our jsp web application.
    The login allready works and so does the log out but now we want to make a check to make it impossible to login with names that are not in the database.
    So what basicly happens is as follows...
    Login reads the database info:
    while (rs.next()) {
         if (request.getParameter("username").equals(rs.getString("username")) && request.getParameter("password").equals(rs.getString("password"))){
              session.setAttribute("username", rs.getString("username"));
              session.setAttribute("firstname", rs.getString("first_name"));
              session.setAttribute("lastname", rs.getString("last_name"));
    }but when you enter invalid information teh session variabe "lastname" for example should read null. Now we want to make a check for this null value, which should look something like this:
    if(session.getAttribute("username").equals(null)){
         response.setStatus(301);
         response.setHeader("Location", "/index.jsp");
    } else {
         response.setStatus(301);
         response.setHeader("Location", "/mainmenu.jsp");
    }But this doesnt work, it just logs in with the null values... any1 got a clue??
    edit: im actually looking for something like the isSet command in PHP to give an idea...
    Message was edited by:
    whappit

    Your test for null will always fail, because request.getParameter("username") is NEVER null, in that it exists, even though it contains no data.
    Try .equals(""); instead.

  • Check for updated file in physical drive and if exists then call procedure?

    hi
    i want to check on local drive in 1 folder if upated file is there and then start my batch process which will load data from that file.
    so how to check if that file is present in location and its upated one
    is there any utiliy in oracle ????
    Reply ASAP

    Use UTL_FILE.FOPEN function with 'r' mode (read text mode). If it fails, then the file does not exist.

Maybe you are looking for

  • Safari 5.1.2 and Java 6 (Latest Downloadable Update)

    There is a compatbility issue with Safari 5.1.2 and the latest version of Java. For some reason when I print out a document on a secured website, the printout is blank, but when I use the previous version of Java, the printouts print out normally. Is

  • BEO Calendar not displaying certain dates

    Hello I'm trying to set up a calender which includes, amongst other dates, 30 November 2009.  However, because November 2009 spans 6 weeks (1st on week 1, 30th on week 6) the 30th is not displayed. Is there any way to overcome this as it will mean th

  • *.pages and *.key cannot be shown on the web page

    I upload an a.KEYNOTE file which is quite alright on my local computer  to the server (3.1.2). After successfully uploading, the web page keeps trying to display the file, but no stopping, just trying. Strangely, the name could be correctly displayed

  • Inactive Items in Organizations and item master

    I suppose user cannot select for those Inactive items in POs. But actually it does. Does anyone know why? Thanks, Amy

  • Creating jar file for entity bean

    I am trying to deploy an entity bean..i compiled all the java files and created a dir by name META_INF and copied ejb-jar.xml and the other two .xml files which are needed to this dir. then using ,ant i tried to create the jar file ,,but it is giving