Code Analysis: Unused variable not identified in special case

Removing test1 leads to successful identification of the unused variable.

BTW: The type is marked with “Rule 2831 - Use PLS_INTEGER instead of INTEGER or equivalent subtypes.”, but PLS_INTEGER is not valid for a type.

CREATE OR REPLACE TYPE my_tab AS TABLE OF NUMBER(1);

DECLARE
PROCEDURE test1 AS
BEGIN
IF( NULL MEMBER OF NEW my_tab() ) THEN
NULL;
END IF;
END test1;

PROCEDURE test2 AS
unused_variable PLS_INTEGER;
BEGIN
NULL;
END test2;
BEGIN
NULL;
END;

PLS_INTEGER is a PL/SQL-only type so probably it shouldn’t appear in a create nested table type statement. It’s strange however that Oracle compiles the CREATE statement (line 1) while rejecting it in procedure test1 (PLS-00905: object CXRULES.MY_TAB is invalid … ORA-06550: … PL/SQL: Statement ignored).

Would suppressing hits in case of nested tables help?

(QP-1725)

Not sure if I understand, if I try to compile the first line with PLS_INTEGER (CREATE OR REPLACE TYPE my_tab AS TABLE OF PLS_INTEGER;) I get the following error as expected:
[Error] PLS-00531 (1: 25): PLS-00531: Unsupported type in a VARRAY or TABLE type: ‘PLS_INTEGER’.

Suppressing this warning for all DDL statements (like CREATE TABLE a ( b NUMBER(1) ):wink: should help.

Did you also have a look at the unused variable? Thanks!

You’re right of course. My bad, Oracle won’t compile first line with PLS_INTEGER and must not have noticed the error message.

Unused variable: are you referring to your other post http://www.toadworld.com/products/toad-for-oracle/toad_for_oracle_beta_program/f/86/t/31085 ?

No, I’m referring to this post. PLS_INTEGER was a bonus, but the example in my initial post shows code that does not detect an unused variable:

DECLARE
PROCEDURE test1 AS
BEGIN
IF( NULL MEMBER OF NEW my_tab() ) THEN
NULL;
END IF;
END test1;

PROCEDURE test2 AS
unused_variable PLS_INTEGER;
BEGIN
NULL;
END test2;
BEGIN
NULL;
END;