I basically have this structure - How to implement nested loop in jmeter?.
The outer loop works as it should. In my case, the outer loop executes 3 times and executes a SQL query each time.
The inner loop executions are based on the # of rows a query returns, so if the first query returns 10 rows, the inner loop execute 10 times. This works great for the 1st outer and inner loop execution. The problem is that the JMeter Counter object in the inner loop does not reset for the second query.
In other words, if the second query in the outer loop returned 5 rows of data, the Counter is still going to count from 1 to 10 based on the first query. Even worse, when it gets to the inner loop of the 3rd query, it's going to start at 6 and continue counting up to 10, then start all over again at 1.
The JMeter inner Loop Controller picks up the new count value and executes the correct number of times, but the query result data is written to a new DB based on an index # (i.e. 1 to #_of_records) so without this index #, I can't properly write out this data. Where p_cnt_tq below is the index # I referred to -
INSERT INTO TopQuery (Id,Database_name,Schema_name,sqltext,total,avg_duration,max_duration,avg_reads,max_reads,avg_writes,max_writes,avg_CPU_time,max_CPU_time) VALUES ("${p_max_id_1}","${_V(P_DbName${p_cnt_tq})}","${_V(P_SchemaName${p_cnt_tq})}","${_V(P_SqlText${p_cnt_tq})}","${_V(P_ExecCount${p_cnt_tq})}","${_V(P_AvgDuration${p_cnt_tq})}","${_V(P_MaxDuration${p_cnt_tq})}","${_V(P_AvgReads${p_cnt_tq})}","${_V(P_MaxReads${p_cnt_tq})}","${_V(P_AvgWrites${p_cnt_tq})}","${_V(P_MaxWrites${p_cnt_tq})}","${_V(P_AvgCpuTime${p_cnt_tq})}","${_V(P_MaxCpuTime${p_cnt_tq})}");
While this seems like it would be ridiculously easy to fix, I have not found a way to create a counter inside the inner loop that counts from 1 to the #_of_rows returned from each outer loop. Has anyone else run across and solved this puzzle?
