Branch libreoffice-5-0-4
[LibreOffice.git] / include / connectivity / dbtools.hxx
blob02b3f0660290fe1ce05be0c54f1c8a1a5aa4bb50
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_CONNECTIVITY_DBTOOLS_HXX
21 #define INCLUDED_CONNECTIVITY_DBTOOLS_HXX
23 #include <connectivity/dbexception.hxx>
24 #include <comphelper/types.hxx>
25 #include <com/sun/star/sdbc/DataType.hpp>
26 #include <comphelper/stl_types.hxx>
27 #include <unotools/sharedunocomponent.hxx>
28 #include <connectivity/dbtoolsdllapi.hxx>
29 #include <connectivity/FValue.hxx>
31 namespace com { namespace sun { namespace star {
33 namespace sdb {
34 class XSingleSelectQueryComposer;
35 class SQLContext;
37 namespace sdbcx {
38 class XTablesSupplier;
40 namespace sdbc {
41 class XConnection;
42 class XDatabaseMetaData;
43 class XRowSet;
44 class XDataSource;
45 class SQLException;
46 class XParameters;
47 class XRowUpdate;
49 namespace beans {
50 class XPropertySet;
52 namespace awt {
53 class XWindow;
55 namespace lang {
56 struct Locale;
57 class XMultiServiceFactory;
58 class WrappedTargetException;
60 namespace container {
61 class XNameAccess;
63 namespace uno {
64 class XComponentContext;
66 namespace util {
67 class XNumberFormatTypes;
68 class XNumberFormatsSupplier;
70 namespace task {
71 class XInteractionHandler;
74 } } }
77 namespace dbtools
79 class ISQLStatementHelper;
80 typedef ::utl::SharedUNOComponent< ::com::sun::star::sdbc::XConnection > SharedConnection;
82 enum EComposeRule
84 eInTableDefinitions,
85 eInIndexDefinitions,
86 eInDataManipulation,
87 eInProcedureCalls,
88 eInPrivilegeDefinitions,
89 eComplete
92 // date conversion
94 // calculates the default numberformat for a given datatype and a give language
95 OOO_DLLPUBLIC_DBTOOLS
96 sal_Int32 getDefaultNumberFormat(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& _xColumn,
97 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
98 const ::com::sun::star::lang::Locale& _rLocale);
100 // calculates the default numberformat for a given datatype and a give language
101 // @param _nDataType @see com.sun.star.sdbc.DataType
102 // @param _nScale can be zero
103 OOO_DLLPUBLIC_DBTOOLS
104 sal_Int32 getDefaultNumberFormat(sal_Int32 _nDataType,
105 sal_Int32 _nScale,
106 bool _bIsCurrency,
107 const ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatTypes >& _xTypes,
108 const ::com::sun::star::lang::Locale& _rLocale);
112 /** creates a connection which can be used for the rowset given
114 The function tries to obtain a connection for the row set with the following
115 steps (in this order):
116 <nl>
117 <li>If the rowset already has an ActiveConnection (means a non-<NULL/> value vor this property),
118 this one is used.</li>
119 <li>If row set is part of a database form document (see ->isEmbeddedInDatabase),
120 a connection for the respective database is used.</li>
121 <li>If in the parent hierarchy of the row set, there is an object supporting
122 the XConnection interface, this one is returned.</li>
123 <li>If the DataSourceName property of the row set is not empty, a connection for this
124 data source is retrieved.</li>
125 <li>If the URL property of the row set is not empty, an connection for this URL is
126 retrieved from the driver manager.
127 </nl>
129 @param _rxRowSet
130 the row set
132 @param _rxFactory
133 a service factory, which can be used to create data sources, interaction handler etc (the usual stuff)
135 @param _bSetAsActiveConnection
136 If <TRUE/>, the calculated connection is set as ActiveConnection property on the rowset.
138 If the connection was newly created by the method, and this parameter is <TRUE/>, then
139 the ownership of the connection is delivered to a temporary object, which observes the
140 row set: As soon as a connection-relevant property of the row set changes, or as soon
141 as somebody else sets another ActiveConnection at the row set, the original
142 connection (the one which this function calculated) is disposed and discarded. At this
143 very moment, also the temporary observer object dies. This way, it is ensured that
144 there's no resource leak from an un-owned connection object.
146 OOO_DLLPUBLIC_DBTOOLS
147 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> connectRowset(
148 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
149 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
150 bool _bSetAsActiveConnection
153 /** ensures that a row set has a valid ActiveConnection, if possible
155 This function does nearly the same as ->connectRowset. In fact, it is to be preferred over
156 ->connectRowset, if possible.
158 There are a few differences:
159 <ul><li>If a connection could be determined for the given RowSet, it is always
160 set as ActiveConnection.</li>
161 <li>Definition of the ownership of the created connection allows for more scenarios:
162 <ul><li>If the connection was not newly created, the returned ->SharedConnection
163 instance will not have the ownership, since in this case it's assumed
164 that there already is an instance which has the ownership.</li>
165 <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer
166 is <TRUE/>, then the returned SharedConnection instance will <em>not</em>
167 be the owner of the connection. Instead, the ownership will be delivered
168 to a temporary object as described for connectRowset.</li>
169 <li>If the connection was newly created, and ->_bUseAutoConnectionDisposer
170 is <FALSE/>, then the returned SharedConnection instance will have the
171 ownership of the XConnection.</li>
172 </ul>
173 </li>
174 </ul>
176 OOO_DLLPUBLIC_DBTOOLS SharedConnection ensureRowSetConnection(
177 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet,
178 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext,
179 bool _bUseAutoConnectionDisposer
182 /** returns the connection the RowSet is currently working with (which is the ActiveConnection property)
184 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowSet>& _rxRowSet) throw (::com::sun::star::uno::RuntimeException);
185 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection> getConnection_withFeedback(
186 const OUString& _rDataSourceName,
187 const OUString& _rUser,
188 const OUString& _rPwd,
189 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
192 /** determines whether the given component is part of a document which is an embedded database
193 document (such as a form)
195 OOO_DLLPUBLIC_DBTOOLS bool isEmbeddedInDatabase(
196 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxComponent,
197 ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxActualConnection
200 /** returns the columns of the named table of the given connection
202 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getTableFields(
203 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
204 const OUString& _rName
207 /** returns the primary key columns of the table
209 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getPrimaryKeyColumns_throw(
210 const ::com::sun::star::uno::Any& i_aTable
212 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> getPrimaryKeyColumns_throw(
213 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& i_xTable
216 /** get fields for a result set given by a "command descriptor"
218 <p>A command descriptor here means:
219 <ul><li>a SDB-level connection (com.sun.star.sdb::Connection</li>
220 <li>a string specifying the name of an object relative to the connection</li>
221 <li>a com.sun.star.sdb::CommandType value specifying the type
222 of the object</type></li>
223 </ul>
224 </p>
226 @param _rxConnection
227 the connection relative to which the to-be-examined object exists
229 @param _nCommandType
230 the type of the object
232 @param _rCommand
233 the object. This may be a table name, a query name, or an SQL statement, depending on the value
234 of <arg>_nCommandType</arg>
236 @param _rxCollectionOner
237 If (and only if) <arg>CommandType</arg> is CommandType.COMMAND, the fields collection which is returned
238 by this function here is a temporary object. It is kept alive by another object, which is to be
239 created temporarily, too. To ensure that the fields you get are valid as long as you need them,
240 the owner which controls their life time is transferred to this parameter upon return.<br/>
242 Your fields live as long as this component lives.<br/>
244 Additionally, you are encouraged to dispose this component as soon as you don't need the fields anymore.
245 It depends on the connection's implementation if this is necessary, but the is no guarantee, so to
246 be on the safe side with respect to resource leaks, you should dispose the component.
248 @param _pErrorInfo
249 If not <NULL/>, then upon return from the function the instance pointed to by this argument will
250 contain any available error information in case something went wrong.
252 @return
253 the container of the columns (aka fields) of the object
255 OOO_DLLPUBLIC_DBTOOLS
256 ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >
257 getFieldsByCommandDescriptor(
258 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
259 const sal_Int32 _nCommandType,
260 const OUString& _rCommand,
261 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent >& _rxKeepFieldsAlive,
262 SQLExceptionInfo* _pErrorInfo = NULL
266 /** get fields for a result set given by a "command descriptor"
268 <p>A command descriptor here means:
269 <ul><li>a SDB-level connection (com.sun.star.sdb::Connection</li>
270 <li>a string specifying the name of an object relative to the connection</li>
271 <li>a com.sun.star.sdb::CommandType value specifying the type
272 of the object</type></li>
273 </ul>
274 </p>
276 @param _rxConnection
277 the connection relative to which the to-be-examined object exists
279 @param _nCommandType
280 the type of the object
282 @param _rCommand
283 the object. This may be a table name, a query name, or an SQL statement, depending on the value
284 of <arg>_nCommandType</arg>
286 @param _pErrorInfo
287 If not <NULL/>, then upon return from the function the instance pointed to by this argument will
288 contain any available error information in case something went wrong.
290 @return
291 an array of strings containing the names of the columns (aka fields) of the object
293 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Sequence< OUString >
294 getFieldNamesByCommandDescriptor(
295 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
296 const sal_Int32 _nCommandType,
297 const OUString& _rCommand,
298 SQLExceptionInfo* _pErrorInfo = NULL
302 /** create a new ::com::sun::star::sdbc::SQLContext, fill it with the given descriptions and the given source,
303 and <i>append</i> _rException (i.e. put it into the NextException member of the SQLContext).
305 OOO_DLLPUBLIC_DBTOOLS
306 ::com::sun::star::sdbc::SQLException prependErrorInfo(
307 const ::com::sun::star::sdbc::SQLException& _rChainedException,
308 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxContext,
309 const OUString& _rAdditionalError,
310 const StandardSQLState _eSQLState = SQL_ERROR_UNSPECIFIED,
311 const sal_Int32 _nErrorCode = 0);
313 /** search the parent hierarchy for a data source.
315 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> findDataSource(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _xParent);
317 /** determines the value of a booolean data source setting, given by ASCII name
319 @param _rxConnection
320 the connection belonging to the data source whose setting is to be retrieved
321 @param _pAsciiSettingName
322 the ASCII name of the setting
324 OOO_DLLPUBLIC_DBTOOLS bool getBooleanDataSourceSetting(
325 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
326 const sal_Char* _pAsciiSettingName
329 /** check if a specific property is enabled in the info sequence
330 @deprecated
331 Use getBooleanDataSourceSetting instead, which cares for the default of the property itself,
332 instead of spreading this knowledge through all callers.
334 OOO_DLLPUBLIC_DBTOOLS
335 bool isDataSourcePropertyEnabled(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>& _xProp,
336 const OUString& _sProperty,
337 bool _bDefault = false);
339 /** retrieves a particular indirect data source setting
341 @param _rxDataSource
342 a data source component
343 @param _pAsciiSettingsName
344 the ASCII name of the setting to obtain
345 @param _rSettingsValue
346 the value of the setting, upon successful return
348 @return
349 <FALSE/> if the setting is not present in the <member scope="com::sun::star::sdb">DataSource::Info</member>
350 member of the data source
351 <TRUE/> otherwise
353 OOO_DLLPUBLIC_DBTOOLS
354 bool getDataSourceSetting(
355 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
356 const sal_Char* _pAsciiSettingsName,
357 ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
359 OOO_DLLPUBLIC_DBTOOLS
360 bool getDataSourceSetting(
361 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >& _rxDataSource,
362 const OUString& _sSettingsName,
363 ::com::sun::star::uno::Any& /* [out] */ _rSettingsValue
366 OOO_DLLPUBLIC_DBTOOLS OUString getDefaultReportEngineServiceName(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxFactory);
368 /** quote the given name with the given quote string.
370 OOO_DLLPUBLIC_DBTOOLS OUString quoteName(const OUString& _rQuote, const OUString& _rName);
372 /** quote the given table name (which may contain a catalog and a schema) according to the rules provided by the meta data
374 OOO_DLLPUBLIC_DBTOOLS
375 OUString quoteTableName(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _rxMeta
376 , const OUString& _rName
377 ,EComposeRule _eComposeRule);
379 /** split a fully qualified table name (including catalog and schema, if appliable) into it's component parts.
380 @param _rxConnMetaData meta data describing the connection where you got the table name from
381 @param _rQualifiedName fully qualified table name
382 @param _rCatalog (out parameter) upon return, contains the catalog name
383 @param _rSchema (out parameter) upon return, contains the schema name
384 @param _rName (out parameter) upon return, contains the table name
385 @param _eComposeRule where do you need the name for
387 OOO_DLLPUBLIC_DBTOOLS void qualifiedNameComponents(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxConnMetaData,
388 const OUString& _rQualifiedName, OUString& _rCatalog, OUString& _rSchema, OUString& _rName,EComposeRule _eComposeRule);
390 /** calculate a NumberFormatsSupplier for use with an given connection
391 @param _rxConn the connection for which the formatter is requested
392 @param _bAllowDefault if the connection (and related components, such as its parent) cannot supply
393 a formatter, we can ask the DatabaseEnvironment for a default one. This parameter
394 states if this is allowed.
395 @param _rxFactory required (only of _bAllowDefault is sal_True) for creating the DatabaseEnvironment.
396 @return the formatter all object related to the given connection should work with.
398 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::util::XNumberFormatsSupplier> getNumberFormats(
399 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
400 bool _bAllowDefault = false,
401 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext = ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>()
404 /** create an com::sun::star::sdb::XSingleSelectQueryComposer which represents
405 the current settings (Command/CommandType/Filter/Order) of the given rowset.
407 As such an instance can be obtained from a com::sun::star::sdb::Connection
408 only the function searches for the connection the RowSet is using via connectRowset.
409 This implies that a connection will be set on the RowSet if needed.
410 (need to changes this sometimes ...)
412 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer > getCurrentSettingsComposer(
413 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxRowSetProps,
414 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext
417 /** transfer and translate properties between two FormComponents
418 @param _rxOld the source property set
419 @param _rxNew the destination property set
420 @param _rLocale the locale for converting number related properties
422 OOO_DLLPUBLIC_DBTOOLS void TransferFormComponentProperties(
423 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxOld,
424 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxNew,
425 const ::com::sun::star::lang::Locale& _rLocale
428 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::INSERT
429 @param _rxCursorSet the property set
431 OOO_DLLPUBLIC_DBTOOLS bool canInsert(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
432 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::UPDATE
433 @param _rxCursorSet the property set
435 OOO_DLLPUBLIC_DBTOOLS bool canUpdate(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
436 /** check if the property "Privileges" supports ::com::sun::star::sdbcx::Privilege::DELETE
437 @param _rxCursorSet the property set
439 OOO_DLLPUBLIC_DBTOOLS bool canDelete(const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _rxCursorSet);
442 /** compose a complete table name from it's up to three parts, regarding to the database meta data composing rules
444 OOO_DLLPUBLIC_DBTOOLS OUString composeTableName( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData >& _rxMetaData,
445 const OUString& _rCatalog,
446 const OUString& _rSchema,
447 const OUString& _rName,
448 bool _bQuote,
449 EComposeRule _eComposeRule);
451 /** composes a table name for usage in a SELECT statement
453 This includes quoting of the table as indicated by the connection's meta data, plus respecting
454 the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
455 in the data source which the connection belongs to.
457 OOO_DLLPUBLIC_DBTOOLS OUString composeTableNameForSelect(
458 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
459 const OUString& _rCatalog,
460 const OUString& _rSchema,
461 const OUString& _rName );
463 /** composes a table name for usage in a SELECT statement
465 This includes quoting of the table as indicated by the connection's meta data, plus respecting
466 the settings "UseCatalogInSelect" and "UseSchemaInSelect", which might be present
467 in the data source which the connection belongs to.
469 OOO_DLLPUBLIC_DBTOOLS OUString composeTableNameForSelect(
470 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
471 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable );
473 /** compose the table name out of the property set which must support the properties from the service <member scope= "com::sun::star::sdbcx">table</member>
474 @param _xMetaData
475 The metadata from the connection.
476 @param _xTable
477 The table.
479 OOO_DLLPUBLIC_DBTOOLS OUString composeTableName(
480 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
481 const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable,
482 EComposeRule _eComposeRule,
483 bool _bSuppressCatalogName,
484 bool _bSuppressSchemaName,
485 bool _bQuote);
488 OOO_DLLPUBLIC_DBTOOLS sal_Int32 getSearchColumnFlag( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _rxConn,
489 sal_Int32 _nDataType);
490 // return the datasource for the given datasource name
491 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDataSource> getDataSource(const OUString& _rsDataSourceName,
492 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
494 /** search for a name that is NOT in the NameAcces
495 @param _rxContainer
496 the NameAccess container to search in
497 @param _rBaseName
498 the base name that should be used to create the new name
499 @param _bStartWithNumber
500 When <TRUE/> the name ends with number even when the name itself doesn't occur in the collection.
501 @return
502 A name which doesn't exist in the collection.
504 OOO_DLLPUBLIC_DBTOOLS
505 OUString createUniqueName(const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess>& _rxContainer,
506 const OUString& _rBaseName,
507 bool _bStartWithNumber = true);
509 /** creates a unique name which is not already used in the given name array
511 OOO_DLLPUBLIC_DBTOOLS OUString createUniqueName(
512 const ::com::sun::star::uno::Sequence< OUString >& _rNames,
513 const OUString& _rBaseName,
514 bool _bStartWithNumber = true
517 /** create a name which is a valid SQL 92 identifier name
518 @param _rName the string which should be converted
519 @param _rSpecials @see com.sun.star.sdbc.XDatabaseMetaData.getExtraNameCharacters
521 @see isValidSQLName
523 OOO_DLLPUBLIC_DBTOOLS OUString convertName2SQLName(const OUString& _rName,const OUString& _rSpecials);
525 /** checks whether the given name is a valid SQL name
527 @param _rName the string which should be converted
528 @param _rSpecials @see com.sun.star.sdbc.XDatabaseMetaData.getExtraNameCharacters
530 @see convertName2SQLName
532 OOO_DLLPUBLIC_DBTOOLS bool isValidSQLName( const OUString& _rName, const OUString& _rSpecials );
534 OOO_DLLPUBLIC_DBTOOLS
535 void showError( const SQLExceptionInfo& _rInfo,
536 const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow>& _pParent,
537 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
539 /** implements <method scope="com.sun.star.sdb">XRowUpdate::updateObject</method>
540 <p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there
541 is another updateXXX method, this other method is used.</p>
542 @param _rxUpdatedObject
543 the interface to forward all updateXXX calls to (except updateObject)
544 @param _nColumnIndex
545 the column index to update
546 @param _rValue
547 the value to update
548 @return
549 <TRUE/> if the update request was successfully re-routed to one of the other updateXXX methods
551 OOO_DLLPUBLIC_DBTOOLS
552 bool implUpdateObject( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XRowUpdate >& _rxUpdatedObject,
553 const sal_Int32 _nColumnIndex,
554 const ::com::sun::star::uno::Any& _rValue);
558 /** ask the user for parameters if the prepared statement needs some and sets them in the prepared statement
559 @param _xConnection the connection must be able to create com::sun::star::sdb::SingleSelectQueryComposers
560 @param _xPreparedStmt the prepared statement where the parameters could be set when needed
561 @param _aParametersSet contains which parameters have to asked for and which already have set.
563 OOO_DLLPUBLIC_DBTOOLS
564 void askForParameters( const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryComposer >& _xComposer,
565 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
566 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
567 const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler >& _rxHandler,
568 const ::std::vector<bool, std::allocator<bool> >& _aParametersSet = ::std::vector<bool, std::allocator<bool> >());
570 /** call the appropriate set method for the specific sql type @see com::sun::star::sdbc::DataType
571 @param _xParams the parameters where to set the value
572 @param parameterIndex the index of the parameter, 1 based
573 @param x the value to set
574 @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType
575 @param scale the scale of the sql type can be 0
577 OOO_DLLPUBLIC_DBTOOLS
578 void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
579 sal_Int32 parameterIndex,
580 const ::com::sun::star::uno::Any& x,
581 sal_Int32 sqlType,
582 sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
584 /** call the appropriate set method for the specific sql type @see com::sun::star::sdbc::DataType
585 @param _xParams the parameters where to set the value
586 @param parameterIndex the index of the parameter, 1 based
587 @param x the value to set
588 @param sqlType the corresponding sql type @see com::sun::star::sdbc::DataType
589 @param scale the scale of the sql type can be 0
591 OOO_DLLPUBLIC_DBTOOLS
592 void setObjectWithInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _xParameters,
593 sal_Int32 parameterIndex,
594 const ::connectivity::ORowSetValue& x,
595 sal_Int32 sqlType,
596 sal_Int32 scale=0) throw(::com::sun::star::sdbc::SQLException, ::com::sun::star::uno::RuntimeException);
599 /** implements <method scope="com.sun.star.sdb">XParameters::setObject</method>
600 <p>The object which is to be set is analyzed, and in case it is a simlpe scalar type for which there
601 is another setXXX method, this other method is used.</p>
602 @param _rxParameters
603 the interface to forward all setXXX calls to (except setObject)
604 @param _nColumnIndex
605 the column index to update
606 @param _rValue
607 the value to update
608 @return
609 <TRUE/> if the update request was successfully re-routed to one of the other updateXXX methods
611 OOO_DLLPUBLIC_DBTOOLS
612 bool implSetObject( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XParameters>& _rxParameters,
613 const sal_Int32 _nColumnIndex,
614 const ::com::sun::star::uno::Any& _rValue);
616 /** creates the standard sql create table statement without the key part.
617 @param descriptor
618 The descriptor of the new table.
619 @param _xConnection
620 The connection.
621 @param _bAddScale
622 The scale will also be added when the value is 0.
624 OOO_DLLPUBLIC_DBTOOLS
625 OUString createStandardCreateStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,
626 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
627 ISQLStatementHelper* _pHelper,
628 const OUString& _sCreatePattern = OUString());
630 /** creates the standard sql statement for the key part of a create table statement.
631 @param descriptor
632 The descriptor of the new table.
633 @param _xConnection
634 The connection.
636 OOO_DLLPUBLIC_DBTOOLS
637 OUString createStandardKeyStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor,
638 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection);
640 /** creates the standard sql statement for the type part of a create or alter table statement.
641 @param _pHelper
642 Allow to add special SQL constructs.
643 @param descriptor
644 The descriptor of the column.
645 @param _xConnection
646 The connection.
648 OOO_DLLPUBLIC_DBTOOLS
649 OUString createStandardTypePart( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor
650 ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
651 ,const OUString& _sCreatePattern = OUString());
653 /** creates the standard sql statement for the column part of a create table statement.
654 @param _pHelper
655 Allow to add special SQL constructs.
656 @param descriptor
657 The descriptor of the column.
658 @param _xConnection
659 The connection.
660 @param _pHelper
661 Allow to add special SQL constructs.
663 OOO_DLLPUBLIC_DBTOOLS
664 OUString createStandardColumnPart( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor
665 ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
666 ,ISQLStatementHelper* _pHelper = NULL
667 ,const OUString& _sCreatePattern = OUString());
669 /** creates a SQL CREATE TABLE statement
671 @param descriptor
672 The descriptor of the new table.
673 @param _xConnection
674 The connection.
675 @param _pHelper
676 Allow to add special SQL constructs.
677 @param _sCreatePattern
679 @return
680 The CREATE TABLE statement.
682 OOO_DLLPUBLIC_DBTOOLS
683 OUString createSqlCreateTableStatement( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet >& descriptor
684 ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection
685 ,ISQLStatementHelper* _pHelper = NULL
686 ,const OUString& _sCreatePattern = OUString());
688 /** creates a SDBC column with the help of getColumns.
689 @param _xTable
690 The table.
691 @param _rName
692 The name of the column.
693 @param _bCase
694 Is the column case sensitive.
695 @param _bQueryForInfo
696 If <TRUE/> the autoincrement and currency field will be read from the meta data, otherwise the following parameters will be used instead
697 @param _bIsAutoIncrement
698 <TRUE/> if the column is an autoincrement.
699 @param _bIsCurrency
700 <TRUE/> if the column is a currency field.
701 @param _nDataType
702 The data type of the column.
704 OOO_DLLPUBLIC_DBTOOLS
705 ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>
706 createSDBCXColumn( const ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet>& _xTable,
707 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
708 const OUString& _rName,
709 bool _bCase,
710 bool _bQueryForInfo = true,
711 bool _bIsAutoIncrement = false,
712 bool _bIsCurrency = false,
713 sal_Int32 _nDataType = com::sun::star::sdbc::DataType::OTHER);
715 /** tries to locate the corresponding DataDefinitionSupplier for the given url and connection
716 @param _rsUrl
717 The URL used to connect to the database.
718 @param _xConnection
719 The connection used to find the correct driver.
720 @param _rxContext
721 Used to create the drivermanager.
722 @return
723 The datadefintion object.
725 OOO_DLLPUBLIC_DBTOOLS ::com::sun::star::uno::Reference< ::com::sun::star::sdbcx::XTablesSupplier> getDataDefinitionByURLAndConnection(
726 const OUString& _rsUrl,
727 const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
728 const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext>& _rxContext);
730 /** returns the table privileges to the given parameters
731 @param _xMetaData
732 The meta data.
733 @param _sCatalog
734 contains the catalog name
735 @param _sSchema
736 contains the schema name
737 @param _sTable
738 contains the table name
740 OOO_DLLPUBLIC_DBTOOLS
741 sal_Int32 getTablePrivileges(const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XDatabaseMetaData>& _xMetaData,
742 const OUString& _sCatalog,
743 const OUString& _sSchema,
744 const OUString& _sTable);
746 typedef ::std::pair<bool,bool> TBoolPair;
747 typedef ::std::pair< TBoolPair,sal_Int32 > ColumnInformation;
748 typedef ::std::multimap< OUString, ColumnInformation, ::comphelper::UStringMixLess> ColumnInformationMap;
749 /** collects the information about auto increment, currency and data type for the given column name.
750 The column must be quoted, * is also valid.
751 @param _xConnection
752 The connection.
753 @param _sComposedTableName
754 The quoted table name. ccc.sss.ttt
755 @param _sName
756 The name of the column, or *
757 @param _rInfo
758 The information about the column(s).
760 OOO_DLLPUBLIC_DBTOOLS
761 void collectColumnInformation( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection,
762 const OUString& _sComposedTableName,
763 const OUString& _rName,
764 ColumnInformationMap& _rInfo);
767 /** adds a boolean comparison clause to the given SQL predicate
769 @param _rExpression
770 the expression which is to be compared with a boolean value
771 @param _bValue
772 the boolean value which the expression is to be compared with
773 @param _nBooleanComparisonMode
774 the boolean comparison mode to be used. Usually obtained from
775 a css.sdb.DataSource's Settings member.
776 @param _out_rSQLPredicate
777 the buffer to which the comparison predicate will be appended
779 OOO_DLLPUBLIC_DBTOOLS void getBooleanComparisonPredicate(
780 const OUString& _rExpression,
781 const bool _bValue,
782 const sal_Int32 _nBooleanComparisonMode,
783 OUStringBuffer& _out_rSQLPredicate
787 } // namespace dbtools
790 #endif // INCLUDED_CONNECTIVITY_DBTOOLS_HXX
792 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */