{"id":1536,"date":"2011-10-19T08:34:11","date_gmt":"2011-10-19T13:34:11","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=1536"},"modified":"2011-10-19T08:34:11","modified_gmt":"2011-10-19T13:34:11","slug":"11g-compiler-warnings","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2011\/10\/19\/11g-compiler-warnings\/","title":{"rendered":"11g compiler warnings"},"content":{"rendered":"<p>The PL\/SQL compiler warnings have been enhanced in 11.2.0.1 and up to include a warning for the dreaded &#8220;when others then null&#8221; exception handler.  Actually, the warning is raised any time an &#8220;others&#8221; is handled (even if it is logged somewhere), and not re-raised.<\/p>\n<p>See below for an example.<\/p>\n<pre lang=\"plsql\" line=\"1\">\r\nSQL> show parameter warn\r\n\r\nNAME                                 TYPE        VALUE\r\n------------------------------------ ----------- ------------------------------\r\nlicense_sessions_warning             integer     0\r\nplsql_warnings                       string      DISABLE:ALL\r\nSQL> alter session set plsql_warnings = 'ENABLE:ALL';\r\n\r\nSession altered.\r\n\r\nSQL> create or replace procedure foo is\r\n  2    l number;\r\n  3  begin\r\n  4    begin\r\n  5      l := 'a';\r\n  6    exception\r\n  7      when others then\r\n  8        null;\r\n  9    end;\r\n 10    null;\r\n 11  exception\r\n 12    when others then\r\n 13      dbms_output.put_line(sqlerrm);\r\n 14      raise;\r\n 15  end;\r\n 16  \/\r\n\r\nSP2-0804: Procedure created with compilation warnings\r\n\r\nSQL> show err\r\nErrors for PROCEDURE FOO:\r\n\r\nLINE\/COL ERROR\r\n-------- -----------------------------------------------------------------\r\n1\/1      PLW-05018: unit FOO omitted optional AUTHID clause; default value\r\n         DEFINER used\r\n\r\n5\/5      PLW-07206: analysis suggests that the assignment to 'L' may be\r\n         unnecessary\r\n\r\n7\/10     PLW-06009: procedure \"FOO\" OTHERS handler does not end in RAISE\r\n         or RAISE_APPLICATION_ERROR\r\n\r\nSQL>\r\n<\/pre>\n<p>The risk in not re-raising the exception is that the executing call never knows an exception occurred in that block.  When it comes to an &#8220;others&#8221; exception, that is simply too much risk in an application, since by definition, you have no idea what happened.  You should know what exceptions  to expect, and handle them.  Anything else means you didn&#8217;t think of it, so you don&#8217;t really have a good reason to just ignore it (since you didn&#8217;t even think of it in the first place).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The PL\/SQL compiler warnings have been enhanced in 11.2.0.1 and up to include a warning for the dreaded &#8220;when others then null&#8221; exception handler. Actually, the warning is raised any time an &#8220;others&#8221; is handled (even if it is logged&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2011\/10\/19\/11g-compiler-warnings\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,22,29],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1536"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=1536"}],"version-history":[{"count":5,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1536\/revisions"}],"predecessor-version":[{"id":1624,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/1536\/revisions\/1624"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=1536"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=1536"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=1536"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}