HomeActive Query Builder - IntroductionDesigning user-friendly query building environmentWorking with Reusable queries

4.3. Working with Reusable queries

The new version of Active Query Builder provides the unique ability to save queries for using them as views in subsequent queries. The user can save a query in the repository that is accessible via the special snippet in the lower right corner of the component. After that he can start to build a new query and drag a saved query to the Design area. This query will appear on the Design area and in the SQL query text by the same way as an ordinary database object, but the programmer will get another SQL text for execution against a database server, in which this object will be expanded to a sub-query (derived table). In this way the user can build multi-level nested sub-queries, i.e. use one reusable query in another, but recursion is not allowed. Substitution of Reusable Query objects for appropriate sub-query texts is performed only when the programmer requests the SQL query text for execution against a database server, so he always gets the latest SQL query text of reusable queries.

The Full-featured demo project is modified to present the new functionality.

To enable end-user to use the saved queries in subsequent work sessions, the programmer has to save the Reusable Queries repository between work sessions. It is possible by means of the QueryBuilder.ReusableQueries import/export methods. It is also needed to switch on the Reusable Queries snippet by setting the QueryBuilder.PanesConfigurationOptions.UserQueriesPaneVisible property to True.

This feature was implemented on the basis of the well-proven mechanism of Virtual Objects. Reusable Queries are saved in the Metadata Container as Metadata Objects of the new type MetadataType.UserQuery. This means that the programmer can implement its own user interface to work with reusable queries instead of the embedded snippet.

This page was: Helpful | Not Helpful