Compiling a PLSQL Block with Warnings Enabled May Result in an Unexpected PLW-06002: Unreachable code Error (Doc ID 1300843.1)

Last updated on MARCH 03, 2011

Applies to:

PL/SQL - Version: 11.1.0.7 and later   [Release: 11.1 and later ]
Information in this document applies to any platform.

Symptoms


Compiling a PLSQL code block may return an unexpected PLW-06002 on a line of code that is reachable.

For example, the following code returns a warning with versions prior to 11.2.0.2.0:

Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

ALTER SESSION SET PLSQL_WARNINGS = 'ENABLE:ALL';

CREATE OR REPLACE PROCEDURE test_warnings(b_test IN BOOLEAN) AS
BEGIN
  IF b_test THEN
    DBMS_OUTPUT.PUT_LINE('True');
  ELSIF NOT b_test THEN
    DBMS_OUTPUT.PUT_LINE('False');
  ELSE
    DBMS_OUTPUT.PUT_LINE('Null');
  END IF;
END;
/

SP2-0804: Procedure created with compilation warnings

SQL> show errors
Errors for PROCEDURE TEST_WARNINGS:

LINE/COL ERROR
-------- -----------------------------------------------------------------
1/1 PLW-05018: unit TEST_WARNINGS omitted optional AUTHID clause;
default value DEFINER used

5/9 PLW-06002: Unreachable code

Changes

Turned on PLSQL warnings

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms