Toad World® Forums

Code Analysis: Rule 2106 when compiling object for another schema

The following examples are marked with “2106 Avoid unnecessary references to schema names.” but they should not, since the objects are not created for my schema.

CREATE VIEW other_schema.test_view
AS
SELECT *
FROM my_schema.test_table;

CREATE PROCEDURE other_schema.test_proc
AS
v_count PLS_INTEGER;
BEGIN
SELECT COUNT(*)
INTO v_count
FROM my_schema.test_table;
END test_proc;

Having a look at this rule I even wonder how we find out that a reference is “unnecessary”. Supposing we have…

CREATE VIEW my_schema.test_view
AS
SELECT *
FROM my_schema.test_table;

…then it’s easy to find out that my_schema in the FROM clause is redundant.

Do you feel that we should amend the logic this way? (i.e. look at the schema where the unit is created)

Yes, I think it’s okay to check against the schema where the object is created.

If no schema is provided explicitly, then this is the current user:

CREATE VIEW test_view
AS
SELECT *
FROM my_schema.test_table;

We decided to yank this rule due to too context dependent. As of QP5 version 5.316 it will no longer be listed.

Thanks,
Andre