In Active Query Builder for .NET 2.0 and in Active Query Builder VCL Edition it is possible to modify text of sub-query independently of the main query. The UnionSubQuery.SQL and SubQuery.SQL properties can be used to read and write sub-query SQL text.
Working in the sub-query editing mode, the programmer should assign the user edited query text to the PlainTextSQLBuilder.SQL property as it's always mapped to the active sub-query in this mode. And use the PlainTextSQLBuilder.SQLUpdated event to update the text editor as this event is fired not only when the query is changed in the Query Builder but also when the active sub-query is changed.
Another option is to let the PlainTextSQLBuilder retrieve the formatted text of the currently active sub-query. Using it the user is able to view and edit the currently active sub-query as an independent query and easily get back to the main query when sub-query text editing is finished.
There are two variants of sub-query editing mode: editing single union sub-queries or editing sets of sub-queries with unions. I.e. if a sub-query contains unions, the user will edit each union sub-query independently in the first case and the whole set of union sub-queries in the second case. Thus the possible values of the PlainTextSQLBuilder.TargetQueryPart property that turn on this mode are the following:
- Query (default) – instructs to generate SQL text for the whole query;
- SubQuery – instructs to generate SQL text for the currently active sub-query with unions;
- UnionSubQuery – instructs to generate SQL text for the currently active union sub-query.
The "Show Query By Parts" demo project illustrates this functionality.
Customer support service by UserEcho