Wednesday, June 23, 2010

New in 10: Compile-Time Warnings

This will allow you to improve code before it runs live.

"ALTER SESSION" is recommended, as "ALTER SYSTEM" takes too much overhead, or use "ALTER PROCEDURE ... COMPILE."

Find message descriptions by SHOW ERRORS or query User_Errors (PLW-)
CategoryMsg #sExample
Severe5000-5999Aliasing problems with parameters
Informational6000-6249Code that can never run
Performance7000-7249Passing a VARCHAR2 value to a NUMBER column

value_clause::=
{ ENABLE | DISABLE | ERROR* }:
{ All| Severe| Informational| Performance|
{ Integer| (Integer [, Integer ] ...)}}
* 'Error' treats a particular message as an error instead of a warning.

Examples:
Alter Session Set Plsql_Warnings = 
               'Enable:Severe', 'Disable:Informational';
Alter Session Set Plsql_Warnings = 
               'Disable:All';
Alter Session Set Plsql_Warnings = 
               'Disable:5000', 'Enable:5001','Error:5002';
Alter Session Set Plsql_Warnings = 
               'Enable:(5000,5001,5002)','Disable:6000,6001)';
Alter Procedure prog_x Compile Plsql_Warnings=
               'Enable:Performance';
Call Dbms_Warning.Set_Warning_Setting_String
               ('Enable:All' ,'Session');
To see how it's currently set:
BEGIN
DBMS_OUTPUT.PUT_LINE('$$PLSQL_WARNINGS = ' || $$PLSQL_WARNINGS);
END;
/

No comments:

Post a Comment