How to exit the loop in oracle

Sundararaj Thathan picture Sundararaj Thathan · Feb 10, 2016 · Viewed 18k times · Source
Declare
var_cnt       number(3):=0;
begin
    loop
        update t_loan_dtl set loan_closure = 'Y' where rownum <10001;
    end loop;
end;

Answer

vishnu sable picture vishnu sable · Feb 10, 2016
  1. simple exit

    loop --do something; exit; end loop;

  2. conditional exit

    loop --do something; exit when "condition"; end loop;

3.Exit with cursor variable

 exit when v_cursor%notfound;