1*b1cdbd2cSJim Jagielski/**************************************************************
2*b1cdbd2cSJim Jagielski *
3*b1cdbd2cSJim Jagielski * Licensed to the Apache Software Foundation (ASF) under one
4*b1cdbd2cSJim Jagielski * or more contributor license agreements.  See the NOTICE file
5*b1cdbd2cSJim Jagielski * distributed with this work for additional information
6*b1cdbd2cSJim Jagielski * regarding copyright ownership.  The ASF licenses this file
7*b1cdbd2cSJim Jagielski * to you under the Apache License, Version 2.0 (the
8*b1cdbd2cSJim Jagielski * "License"); you may not use this file except in compliance
9*b1cdbd2cSJim Jagielski * with the License.  You may obtain a copy of the License at
10*b1cdbd2cSJim Jagielski *
11*b1cdbd2cSJim Jagielski *   http://www.apache.org/licenses/LICENSE-2.0
12*b1cdbd2cSJim Jagielski *
13*b1cdbd2cSJim Jagielski * Unless required by applicable law or agreed to in writing,
14*b1cdbd2cSJim Jagielski * software distributed under the License is distributed on an
15*b1cdbd2cSJim Jagielski * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b1cdbd2cSJim Jagielski * KIND, either express or implied.  See the License for the
17*b1cdbd2cSJim Jagielski * specific language governing permissions and limitations
18*b1cdbd2cSJim Jagielski * under the License.
19*b1cdbd2cSJim Jagielski *
20*b1cdbd2cSJim Jagielski *************************************************************/
21*b1cdbd2cSJim Jagielski
22*b1cdbd2cSJim Jagielski
23*b1cdbd2cSJim Jagielski
24*b1cdbd2cSJim Jagielski#ifndef __com_sun_star_sdb_ErrorCondition_idl__
25*b1cdbd2cSJim Jagielski#define __com_sun_star_sdb_ErrorCondition_idl__
26*b1cdbd2cSJim Jagielski
27*b1cdbd2cSJim Jagielski//=============================================================================
28*b1cdbd2cSJim Jagielski
29*b1cdbd2cSJim Jagielskimodule com { module sun { module star { module sdb {
30*b1cdbd2cSJim Jagielski
31*b1cdbd2cSJim Jagielski//=============================================================================
32*b1cdbd2cSJim Jagielski
33*b1cdbd2cSJim Jagielski/** defines error conditions for OpenOffice.org Base core components
34*b1cdbd2cSJim Jagielski
35*b1cdbd2cSJim Jagielski    <p>Core components of OpenOffice.org will use those error conditions
36*b1cdbd2cSJim Jagielski    as error codes (<member scope="com::sun::star::sdbc">SQLException::ErrorCode</member>)
37*b1cdbd2cSJim Jagielski    whereever possible.<br/>
38*b1cdbd2cSJim Jagielski    That is, if an <code>SQLException</code> is raised by
39*b1cdbd2cSJim Jagielski    such a component, caused by an error condition which is included in the
40*b1cdbd2cSJim Jagielski    <type>ErrorCondition</type> group, then the respective <em>negative</em> value
41*b1cdbd2cSJim Jagielski    will be used as <code>ErrorCode</code>.</p>
42*b1cdbd2cSJim Jagielski
43*b1cdbd2cSJim Jagielski    <p>This allows to determine specific error conditions in your client code, and
44*b1cdbd2cSJim Jagielski    to handle it appropriately.</p>
45*b1cdbd2cSJim Jagielski
46*b1cdbd2cSJim Jagielski    <p>Note that before you examine the <code>ErrorCode</code> member of a caught
47*b1cdbd2cSJim Jagielski    <code>SQLException</code>, you need to make sure that the exception
48*b1cdbd2cSJim Jagielski    is really thrown by an OpenOffice.org Base core component. To do so, check
49*b1cdbd2cSJim Jagielski    whether the error message (<code>Exception::Message</code>) starts with the
50*b1cdbd2cSJim Jagielski    vendor string <code>[OOoBase]</code>.</p>
51*b1cdbd2cSJim Jagielski
52*b1cdbd2cSJim Jagielski    <p>The list of defined error conditions, by nature, is expected to permanently grow,
53*b1cdbd2cSJim Jagielski    so never assume it being finalized.</p>
54*b1cdbd2cSJim Jagielski
55*b1cdbd2cSJim Jagielski    @example Java
56*b1cdbd2cSJim Jagielski    <listing>
57*b1cdbd2cSJim Jagielski    catch ( SQLException e )
58*b1cdbd2cSJim Jagielski    {
59*b1cdbd2cSJim Jagielski    &nbsp;&nbsp;if ( e.Message.startsWith( "[OOoBase]" ) )
60*b1cdbd2cSJim Jagielski    &nbsp;&nbsp;&nbsp;&nbsp;if ( e.ErrorCode + ErrorCondition.SOME_ERROR_CONDITION == 0 )
61*b1cdbd2cSJim Jagielski    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;handleSomeErrorCondition();
62*b1cdbd2cSJim Jagielski    }
63*b1cdbd2cSJim Jagielski    </listing>
64*b1cdbd2cSJim Jagielski */
65*b1cdbd2cSJim Jagielskiconstants ErrorCondition
66*b1cdbd2cSJim Jagielski{
67*b1cdbd2cSJim Jagielski    // ========================================================================
68*b1cdbd2cSJim Jagielski    // = section ROW_SET - css.sdb.RowSet related error conditions
69*b1cdbd2cSJim Jagielski
70*b1cdbd2cSJim Jagielski    /** is used by and <type>RowSet</type> to indicate that an operation has been vetoed
71*b1cdbd2cSJim Jagielski        by one of its approval listeners
72*b1cdbd2cSJim Jagielski
73*b1cdbd2cSJim Jagielski        <p>This error condition results in raising a <type>RowSetVetoException</type>.</p>
74*b1cdbd2cSJim Jagielski        @see RowSet
75*b1cdbd2cSJim Jagielski        @see XRowSetApproveBroadcaster
76*b1cdbd2cSJim Jagielski        @see XRowSetApproveListener
77*b1cdbd2cSJim Jagielski    */
78*b1cdbd2cSJim Jagielski	const long ROW_SET_OPERATION_VETOED = 100;
79*b1cdbd2cSJim Jagielski
80*b1cdbd2cSJim Jagielski    // ========================================================================
81*b1cdbd2cSJim Jagielski    // = section PARSER - parsing related error conditions
82*b1cdbd2cSJim Jagielski
83*b1cdbd2cSJim Jagielski    /** indicates that while parsing an SQL statement, cyclic sub queries have been detected.
84*b1cdbd2cSJim Jagielski
85*b1cdbd2cSJim Jagielski        <p>Imagine you have a client-side query <code>SELECT * FROM table</code>, which is
86*b1cdbd2cSJim Jagielski        saved as &quot;query1&quot;. Additionally, there is a query &quot;query2&quot; defined
87*b1cdbd2cSJim Jagielski        as <code>SELECT * FROM query1</code>. Now if you try to change the statement of
88*b1cdbd2cSJim Jagielski        <type>query1</type> to <code>SELECT * FROM query2</code>, this is prohibited, because
89*b1cdbd2cSJim Jagielski        it would lead to a cyclic sub query.
90*b1cdbd2cSJim Jagielski    */
91*b1cdbd2cSJim Jagielski    const long PARSER_CYCLIC_SUB_QUERIES = 200;
92*b1cdbd2cSJim Jagielski
93*b1cdbd2cSJim Jagielski    // ========================================================================
94*b1cdbd2cSJim Jagielski    // = section DB - application-level error conditions
95*b1cdbd2cSJim Jagielski    // =
96*b1cdbd2cSJim Jagielski    // = next section should start with 500
97*b1cdbd2cSJim Jagielski
98*b1cdbd2cSJim Jagielski    /** indicates that the name of a client side database object - a query, a form,
99*b1cdbd2cSJim Jagielski        or a report - contains one or more slashes, which is forbidden.
100*b1cdbd2cSJim Jagielski    */
101*b1cdbd2cSJim Jagielski    const long DB_OBJECT_NAME_WITH_SLASHES = 300;
102*b1cdbd2cSJim Jagielski
103*b1cdbd2cSJim Jagielski    /** indicates that an identifier is not SQL conform.
104*b1cdbd2cSJim Jagielski    */
105*b1cdbd2cSJim Jagielski    const long DB_INVALID_SQL_NAME = 301;
106*b1cdbd2cSJim Jagielski
107*b1cdbd2cSJim Jagielski    /** indicates that the name of a query contains quote characters.
108*b1cdbd2cSJim Jagielski
109*b1cdbd2cSJim Jagielski        <p>This error condition is met when the user attempts to save a query
110*b1cdbd2cSJim Jagielski        with a name which contains one of the possible database quote characters.
111*b1cdbd2cSJim Jagielski        This is an error since query names can potentially be used in
112*b1cdbd2cSJim Jagielski        <code>SELECT</code> statements, where quote identifiers would render the statement invalid.</p>
113*b1cdbd2cSJim Jagielski
114*b1cdbd2cSJim Jagielski        @see com::sun::star::sdb::tools::XDataSourceMetaData::supportsQueriesInFrom
115*b1cdbd2cSJim Jagielski    */
116*b1cdbd2cSJim Jagielski    const long DB_QUERY_NAME_WITH_QUOTES = 302;
117*b1cdbd2cSJim Jagielski
118*b1cdbd2cSJim Jagielski    /** indicates that an attempt was made to save a database object under a name
119*b1cdbd2cSJim Jagielski        which is already used in the database.
120*b1cdbd2cSJim Jagielski
121*b1cdbd2cSJim Jagielski        <p>In databases which support query names to appear in <code>SELECT</code>
122*b1cdbd2cSJim Jagielski        statements, this could mean that a table was attempted to be saved with the
123*b1cdbd2cSJim Jagielski        name of an existing query, or vice versa.</p>
124*b1cdbd2cSJim Jagielski
125*b1cdbd2cSJim Jagielski        <p>Otherwise, it means an object was attempted to be saved with the
126*b1cdbd2cSJim Jagielski        name of an already existing object of the same type.</p>
127*b1cdbd2cSJim Jagielski
128*b1cdbd2cSJim Jagielski        @see com::sun::star::sdb::application::DatabaseObject
129*b1cdbd2cSJim Jagielski        @see com::sun::star::sdb::tools::XDataSourceMetaData::supportsQueriesInFrom
130*b1cdbd2cSJim Jagielski    */
131*b1cdbd2cSJim Jagielski    const long DB_OBJECT_NAME_IS_USED = 303;
132*b1cdbd2cSJim Jagielski
133*b1cdbd2cSJim Jagielski    /** indicates an operation was attempted which needs a connection to the
134*b1cdbd2cSJim Jagielski        database, which did not exist at that time.
135*b1cdbd2cSJim Jagielski    */
136*b1cdbd2cSJim Jagielski    const long DB_NOT_CONNECTED = 304;
137*b1cdbd2cSJim Jagielski
138*b1cdbd2cSJim Jagielski    // ========================================================================
139*b1cdbd2cSJim Jagielski    // = section AB - address book access related error conditions
140*b1cdbd2cSJim Jagielski    // =
141*b1cdbd2cSJim Jagielski    // = next section should start with 550
142*b1cdbd2cSJim Jagielski
143*b1cdbd2cSJim Jagielski    /** used by the component implementing address book access to indicate that a requested address book could
144*b1cdbd2cSJim Jagielski        not be accessed.
145*b1cdbd2cSJim Jagielski
146*b1cdbd2cSJim Jagielski        <p>For instance, this error code is used when you try to access the address book
147*b1cdbd2cSJim Jagielski        in a Thunderbird profile named <q>MyProfile</q>,  but there does not exist a profile
148*b1cdbd2cSJim Jagielski        with this name.</p>
149*b1cdbd2cSJim Jagielski    */
150*b1cdbd2cSJim Jagielski    const long AB_ADDRESSBOOK_NOT_FOUND = 500;
151*b1cdbd2cSJim Jagielski
152*b1cdbd2cSJim Jagielski    // ========================================================================
153*b1cdbd2cSJim Jagielski    // = section DATA - data retrieval related error conditions
154*b1cdbd2cSJim Jagielski    // =
155*b1cdbd2cSJim Jagielski    // = next section should start with 600
156*b1cdbd2cSJim Jagielski
157*b1cdbd2cSJim Jagielski    /** used to indicate that a <code>SELECT</code> operation on a table needs a filter.
158*b1cdbd2cSJim Jagielski
159*b1cdbd2cSJim Jagielski        <p>Some database drivers are not able to <code>SELECT</code> from a table if the
160*b1cdbd2cSJim Jagielski        statement does not contain a <code>WHERE</code> clause. In this case, a statement
161*b1cdbd2cSJim Jagielski        like <code>SELECT * FROM "table"</cdeo> with fail with the error code
162*b1cdbd2cSJim Jagielski        <code>DATA_CANNOT_SELECT_UNFILTERED</code>.</p>
163*b1cdbd2cSJim Jagielski
164*b1cdbd2cSJim Jagielski        <p>It is also legitimate for the driver to report this error condition as warning, and provide
165*b1cdbd2cSJim Jagielski        an empty result set, instead of ungracefull failing.</p>
166*b1cdbd2cSJim Jagielski    */
167*b1cdbd2cSJim Jagielski    const long DATA_CANNOT_SELECT_UNFILTERED = 550;
168*b1cdbd2cSJim Jagielski};
169*b1cdbd2cSJim Jagielski
170*b1cdbd2cSJim Jagielski//=============================================================================
171*b1cdbd2cSJim Jagielski
172*b1cdbd2cSJim Jagielski}; }; }; };
173*b1cdbd2cSJim Jagielski
174*b1cdbd2cSJim Jagielski//=============================================================================
175*b1cdbd2cSJim Jagielski
176*b1cdbd2cSJim Jagielski#endif
177