Parameterizing SQL queries with the JDBC Request TestStep
This recipe builds directly on the last one to show how the JDBC Request TestStep
can be used to execute parameterized SQL queries based on property values from outside the TestStep
. This can be useful, as it allows the JDBC Request TestStep
to query and check data based on properties set from the results of other TestSteps
, for example, executing a query using an ID obtained from a web service response.
How to do it...
First, we add a new parameter with a fixed value to the JDBC Request TestStep
and use it as the criteria for a simple select query. Then, we change the JDBC Request TestStep
parameter to take its value from the value of a TestCase
property. Perform the following steps:
- Edit the
JDBC Request TestStep
from the previous recipe and add a new parameter calledinvoiceIdParam
with a value of2
. - Then, modify the SQL Query value to add a
where
clause to specify that the invoiceid
field must be equal to the value ofinvoiceIdParam...