That's how to do it (in this example, a divide by zero - exception is caught):
Code:
begin
for i in 1..10 loop
begin
dbms_output.put_line('i | i / (i - 5):' || i || '|' || i / (i - 5));
exception
when ZERO_DIVIDE then dbms_output.put_line ('This Line from exception handler') ;continue;
when others then dbms_output.put_line('Error: ' || SQLCODE || ' ' || SQLERRM); exit;
end;
end loop;
end;
/
Output:
Code:
i | i / (i - 5):1|-,25
i | i / (i - 5):2|-,6666666666666666666666666666666666666667
i | i / (i - 5):3|-1,5
i | i / (i - 5):4|-4
This Line from exception handler
i | i / (i - 5):6|6
i | i / (i - 5):7|3,5
i | i / (i - 5):8|2,66666666666666666666666666666666666667
i | i / (i - 5):9|2,25
i | i / (i - 5):10|2