Reputation: 2282
In my JMeter test plan one of the JDBC sampler returns multiple values named clusterCode
. Now i want to use this values in the next JDBC request like select userID from users where clusterCode in ('foo1','foo2','foo3');
.
Currently I am using JSR223 sampler
inside of ForEach controller of JMeter to append all the clusterCodes
to a string. It is working correctly. But with this method number of JSR223 sampler request count is very high, and it is also taking a lot of time with higher number of users. Is there a better way to achieve this goal?
Upvotes: 0
Views: 1255
Reputation: 2282
Found the solution. I had tried to use JSR223 post-processor
, but my implementation was wrong. I have got it working now. Following is the code:
var strClusterCodes1= "'" + vars.get("clusterCodes_1") + "',";
var msglength = vars.get("clusterCodes_#");
for (var position = 0; position < msglength; position++) {
strClusterCodes1 += "'" + vars.get("clusterCodes_" + msglength) + "',";
}
strClusterCodes1 =strClusterCodes1.substring(0,strClusterCodes1.lastIndexOf(","))
vars.put("strClusterCodes",strClusterCodes1);
So, I find the number of elements in the array result with clusterCodes_#
and append all the elements of the array with for loop to a string. And my work is done by a single JSR223 post-processor
.
Upvotes: 1