In the last post we compared the list of databases in the same PostgreSQL cluster using OMrun. The setup for this was pretty simple: We’ve defined the environment using the PostgreSQL Data Adapter and created the connections to two databases. In a new “Test Data Object” we’ve written the SQL statement to list all databases and once the test was executed OMrun compared the results.
This is how it looked like at the end of the previous post:
The select statement we used did not use a where clause, it just lists all the databases. If we want to restrict the result, we can do it like this:
Very simple SQL (of course an in-list with just one value does not make much sense). A potential issue with this is, that we hard code the value(s) into the statement. This is where the parameters come into the game. In OMrun you can define up to four parameters which will get passed into the statement. You can already see that in the lower right section in the screenshot above. Instead of hard coding the value(s), we can define a parameter and pass the parameter into the statement by referencing it with “@param1”:
Our statement has become more dynamic. Passing multiple values by using one parameter is possible as well:
In the same way the remaining parameters can be used, e.g. like this:
Doing it like this, will result in the test to fail, of course. You can even go a step further and use nested parameters:
As you can see, this gives you great flexibility with passing values into your statements.