G-7240: Avoid using an IN OUT parameter as IN or OUT only.

Major

Efficiency, Maintainability

Reason

By showing the mode of parameters, you help the reader. If you do not specify a parameter mode, the default mode is in. Explicitly showing the mode indication of all parameters is a more assertive action than simply taking the default mode. Anyone reviewing the code later will be more confident that you intended the parameter mode to be in / out.

Example (bad)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
create or replace package body employee_up is
   procedure rcv_emp (io_first_name     in out employee.first_name%type
                     ,io_last_name      in out employee.last_name%type 
                     ,io_email          in out employee.email%type 
                     ,io_phone_number   in out employee.phone_number%type
                     ,io_hire_date      in out employee.hire_date%type 
                     ,io_job_id         in out employee.job_id%type
                     ,io_salary         in out employee.salary%type
                     ,io_commission_pct in out employee.commission_pct%type 
                     ,io_manager_id     in out employee.manager_id%type
                     ,io_department_id  in out employee.department_id%type
                     ,in_wait                  integer) is
      l_status pls_integer;
      k_pipe_name constant string(6 char) := 'mypipe';
      k_ok constant pls_integer := 1;
   begin
      -- receive next message and unpack for each column. 
      l_status := sys.dbms_pipe.receive_message(pipename => k_pipe_name
                                               ,timeout  => in_wait);
      if l_status = k_ok then
         sys.dbms_pipe.unpack_message (io_first_name);
         sys.dbms_pipe.unpack_message (io_last_name);
         sys.dbms_pipe.unpack_message (io_email);
         sys.dbms_pipe.unpack_message (io_phone_number);
         sys.dbms_pipe.unpack_message (io_hire_date);
         sys.dbms_pipe.unpack_message (io_job_id);
         sys.dbms_pipe.unpack_message (io_salary);
         sys.dbms_pipe.unpack_message (io_commission_pct);
         sys.dbms_pipe.unpack_message (io_manager_id);
         sys.dbms_pipe.unpack_message (io_department_id);
      end if;
   end rcv_emp;
end employee_up;
/

Example (good)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
create or replace package body employee_up is
   procedure rcv_emp (out_first_name     out employee.first_name%type
                     ,out_last_name      out employee.last_name%type 
                     ,out_email          out employee.email%type 
                     ,out_phone_number   out employee.phone_number%type
                     ,out_hire_date      out employee.hire_date%type 
                     ,out_job_id         out employee.job_id%type
                     ,out_salary         out employee.salary%type
                     ,out_commission_pct out employee.commission_pct%type 
                     ,out_manager_id     out employee.manager_id%type
                     ,out_department_id  out employee.department_id%type
                     ,in_wait            in  integer) is
      l_status pls_integer;
      k_pipe_name constant string(6 char) := 'mypipe';
      k_ok constant pls_integer := 1;
   begin
      -- receive next message and unpack for each column. 
      l_status := sys.dbms_pipe.receive_message(pipename => k_pipe_name
                                               ,timeout  => in_wait);
      if l_status = k_ok then
         sys.dbms_pipe.unpack_message (out_first_name);
         sys.dbms_pipe.unpack_message (out_last_name);
         sys.dbms_pipe.unpack_message (out_email);
         sys.dbms_pipe.unpack_message (out_phone_number);
         sys.dbms_pipe.unpack_message (out_hire_date);
         sys.dbms_pipe.unpack_message (out_job_id);
         sys.dbms_pipe.unpack_message (out_salary);
         sys.dbms_pipe.unpack_message (out_commission_pct);
         sys.dbms_pipe.unpack_message (out_manager_id);
         sys.dbms_pipe.unpack_message (out_department_id);
      end if;
   end rcv_emp;
end employee_up;
/