Andrew Chichick
Andrew Chichick

Reputation: 89

JMeter JDBC - use one row from the table per one test execution

I use JDBC request for selecting data from the SQL table and use it in a test. In order to get a value from a table and insert into request I use ForEach controller

enter image description here

But when test runs the controller gets all values from the table in one test and executes the transaction that number of times that table has values.

enter image description here

How can I use only one value per test and execute the transaction only once per test? When I don't use ForEach controller the variable doesn't use as well and I see in the request only variable name: ${variable}

My Debug Sampler picture. Variable name is changed.

enter image description here

Upvotes: 1

Views: 516

Answers (1)

Dmitri T
Dmitri T

Reputation: 168197

Use Debug Sampler and View Results Tree listener combination in order to inspect the variables produced by the JDBC Request sampler, this way you will be able to choose the variable holding the "interesting" value.

The variables are generated using the following pattern:

variable_1=value from 1st row
variable_2=value from 2nd row
...
variable_#=number of rows returned by your query

See Debugging JDBC Sampler Results in JMeter article for more details.

So if you want to use the value from first row - use ${variable_1}, from 2nd row - ${variable_2}, if you want a random value - go for __V() and __Random() functions combination like ${__V(variable_${__Random(1,${variable_#},)},)}. if you want something else - show the output of the Debug Sampler with your "variables" and indicate how you would like to re-use them in the next request(s)

Upvotes: 1

Related Questions