Debug: is it my imagination?

ScottMattes

Member³
I am stepping thru the following

for i in my_collection.first..my_collection.last
loop
my_var := my_collection( i ).my_var;
end loop;

and I see the following in the watch area

i = 105 (105 entries are in my_collection)
my_collection( i ).my_var = 'something'
my_var = 'something different'

yipes!!!!!!!!!
 
Could it be that you haven't executed the assignment statement yet? my_var should be the same as my_collection(i).my_var after the statement has been executed.

Just a thought on sunday morning ;-)

regards,
Patrick
 
When you are on the line with the assignment, it is not yet executed. After the next step you will be back on the line with the "for" statement, and my_var and my_collection(i).my_var should be the same.
 
I just got curious and built a test procedure:


Code:
create or replace procedure test is
  type record_type is record(my_var varchar2(10));
  type record_table_type is table of record_type index by pls_integer;
  my_collection record_table_type;
  my_record record_type;
  my_var varchar2(10);
begin
  select 'a' into my_record from dual;
  my_collection(1) := my_record;
  select 'b' into my_record from dual;
  my_collection(2) := my_record;
  select 'c' into my_record from dual;
  my_collection(3) := my_record;

  for i in my_collection.first .. my_collection.last loop
    my_var := my_collection(i).my_var;
  end loop;
end test;
In my case, the watches for my_var and my_collection(i).my_var displays the same result after the assignment, i.e. when the current line is back at the for loop.

So either my test case is not comparable to yours or the environment are different. I'm using PL/SQL Developer 6.0.5 against an 9.2.0.3 database.

Bo Pedersen
 
Marco,
The variable 'i' is one of the watches and it stays at the max count of records in the collection (in my case that was 115).
 
That can't be right. Could it be that i is an implicit variable that is used in multiple for loops in this program unit?
 
Hmmm, 'i' is implicit and it is used in multiple loops.

Does the Oracle Debug API not handle implicit variables like this 'correctly'?
 
This doesn't always seem to work okay. If you use implicit variables with a unique name (within the scope of the program unit) this will work fine.
 
Back
Top