views:

22

answers:

1

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 any advice.

+2  A: 

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;
Tony Andrews
So unlike MS SQL Server, you don't get warnings/information messages back at runtime, only errors?
tuseau
Pretty much. If you are in SQL Plus then you will see "messages" like "5 rows selected" and "PL/SQL procedure successfully completed." but these are coming from the SQL Plus application itself, not from the database.
Tony Andrews
Thanks, that helps a lot.
tuseau
There are "Compile-type warnings" when compiling PL/SQL objects (such as triggers and functions), but you shouldn't encounter them during a run. http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/errors.htm#sthref2089
Gary

related questions