In the Database block you can use variables to compose the query that you want to execute when the test case is running. This allows you to e.g. call a Stored Procedure with the data that is produced as part of the test flow.

In some cases it is interesting to also add the columns that should be returned as variables in the building block. E.g. based on some condition, you want either the first name or the last name of a person, and in any case you want to continue with the same flow just using the name value from the database. In this case we can’t connect the value from the property to the rest of the flow, if the property is dynamically changing between “firstname” and “lastname”. We can handle this using aliases as described below.

In the example below we have specified ‘FirstName’ as the column to be returned. This will add a FirstName property to the Database block which will give access to the values in the FirstName column returned.

But what if we want a “Name” property returning the value of either the FirstName or the LastName column?

Well, we are not allowed to use the Refresh function if we add any [Fields] in the query field, so we need to prepare a bit before adding the field. We add an alias to the FirstName column by appending “as Name” in the query. This will give us the following result after pressing Refresh:

Now we have the structure in place and can now use [FIELDS] in the Query field to add the dynamic selection of columns. In the example below the ‘FirstName’ column in the query has been replaced by a FIELD allowing us to specify exactly which column should be returned in the query. No matter what column is returned, the value can be accessed using the “Name” connector/property on the database block.