DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: NO_DATA_FOUND Exception

  1. #1
    Join Date
    Dec 1999
    Location
    Alpharetta, GA, US
    Posts
    192
    I would like to know how do i proceed if i would get the NO_DATA_FOUND exception in Stored Procedure.
    In my case i need to do some select, insert's if i got this
    exception.

    Thanks

  2. #2
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    hi,

    Step 1:
    DECLARE
    lv_get_sal NUMBER;
    BEGIN
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    END;

    in case 2 the foucus will goto the exception inside the block
    Step 2:
    DECLARE
    lv_get_sal NUMBER;
    BEGIN
    BEGIN
    SELECT COUNT(*) INTO lv_get_sal FROM emp
    WHERE......;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    CONDITION......;
    END;
    END;
    Cheers!
    OraKid.

  3. #3
    Join Date
    Sep 2000
    Location
    Sao Paulo,SP,Brazil, Earth, Milky Way
    Posts
    350
    Beware, the given fragment have an error :

    BEGIN
    SELECT COUNT(*) INTO lv_get_sal FROM emp
    WHERE......;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    CONDITION......;
    END;

    ===>> the COUNT function NEVER fires a WHEN NO_DATA_FOUND, it only give you ZERO as result if any data was found, either in SQL or PL/SQL :

    SQL> select count(*) from dual where 1=2;

    COUNT(*)
    ---------
    0


    Regards,

    Chiappa



  4. #4
    Join Date
    Mar 2001
    Location
    Reading, U.K
    Posts
    598
    ya!
    iam sorry
    Cheers!
    OraKid.

Posting Permissions

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


Click Here to Expand Forum to Full Width