Differentiate between Oracle error and warning messages
I am wondering if there is a way to differentiate between warning messages and error messages in Oracle? Does a Warning message count as an exception? Are warning just errors? Is there a clear difference? And if so, is there a way to catch warning messages explicitly, or information messages?
Thanks for an开发者_如何转开发y advice.
Oracle itself doesn't raise warning or information messages, only exceptions for error messages. However it does have some information that you can interrogate in PL/SQL such as:
SQL%ROWCOUNT:
update emp
set sal = sal+1000
where depno = 10;
if sql%rowcount = 0 then
-- no rows got updated
...
cursor%NOTFOUND:
loop
fetch mycursor into myvar;
exit when mycursor%notfound;
end loop;
精彩评论