title: Oracle nocopy method
body: <p>I create an Oracle block for checking the effects of using nocopy on associative arrays; create an array with 1000000 elements and pass it as an argument to two identical methods, the first time as an in out parameter and the second one as an in out nocopy. The code is shown below:</p>
  
  <pre><code>declare
  type my_type is table of varchar2(32767) index by binary_integer;
  my_array my_type;
  st number;
  rt number;
  procedure in_out(m1 in out my_type)
  is
  begin
  dbms_output.put_line(my_array(1));
  end in_out;
  procedure in_out_nocopy(m1  in out nocopy my_type)
  is
  begin
  dbms_output.put_line(my_array(1));
  end in_out_nocopy;
  begin
  for i in 1..999999 loop
    my_array(i) := '123456789012345678901234567890123456789012345678901234567890abcd';
  end loop;
  st := dbms_utility.get_time;
  in_out(my_array);
  rt := (dbms_utility.get_time - st)/100;
  dbms_output.put_line('Time needed for in out is: ' || rt || ' 100''ths of second!');
  st := dbms_utility.get_time;
  in_out_nocopy(my_array);
  rt := (dbms_utility.get_time - st)/100;
  dbms_output.put_line('Time needed for in out nocopy is: ' || rt || ' 100''ths of second!');
  end;
  </code></pre>
  
  <p>Now this will report that the nocopy method did better by .27 seconds. I am puzzled by two things:</p>
  
  <p>i) If I change the body of both methods to </p>
  
  <pre><code>begin
  null;
  end; 
  </code></pre>
  
  <p>no time difference will be noted, however the difference in the passing of parameters still exists. Why does that happen?</p>
  
  <p>ii) If I keep the procedure bodies as</p>
  
  <pre><code>begin
  null;
  end;
  </code></pre>
  
  <p>and this time rather than defining the parameter as in out and in out nocopy, I define it as out and out nocopy I do get a time difference. I thought out parameters are re-initialised anyway, so why am I getting a time difference here and not in the in out case?</p>
  
  <p>Regards,
  Christos</p>