Qualifying PL/SQL code example to improve readability and NOT to invalidate

-- a good example for qualifying
PACKAGE scope_demo
   g_global   NUMBER;

   PROCEDURE set_global (number_in IN NUMBER);
END scope_demo;

PACKAGE BODY scope_demo
   PROCEDURE set_global (number_in IN NUMBER)
      l_salary  NUMBER := 10000;
     l_count   PLS_INTEGER;

         l_inner   PLS_INTEGER;
         SELECT COUNT (*)
           INTO set_global.l_count
           FROM employees e
          WHERE e.department_id = local_block.l_inner
            AND e.salary > set_global.l_salary;
      END local_block;

      scope_demo.g_global := set_global.number_in;
   END set_global;
END scope_demo; 

For a closer look of the advantages of qualifying please check Qualifying All References Thread on Best Practice PL/SQL with Steven Feuerstein of OTN.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s