Parameters and variables in queries
Our recent work on Sutoiku Activities outlined the need for query variables. Following some internal discussions, we also realized that we should add support for query parameters as well. Both apply to the values of query filters (account.country equals "France"), but they address two different sets of requirements.
Query Parameters
Query parameters allow the value of a query filter to be set by the user when a query is executed. To define a query parameter from the query builder, simply check the “Query parameter” checkbox in a given query filter. When doing so, the placeholder for the query value goes from “Enter value” to “Enter default value”, the latter being optional.
When a query parameter is defined, a corresponding input field is displayed underneath the query name in the query selector box. When the query is selected, default filter values are automatically populated, and the user can set the values of any query parameter, then click on the “Run” button to refresh the Object View.
Query Variables
Query variables allow the value of a query filter to be dynamically set when a query is executed. To use a query variable as value of a query filter, simply add the dollar sign ($) as prefix to a variable’s name. The variable must be within the query engine’s scope in order to be properly evaluated at runtime.