The Professional version of Active Query Builder provides the unique ability to save end-user queries for using them as views in subsequent queries. The user can save a query as Reusable Query via the special snippet in the lower right corner of the component. After that he can start building a new query and then use the saved query in a new one. The Reusable Query will appear the same way as an ordinary database object in the component's UI as well as in the SQL query text, but it will be substituted for containing SQL text upon execution against the database server. Reusable Queries are linked, not embedded, so the substitution is performed right before the execution against a database server. This means that if Reusable Query is changed, the linked query gets the latest SQL query text of Reusable Query. This way the user can create multi-level nested queries, and work with each query independently from linked queries.

You can try this feature and get code samples using the Full-featured demo project in Professional and Trial versions. The QueryBuilder.PanesConfigurationOptions.UserQueriesPaneVisible property switches the Reusable Queries snippet on and off.

To save Reusable Queries between work sessions, the programmer has to save the Reusable Queries repository using the QueryBuilder.ReusableQueries import/export methods.

This feature was implemented on the basis of the well-proven mechanism of Virtual Objects. Reusable Queries are stored in the Metadata Container as objects of the new type MetadataType.UserQuery, so they can be accessed programmatically. Nothing stops the programmer from implementing its own user interface to work with reusable queries instead of the embedded snippet.

Is this article helpful for you?