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_XSingleSelectQueryAnalyzer_idl__
28*cdf0e10cSrcweir#define __com_sun_star_sdb_XSingleSelectQueryAnalyzer_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*cdf0e10cSrcweirmodule com {  module sun {  module star {  module container {
43*cdf0e10cSrcweirpublished interface XIndexAccess;
44*cdf0e10cSrcweir};};};};
45*cdf0e10cSrcweir//=============================================================================
46*cdf0e10cSrcweir
47*cdf0e10cSrcweir module com {  module sun {  module star {  module sdb {
48*cdf0e10cSrcweir
49*cdf0e10cSrcweir//=============================================================================
50*cdf0e10cSrcweir
51*cdf0e10cSrcweir/** simplifies the analyzing of single select statements.
52*cdf0e10cSrcweir
53*cdf0e10cSrcweir    <p>
54*cdf0e10cSrcweir    The interface can be used for analyzing single SELECT statements without knowing the
55*cdf0e10cSrcweir    structure of the used query.
56*cdf0e10cSrcweir    </p>
57*cdf0e10cSrcweir */
58*cdf0e10cSrcweirpublished interface XSingleSelectQueryAnalyzer : com::sun::star::uno::XInterface
59*cdf0e10cSrcweir{
60*cdf0e10cSrcweir
61*cdf0e10cSrcweir    /** returns the query.
62*cdf0e10cSrcweir        @returns
63*cdf0e10cSrcweir            the query
64*cdf0e10cSrcweir     */
65*cdf0e10cSrcweir    string getQuery();
66*cdf0e10cSrcweir    //-------------------------------------------------------------------------
67*cdf0e10cSrcweir
68*cdf0e10cSrcweir    /** sets a new query for the composer, which may be expanded by filters, group by, having
69*cdf0e10cSrcweir        and sort criteria.
70*cdf0e10cSrcweir        @param command
71*cdf0e10cSrcweir            the single select statement to set
72*cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
73*cdf0e10cSrcweir            if a database access error occurs
74*cdf0e10cSrcweir            or the statement isn't a single select statement
75*cdf0e10cSrcweir            or the statement isn't valid
76*cdf0e10cSrcweir            or the statement can not be parsed.
77*cdf0e10cSrcweir     */
78*cdf0e10cSrcweir    void setQuery([in] string command )
79*cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
80*cdf0e10cSrcweir    //-------------------------------------------------------------------------
81*cdf0e10cSrcweir    // FILTER
82*cdf0e10cSrcweir    //-------------------------------------------------------------------------
83*cdf0e10cSrcweir
84*cdf0e10cSrcweir    /** returns the used filter.
85*cdf0e10cSrcweir        <p>
86*cdf0e10cSrcweir        The filter criteria returned is part of the where condition of the
87*cdf0e10cSrcweir        select command, but it does not contain the where token.
88*cdf0e10cSrcweir        </p>
89*cdf0e10cSrcweir        @returns
90*cdf0e10cSrcweir            the filter
91*cdf0e10cSrcweir     */
92*cdf0e10cSrcweir    string getFilter();
93*cdf0e10cSrcweir    //-------------------------------------------------------------------------
94*cdf0e10cSrcweir
95*cdf0e10cSrcweir    /** returns the currently used filter.
96*cdf0e10cSrcweir             <p>
97*cdf0e10cSrcweir             The filter criteria is split into levels. Each level represents the
98*cdf0e10cSrcweir             OR criterias. Within each level, the filters are provided as an AND criteria
99*cdf0e10cSrcweir             with the name of the column and the filter condition. The filter condition
100*cdf0e10cSrcweir             is of type string. The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
101*cdf0e10cSrcweir             </p>
102*cdf0e10cSrcweir        @returns
103*cdf0e10cSrcweir            the structured filter
104*cdf0e10cSrcweir     */
105*cdf0e10cSrcweir    sequence< sequence<com::sun::star::beans::PropertyValue> >
106*cdf0e10cSrcweir        getStructuredFilter();
107*cdf0e10cSrcweir
108*cdf0e10cSrcweir    //-------------------------------------------------------------------------
109*cdf0e10cSrcweir    // GROUP BY
110*cdf0e10cSrcweir    //-------------------------------------------------------------------------
111*cdf0e10cSrcweir
112*cdf0e10cSrcweir    /** returns the currently used GROUP BY.
113*cdf0e10cSrcweir        <p>
114*cdf0e10cSrcweir        The group criteria returned is part of the GROUP BY clause of the
115*cdf0e10cSrcweir        select command, but it does not contain the GROUP BY keyword .
116*cdf0e10cSrcweir        </p>
117*cdf0e10cSrcweir        @returns
118*cdf0e10cSrcweir            the group
119*cdf0e10cSrcweir     */
120*cdf0e10cSrcweir    string getGroup();
121*cdf0e10cSrcweir
122*cdf0e10cSrcweir    //-------------------------------------------------------------------------
123*cdf0e10cSrcweir    /** returns the currently used group.
124*cdf0e10cSrcweir        <p>
125*cdf0e10cSrcweir        The columns returned form the GROUP BY clause.
126*cdf0e10cSrcweir        </p>
127*cdf0e10cSrcweir        @returns
128*cdf0e10cSrcweir            a collection of <type scope="com::sun::star::sdb">GroupColumn</type> which form the GROUP BY.
129*cdf0e10cSrcweir     */
130*cdf0e10cSrcweir    com::sun::star::container::XIndexAccess getGroupColumns();
131*cdf0e10cSrcweir
132*cdf0e10cSrcweir    //-------------------------------------------------------------------------
133*cdf0e10cSrcweir    // HAVING
134*cdf0e10cSrcweir    //-------------------------------------------------------------------------
135*cdf0e10cSrcweir
136*cdf0e10cSrcweir    /** returns the used HAVING filter.
137*cdf0e10cSrcweir        <p>
138*cdf0e10cSrcweir        The HAVING filter criteria returned is part of the HAVING condition of the
139*cdf0e10cSrcweir        select command, but it does not contain the HAVING token.
140*cdf0e10cSrcweir        </p>
141*cdf0e10cSrcweir        @returns
142*cdf0e10cSrcweir            the filter
143*cdf0e10cSrcweir     */
144*cdf0e10cSrcweir    string getHavingClause();
145*cdf0e10cSrcweir    //-------------------------------------------------------------------------
146*cdf0e10cSrcweir
147*cdf0e10cSrcweir    /** returns the currently used HAVING filter.
148*cdf0e10cSrcweir             <p>
149*cdf0e10cSrcweir             The HAVING filter criteria is split into levels. Each level represents the
150*cdf0e10cSrcweir             OR criterias. Within each level, the filters are provided as an AND criteria
151*cdf0e10cSrcweir             with the name of the column and the filter condition. The filter condition
152*cdf0e10cSrcweir             is of type string. The operator used, is defined by <type scope="com::sun::star::sdb">SQLFilterOperator</type>.
153*cdf0e10cSrcweir             </p>
154*cdf0e10cSrcweir        @returns
155*cdf0e10cSrcweir            the structured HAVING filter
156*cdf0e10cSrcweir     */
157*cdf0e10cSrcweir    sequence< sequence<com::sun::star::beans::PropertyValue> >
158*cdf0e10cSrcweir        getStructuredHavingClause();
159*cdf0e10cSrcweir
160*cdf0e10cSrcweir    //-------------------------------------------------------------------------
161*cdf0e10cSrcweir    // ORDER BY
162*cdf0e10cSrcweir    //-------------------------------------------------------------------------
163*cdf0e10cSrcweir    /** returns the currently used sort order.
164*cdf0e10cSrcweir        <p>
165*cdf0e10cSrcweir        The order criteria returned is part of the ORDER BY clause of the
166*cdf0e10cSrcweir        select command, but it does not contain the ORDER BY keyword .
167*cdf0e10cSrcweir        </p>
168*cdf0e10cSrcweir        @returns
169*cdf0e10cSrcweir            the order
170*cdf0e10cSrcweir     */
171*cdf0e10cSrcweir    string getOrder();
172*cdf0e10cSrcweir
173*cdf0e10cSrcweir    //-------------------------------------------------------------------------
174*cdf0e10cSrcweir    /** returns the currently used sort order.
175*cdf0e10cSrcweir        <p>
176*cdf0e10cSrcweir        The order criteria returned is part of the ORDER BY clause of the
177*cdf0e10cSrcweir        select command, but it does not contain the ORDER BY keyword .
178*cdf0e10cSrcweir        </p>
179*cdf0e10cSrcweir        @returns
180*cdf0e10cSrcweir            a collection of <type scope="com::sun::star::sdb">OrderColumn</type> which form the ORDER BY.
181*cdf0e10cSrcweir     */
182*cdf0e10cSrcweir    com::sun::star::container::XIndexAccess getOrderColumns();
183*cdf0e10cSrcweir
184*cdf0e10cSrcweir    //-------------------------------------------------------------------------
185*cdf0e10cSrcweir    /** returns the query previously set at the analyzer, with all application-level
186*cdf0e10cSrcweir        features being substituted by their database-level counterparts.
187*cdf0e10cSrcweir
188*cdf0e10cSrcweir        <p>The <type>XSingleSelectQueryAnalyzer</type> is an application-level component,
189*cdf0e10cSrcweir        which in some respect understands SQL features usually not present at the database
190*cdf0e10cSrcweir        level. As a prominent example, you might pass a <code>SELECT</code> statement to the analyzer
191*cdf0e10cSrcweir        which is based on another query.</p>
192*cdf0e10cSrcweir
193*cdf0e10cSrcweir        <p>While all other methods will handle those additional features transparently - e.g.
194*cdf0e10cSrcweir        the query in the <code>FROM</code> part of a <code>SELECT</code> statement will be handled
195*cdf0e10cSrcweir        as if it really is a table -, <code>getQueryWithSubstitution</code> gives you the SQL statement
196*cdf0e10cSrcweir        where all those features have been stripped, and replaced with appropriate standard SQL.</p>
197*cdf0e10cSrcweir
198*cdf0e10cSrcweir        <p>For example, consider a database document which contains a client-side query named <code>All Orders</code>.
199*cdf0e10cSrcweir        This query is not known to the underlying database, so an SQL statement like
200*cdf0e10cSrcweir        <code>SELECT * from "All Orders"</code> would be rejected by the database. However, instantiating
201*cdf0e10cSrcweir        a <type>SingleSelectQueryAnalyzer</type> at the <type>Connection</type> object, and passing it the above query,
202*cdf0e10cSrcweir        you can then use <code>getQueryWithSubstitution</code> to retrieve a statement where <code>"All Orders"</code>
203*cdf0e10cSrcweir        has been replaced with the <code>SELECT</code> statement which actually constitutes the <code>"All Orders"</code>
204*cdf0e10cSrcweir        query.</p>
205*cdf0e10cSrcweir
206*cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
207*cdf0e10cSrcweir            if the query represented cannot be completely substituted. A usual case for this is a recursion in
208*cdf0e10cSrcweir            the sub queries: Consider a query named <code>foo</code>, which is defined as <code>SELECT * FROM "bar"</code>.
209*cdf0e10cSrcweir            Now assume that <code>bar</code> is a query defined as <code>SELECT * FROM "foo"</code>. Passing either
210*cdf0e10cSrcweir            of those statements to an analyzer, and calling <member>getQueryWithSubstitution</member>, would result
211*cdf0e10cSrcweir            in an exception being thrown, since it's impossible to substitute the sub queries with their
212*cdf0e10cSrcweir            constituting statements.
213*cdf0e10cSrcweir
214*cdf0e10cSrcweir        @see Connection
215*cdf0e10cSrcweir        @see XQueriesSupplier
216*cdf0e10cSrcweir        @see DatabaseDocument
217*cdf0e10cSrcweir
218*cdf0e10cSrcweir        @since OOo 2.0.4
219*cdf0e10cSrcweir    */
220*cdf0e10cSrcweir    string getQueryWithSubstitution()
221*cdf0e10cSrcweir        raises (com::sun::star::sdbc::SQLException);
222*cdf0e10cSrcweir
223*cdf0e10cSrcweir    /** sets a new query for the composer, which may be expanded by filters, group by, having
224*cdf0e10cSrcweir        and sort criteria.
225*cdf0e10cSrcweir        @param Command
226*cdf0e10cSrcweir            is the command which should be executed, the type of command depends
227*cdf0e10cSrcweir            on the CommandType.
228*cdf0e10cSrcweir
229*cdf0e10cSrcweir            <p>In case of a <member>CommandType</member> of <member>CommandType::COMMAND</member>,
230*cdf0e10cSrcweir            means in case the <member>Command</member> specifies an SQL statement, the inherited
231*cdf0e10cSrcweir            <member scope="com::sun::star::sdbc">RowSet::EscapeProcessing</member>
232*cdf0e10cSrcweir            becomes relevant:<br/>
233*cdf0e10cSrcweir            It then can be to used to specify whether the SQL statement should be analyzed on the
234*cdf0e10cSrcweir            client side before sending it to the database server.<br/>
235*cdf0e10cSrcweir            The default value for <member scope="com::sun::star::sdbc">RowSet::EscapeProcessing</member>
236*cdf0e10cSrcweir            is <TRUE/>. By switching it to <FALSE/>, you can pass backend-specific SQL statements,
237*cdf0e10cSrcweir            which are not standard SQL, to your database.</p>
238*cdf0e10cSrcweir
239*cdf0e10cSrcweir            @see com::sun::star::sdb::CommandType
240*cdf0e10cSrcweir            @see com::sun::star::sdbc::RowSet::EscapeProcessing
241*cdf0e10cSrcweir        @param  CommandType
242*cdf0e10cSrcweir            is the type of the command.
243*cdf0e10cSrcweir            @see com::sun::star::sdb::CommandType
244*cdf0e10cSrcweir        @throws com::sun::star::sdbc::SQLException
245*cdf0e10cSrcweir            if a database access error occurs
246*cdf0e10cSrcweir            or the statement isn't a single select statement
247*cdf0e10cSrcweir            or the statement isn't valid
248*cdf0e10cSrcweir            or the statement can not be parsed.
249*cdf0e10cSrcweir     */
250*cdf0e10cSrcweir    void setCommand([in] string Command ,[in] long CommandType)
251*cdf0e10cSrcweir            raises (com::sun::star::sdbc::SQLException);
252*cdf0e10cSrcweir};
253*cdf0e10cSrcweir
254*cdf0e10cSrcweir//=============================================================================
255*cdf0e10cSrcweir
256*cdf0e10cSrcweir}; }; }; };
257*cdf0e10cSrcweir
258*cdf0e10cSrcweir/*=============================================================================
259*cdf0e10cSrcweir
260*cdf0e10cSrcweir=============================================================================*/
261*cdf0e10cSrcweir#endif
262*cdf0e10cSrcweir
263