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

Thread: Sql%notfound

Threaded View

  1. #7
    Join Date
    Dec 2000
    Location
    Ljubljana, Slovenia
    Posts
    4,439
    Originally posted by cleggfr
    Thats what I thought - but if I put the IF statement inside the cursor I get no output at all??:

    for rec in c2 loop
    delete from stats$database_instance where snap_id=rec.snap_id;
    if SQL%NOTFOUND then
    dbms_output.put_line('No hanging SQL to delete');
    else
    dbms_output.put_line('Hanging data deleted');
    end if;
    end loop;
    commit;
    Change your SQL%NOTFOUND into c2%NOTFOUND inside the cursor for-loop.

    But if your cursor doesn't return any rows then the body of the loop will never be executed, hence you still won't get any output .

    In your case, I would do something like:
    Code:
    DECLARE
      ....
      v_found BOOLEAN := FALSE;
    BEGIN
      ...
      for rec in c2 loop
        v_found := TRUE;
        delete from stats$database_instance where snap_id=rec.snap_id;
      end loop;
      if v_found then
        dbms_output.put_line('Hanging data deleted');
      else
        dbms_output.put_line('No hanging SQL to delete');
      end if;
      commit;
      ....
    END;
    Last edited by jmodic; 01-07-2003 at 10:01 AM.
    Jurij Modic
    ASCII a stupid question, get a stupid ANSI
    24 hours in a day .... 24 beer in a case .... coincidence?

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