Use a query parameter to create a dynamic query. When you include a query parameter, your result set varies, depending on the value of the parameter at runtime.
Dynamic queries are useful when you want to perform one of the following tasks:
You can capture the user's choice and pass it from a scene or global parameter to a query parameter, thereby changing the filter for the query results.
You can use a query parameter to specify the threshold for some object property, such as Visibility or Color. Then, at runtime, if the threshold or condition is met, the appearance of the object is changed.
Parameters can provide you with many ways to transform your analysis of data into an intuitive visual display for your users.
The most common way to use a query parameter is to have it supply the contents of a filter. For example, WHERE columnname = :Q_filter. Q_filter is then set to different values. Use the Advanced Query wizard or the Query Diagram view to insert query parameters as filters.
You can also use query parameters to supply:
For example, WHERE :Q_predicate. Q_predicate is then set to different versions of column = value. Use the Query Diagram or Text view to insert these parameters.
For example, FROM :Q_tablename aliasname. Q_tablename is then set to different table names. Use the Text view to insert these parameters. Define the parameter as a literal type and include an alias for the column or table name.
You can create a query parameter in the Advanced Query wizard (click the Define Parameter button) or in the Query Diagram view (right-click the Parameters block and click Define Parameter). To create a query parameter, you name it, specify a data type, and in most cases, specify a default value. You then use the parameter in a query.
To set a query parameter, select the DataTemplaten.QueryParameters object from the Object Inspector list and then edit the value cell for the parameter, as shown below.
You can set a query parameter to a constant, a functional expression, or the value of another parameter, such as a scene or global parameter. For example, to pass information from a scene parameter to a query parameter, you set the value of the query parameter to be equal to that of the scene parameter. For more information on modifying object properties and for information about functional expressions, see Object properties and events.