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