/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ module com { module sun { module star { module sdb { /** simplifies the composing of single select statements.
The interface can be used for composing single SELECT statements without knowing the structure of the used query.
@see com::sun::star::sdb::SingleSelectQueryComposer */ interface XSingleSelectQueryComposer: XSingleSelectQueryAnalyzer { // FILTER /** makes it possible to set a filter condition for the query. @param filter the filter to set @throws com::sun::star::sdbc::SQLException if a database access error occurs or the statement isn't valid or the statement isn't parsable. */ void setFilter([in] string filter) raises (com::sun::star::sdbc::SQLException); /** appends a new set of filter criteria which is split into levels. @param filter The filter criteria is split into levels. Each level represents the OR criteria. Within each level, the filters are provided as an AND criteria with the name of the column and the filter condition. The filter condition is of type string. The operator used, is defined by com::sun::star::sdb::SQLFilterOperator. @throws com::sun::star::sdbc::SQLException if a database access error occurs. */ void setStructuredFilter([in] sequence< sequenceAn elementary query or statement is a (single select) statement whose parts are not covered by the various set and get methods of the composer. That is, if the elementary statement contains a filter clause, a call to XSingleSelectQueryAnalyzer::getFilter() will not return you this filter. Instead, only filters which have been set using for instance setFilter() are covered by the get methods.
The only methods which take all parts of the elementary statement into account are XSingleSelectQueryAnalyzer::getQuery() and XSingleSelectQueryAnalyzer::getQueryWithSubstitution(), which always returns the complete composed query.
As a result, you can use the composer to build cumulative filter expressions. That is, you can set #ElementaryQuery to a statement already containing filters, and then use setFilter() to append additional filters.
The very same holds for sort orders, HAVING
and GROUP BY
clauses.
There are various use cases for this. For instance, you might want to use the statement represented by a QueryDefinition, and extend it with additional filters or sort orders, while not touching the respective parts already present in QueryDefinition::Command. This can be achieved by setting the QueryDefinition::Command as #ElementaryQuery of a SingleSelectQueryComposer.
If, in such a scenario, you would be interested in the filter part of the QueryDefinition::Command, you would set it via XSingleSelectQueryAnalyzer::setQuery(), and retrieve the filter part via XSingleSelectQueryAnalyzer::getFilter().
If you'd be interested in the composed filter, you would set the QueryDefinition::Command as #ElementaryQuery, add your filter, and propagate the resulting query (XSingleSelectQueryAnalyzer::getQuery()) to an SingleSelectQueryAnalyzer instance via XSingleSelectQueryAnalyzer::setQuery().
*/ [attribute] string ElementaryQuery { set raises (com::sun::star::sdbc::SQLException); }; }; }; }; }; }; /* vim:set shiftwidth=4 softtabstop=4 expandtab: */