Reputation: 1237
I have a question about jdbc in jmeter, I have a value (employee), that I want to check if it exists in a list. i try to perform a query to DB and to use var.get function, is it possible? it only worked when I use ${value}. is it possible to use var.get?
in the test I try to perform call and check if employee exists in test_case_string_employee.
select count (*)
from employee
where CreatedAtDate ='today'
and employee IN ${test_case_string_employee};
the code is working. but can I change what is after the "IN"?
I tried
IN 'vars.get("test_case_string_employee")';
and
IN vars.get("test_case_string_employee");
and got exceptions regards
Upvotes: 0
Views: 388
Reputation: 168122
As per Functions and Variables documentation chapter:
Variables are referenced as follows:
${VARIABLE}
As per SQL IN Operator tutorial your query seems to be missing parentheses and quotation marks
So my expectation is that you need to amend your query like:
select count (*)
from employee
where CreatedAtDate ='today'
and employee IN ('${test_case_string_employee}');
If you prefer vars
shorthand you can do the same using __groovy() function like:
select count (*)
from employee
where CreatedAtDate ='today'
and employee IN ('${__groovy(vars.get('test_case_string_employee'),)}');
however it might be an overkill for particularly this scenario.
Upvotes: 0
Reputation: 34536
vars.get only works in scripting elements (jsr223, beanshell).
In other test elements, you need to use:
${}
Upvotes: 1