1*d1766043SAndrew Rist/**************************************************************
2*d1766043SAndrew Rist *
3*d1766043SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*d1766043SAndrew Rist * or more contributor license agreements.  See the NOTICE file
5*d1766043SAndrew Rist * distributed with this work for additional information
6*d1766043SAndrew Rist * regarding copyright ownership.  The ASF licenses this file
7*d1766043SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*d1766043SAndrew Rist * "License"); you may not use this file except in compliance
9*d1766043SAndrew Rist * with the License.  You may obtain a copy of the License at
10*d1766043SAndrew Rist *
11*d1766043SAndrew Rist *   http://www.apache.org/licenses/LICENSE-2.0
12*d1766043SAndrew Rist *
13*d1766043SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*d1766043SAndrew Rist * software distributed under the License is distributed on an
15*d1766043SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*d1766043SAndrew Rist * KIND, either express or implied.  See the License for the
17*d1766043SAndrew Rist * specific language governing permissions and limitations
18*d1766043SAndrew Rist * under the License.
19*d1766043SAndrew Rist *
20*d1766043SAndrew Rist *************************************************************/
21*d1766043SAndrew Rist
22*d1766043SAndrew Rist
23cdf0e10cSrcweir#ifndef __com_sun_star_sdb_XSingleSelectQueryComposer_idl__
24cdf0e10cSrcweir#define __com_sun_star_sdb_XSingleSelectQueryComposer_idl__
25cdf0e10cSrcweir
26cdf0e10cSrcweir#ifndef __com_sun_star_beans_XPropertySet_idl__
27cdf0e10cSrcweir#include <com/sun/star/beans/XPropertySet.idl>
28cdf0e10cSrcweir#endif
29cdf0e10cSrcweir
30cdf0e10cSrcweir#ifndef __com_sun_star_beans_PropertyValue_idl__
31cdf0e10cSrcweir#include <com/sun/star/beans/PropertyValue.idl>
32cdf0e10cSrcweir#endif
33cdf0e10cSrcweir
34cdf0e10cSrcweir#ifndef __com_sun_star_sdbc_SQLException_idl__
35cdf0e10cSrcweir#include <com/sun/star/sdbc/SQLException.idl>
36cdf0e10cSrcweir#endif
37cdf0e10cSrcweir
38cdf0e10cSrcweir#ifndef __com_sun_star_sdb_XSingleSelectQueryAnalyzer_idl__
39cdf0e10cSrcweir#include <com/sun/star/sdb/XSingleSelectQueryAnalyzer.idl>
40cdf0e10cSrcweir#endif
41cdf0e10cSrcweir
42cdf0e10cSrcweir//=============================================================================
43cdf0e10cSrcweir
44cdf0e10cSrcweir module com {  module sun {  module star {  module sdb {
45cdf0e10cSrcweir
46cdf0e10cSrcweir//=============================================================================
47cdf0e10cSrcweir
48cdf0e10cSrcweir/** simplifies the composing of single select statements.
49cdf0e10cSrcweir
50cdf0e10cSrcweir    <p>
51cdf0e10cSrcweir    The interface can be used for composing single SELECT statements without knowing the
52cdf0e10cSrcweir    structure of the used query.
53cdf0e10cSrcweir    </p>
54cdf0e10cSrcweir
55cdf0e10cSrcweir    @see com::sun::star::sdb::SingleSelectQueryComposer
56cdf0e10cSrcweir */
57cdf0e10cSrcweirpublished interface XSingleSelectQueryComposer: XSingleSelectQueryAnalyzer
58cdf0e10cSrcweir{
59cdf0e10cSrcweir    //-------------------------------------------------------------------------
60cdf0e10cSrcweir    // FILTER
61cdf0e10cSrcweir    //-------------------------------------------------------------------------
62cdf0e10cSrcweir
63cdf0e10cSrcweir    /** makes it possible to set a filter condition	for the query.
64cdf0e10cSrcweir        @param filter
65cdf0e10cSrcweir            the filter to set
66cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
67cdf0e10cSrcweir            if a database access error occurs
68cdf0e10cSrcweir            or the statement isn't valid
69cdf0e10cSrcweir            or the statement isn't parseable.
70cdf0e10cSrcweir     */
71cdf0e10cSrcweir    void setFilter([in] string filter)
72cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
73cdf0e10cSrcweir    //-------------------------------------------------------------------------
74cdf0e10cSrcweir
75cdf0e10cSrcweir    /** appends a new set of filter criteria which is split into levels.
76cdf0e10cSrcweir        @param filter
77cdf0e10cSrcweir            The filter criteria is split into levels. Each level represents the
78cdf0e10cSrcweir            OR criterias. Within each level, the filters are provided as an AND criteria
79cdf0e10cSrcweir            with the name of the column and the filter condition. The filter condition
80cdf0e10cSrcweir            is of type string. The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
81cdf0e10cSrcweir
82cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
83cdf0e10cSrcweir            if a database access error occurs.
84cdf0e10cSrcweir     */
85cdf0e10cSrcweir    void setStructuredFilter([in] sequence< sequence<com::sun::star::beans::PropertyValue> > filter)
86cdf0e10cSrcweir        raises (com::sun::star::sdbc::SQLException,com::sun::star::lang::IllegalArgumentException);
87cdf0e10cSrcweir    //-------------------------------------------------------------------------
88cdf0e10cSrcweir
89cdf0e10cSrcweir    /** appends a new filter condition by a
90cdf0e10cSrcweir        <type scope="com::sun::star::sdb">DataColumn</type>
91cdf0e10cSrcweir        providing the name and the value for the filter.
92cdf0e10cSrcweir        The value property must be supported by the <type scope="com::sun::star::sdb">DataColumn</type>.
93cdf0e10cSrcweir        @param column
94cdf0e10cSrcweir            the column which is used to create a filter
95cdf0e10cSrcweir        @param	andCriteria
96cdf0e10cSrcweir            If <TRUE/> the filter condition will be appended as an AND condition, otherwise
97cdf0e10cSrcweir            the new filter condition will be appended as OR criteria.
98cdf0e10cSrcweir            E.g. (xx AND bb AND cc) OR newCriteria
99cdf0e10cSrcweir        @param  filterOperator
100cdf0e10cSrcweir            The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
101cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
102cdf0e10cSrcweir            if a database access error occurs.
103cdf0e10cSrcweir     */
104cdf0e10cSrcweir    void appendFilterByColumn([in] com::sun::star::beans::XPropertySet column,[in] boolean andCriteria,[in] long filterOperator)
105cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
106cdf0e10cSrcweir
107cdf0e10cSrcweir    //-------------------------------------------------------------------------
108cdf0e10cSrcweir    // GROUP BY
109cdf0e10cSrcweir    //-------------------------------------------------------------------------
110cdf0e10cSrcweir
111cdf0e10cSrcweir
112cdf0e10cSrcweir    /** makes it possibile to set a group for the query.
113cdf0e10cSrcweir        @param group
114cdf0e10cSrcweir            the group part to set
115cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
116cdf0e10cSrcweir            if a database access error occurs
117cdf0e10cSrcweir            or the statement isn't valid
118cdf0e10cSrcweir            or the statement isn't parseable..
119cdf0e10cSrcweir     */
120cdf0e10cSrcweir    void setGroup([in] string group)
121cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
122cdf0e10cSrcweir
123cdf0e10cSrcweir    //-------------------------------------------------------------------------
124cdf0e10cSrcweir
125cdf0e10cSrcweir    /** appends an additional part to the group criteria of the select
126cdf0e10cSrcweir        statement. The column must be a <type scope="com::sun::star::sdbcx">Column</type>.
127cdf0e10cSrcweir        @param column
128cdf0e10cSrcweir            the column which is used to create a group part
129cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
130cdf0e10cSrcweir            if a database access error occurs.
131cdf0e10cSrcweir     */
132cdf0e10cSrcweir    void appendGroupByColumn([in] com::sun::star::beans::XPropertySet column)
133cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
134cdf0e10cSrcweir
135cdf0e10cSrcweir    //-------------------------------------------------------------------------
136cdf0e10cSrcweir    // HAVING
137cdf0e10cSrcweir    //-------------------------------------------------------------------------
138cdf0e10cSrcweir
139cdf0e10cSrcweir    /** makes it possible to set a HAVING filter condition for the query.
140cdf0e10cSrcweir        @param filter
141cdf0e10cSrcweir            the filter to set
142cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
143cdf0e10cSrcweir            if a database access error occurs
144cdf0e10cSrcweir            or the statement isn't valid
145cdf0e10cSrcweir            or the statement isn't parseable.
146cdf0e10cSrcweir     */
147cdf0e10cSrcweir    void setHavingClause([in] string filter)
148cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
149cdf0e10cSrcweir
150cdf0e10cSrcweir    //-------------------------------------------------------------------------
151cdf0e10cSrcweir
152cdf0e10cSrcweir    /** appends a new set of HAVING filter criteria which is split into levels.
153cdf0e10cSrcweir        @param filter
154cdf0e10cSrcweir            The HAVING filter criteria is split into levels. Each level represents the
155cdf0e10cSrcweir            OR criterias. Within each level, the filters are provided as an AND criteria
156cdf0e10cSrcweir            with the name of the column and the filter condition. The filter condition
157cdf0e10cSrcweir            is of type string. The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
158cdf0e10cSrcweir
159cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
160cdf0e10cSrcweir            if a database access error occurs.
161cdf0e10cSrcweir     */
162cdf0e10cSrcweir    void setStructuredHavingClause([in] sequence< sequence<com::sun::star::beans::PropertyValue> > filter)
163cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
164cdf0e10cSrcweir    //-------------------------------------------------------------------------
165cdf0e10cSrcweir
166cdf0e10cSrcweir    /** appends a new HAVING filter condition by a
167cdf0e10cSrcweir        <type scope="com::sun::star::sdb">DataColumn</type>
168cdf0e10cSrcweir        providing the name and the value for the filter.
169cdf0e10cSrcweir        @param column
170cdf0e10cSrcweir            the column which is used to create a filter
171cdf0e10cSrcweir        @param	andCriteria
172cdf0e10cSrcweir            If <TRUE/> the filter condition will be appended as an AND condition, otherwise
173cdf0e10cSrcweir            the new filter condition will be appended as OR criteria.
174cdf0e10cSrcweir            E.g. (xx AND bb AND cc) OR newCriteria
175cdf0e10cSrcweir        @param  filterOperator
176cdf0e10cSrcweir            The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
177cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
178cdf0e10cSrcweir            if a database access error occurs.
179cdf0e10cSrcweir     */
180cdf0e10cSrcweir    void appendHavingClauseByColumn([in] com::sun::star::beans::XPropertySet column,[in] boolean andCriteria,[in] long filterOperator)
181cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
182cdf0e10cSrcweir
183cdf0e10cSrcweir    //-------------------------------------------------------------------------
184cdf0e10cSrcweir    // ORDER BY
185cdf0e10cSrcweir    //-------------------------------------------------------------------------
186cdf0e10cSrcweir
187cdf0e10cSrcweir    /** makes it possibile to set a sort condition for the query.
188cdf0e10cSrcweir        @param order
189cdf0e10cSrcweir            the order part to set
190cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
191cdf0e10cSrcweir            if a database access error occurs
192cdf0e10cSrcweir            or the order isn't valid
193cdf0e10cSrcweir            or the statement isn't parseable.
194cdf0e10cSrcweir     */
195cdf0e10cSrcweir    void setOrder([in] string order)
196cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
197cdf0e10cSrcweir
198cdf0e10cSrcweir    //-------------------------------------------------------------------------
199cdf0e10cSrcweir
200cdf0e10cSrcweir    /** appends an additional part to the sort order criteria of the select
201cdf0e10cSrcweir        statement. The column must be a <type scope="com::sun::star::sdbcx">Column</type>.
202cdf0e10cSrcweir        @param column
203cdf0e10cSrcweir            the column which is used to create a order part
204cdf0e10cSrcweir        @param	ascending
205cdf0e10cSrcweir            <TRUE/> when the order should be ascending, otherwise if <FALSE/> descending.
206cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
207cdf0e10cSrcweir            if a database access error occurs.
208cdf0e10cSrcweir     */
209cdf0e10cSrcweir    void appendOrderByColumn([in] com::sun::star::beans::XPropertySet column,
210cdf0e10cSrcweir                             [in] boolean ascending)
211cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
212cdf0e10cSrcweir
213cdf0e10cSrcweir    //-------------------------------------------------------------------------
214cdf0e10cSrcweir    // culmulative composing
215cdf0e10cSrcweir    //-------------------------------------------------------------------------
216cdf0e10cSrcweir
217cdf0e10cSrcweir    /** sets a new elementary query for the composer
218cdf0e10cSrcweir
219cdf0e10cSrcweir        <p>An elementary query or statement is a (single select) statement whose parts are
220cdf0e10cSrcweir        not covered by the various set and get methods of the composer. That is, if the
221cdf0e10cSrcweir        elementary statement contains a filter clause, a call to
222cdf0e10cSrcweir        <member>XSingleSelectQueryAnalyzer::getFilter</member> will not return you this
223cdf0e10cSrcweir        filter. Instead, only filters which have been set using for instance <member>setFilter</member>
224cdf0e10cSrcweir        are covered by the get methods.</p>
225cdf0e10cSrcweir
226cdf0e10cSrcweir        <p>The only methods which take all parts of the elementary statement into account are
227cdf0e10cSrcweir        <member>XSingleSelectQueryAnalyzer::getQuery</member> and
228cdf0e10cSrcweir        <member>XSingleSelectQueryAnalyzer::getQueryWithSubstitution</member>, which always returns
229cdf0e10cSrcweir        the complete composed query.</p>
230cdf0e10cSrcweir
231cdf0e10cSrcweir        <p>As a result, you can use the composer to build culmulative filter expressions. That
232cdf0e10cSrcweir        is, you can set <member>ElementaryQuery</member> to a statement already containing
233cdf0e10cSrcweir        filters, and then use <member>setFilter</member> to append additional filters.</p>
234cdf0e10cSrcweir
235cdf0e10cSrcweir        <p>The very same holds for sort orders, <code>HAVING</code> and <code>GROUP BY</code>
236cdf0e10cSrcweir        clauses.</p>
237cdf0e10cSrcweir
238cdf0e10cSrcweir        <p>There are various use cases for this. For instance, you might want to use the
239cdf0e10cSrcweir        statement represented by a <type>QueryDefinition</type>, and extend it with additional
240cdf0e10cSrcweir        filters or sort orders, while not touching the respective parts already present
241cdf0e10cSrcweir        in <member>QueryDefinition::Command</member>. This can be achieved by setting the
242cdf0e10cSrcweir        <member>QueryDefinition::Command</member> as <member>ElementaryQuery</member> of a
243cdf0e10cSrcweir        <type>SingleSelectQueryComposer</type>.</p>
244cdf0e10cSrcweir
245cdf0e10cSrcweir        <p>If, in such a scenario, you would be interested in the filter part of the
246cdf0e10cSrcweir        <member>QueryDefinition::Command</member>, you would set it via
247cdf0e10cSrcweir        <member>XSingleSelectQueryAnalyzer::setQuery</member>, and retrieve the filter
248cdf0e10cSrcweir        part via <member>XSingleSelectQueryAnalyzer::getFilter</member>.</p>
249cdf0e10cSrcweir
250cdf0e10cSrcweir        <p>If you'd be interested in the composed filter, you would set the
251cdf0e10cSrcweir        <member>QueryDefinition::Command</member> as <member>ElementaryQuery</member>, add your
252cdf0e10cSrcweir        filter, and propagate the resulting query (<member>XSingleSelectQueryAnalyzer::getQuery</member>)
253cdf0e10cSrcweir        to an <type>SingleSelectQueryAnalyzer</type> instance via
254cdf0e10cSrcweir        <member>XSingleSelectQueryAnalyzer::setQuery</member>.</p>
255cdf0e10cSrcweir    */
256cdf0e10cSrcweir    [attribute] string ElementaryQuery
257cdf0e10cSrcweir    {
258cdf0e10cSrcweir        set raises (com::sun::star::sdbc::SQLException);
259cdf0e10cSrcweir    };
260cdf0e10cSrcweir};
261cdf0e10cSrcweir
262cdf0e10cSrcweir//=============================================================================
263cdf0e10cSrcweir
264cdf0e10cSrcweir}; }; }; };
265cdf0e10cSrcweir
266cdf0e10cSrcweir/*=============================================================================
267cdf0e10cSrcweir
268cdf0e10cSrcweir=============================================================================*/
269cdf0e10cSrcweir#endif
270cdf0e10cSrcweir
271