Bump for 3.6-28
[LibreOffice.git] / connectivity / source / drivers / odbcbase / ODatabaseMetaData.cxx
blob8646565f6879ed24ec56bb015132cbf4c20ca7b0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*************************************************************************
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * Copyright 2000, 2010 Oracle and/or its affiliates.
8 * OpenOffice.org - a multi-platform office productivity suite
10 * This file is part of OpenOffice.org.
12 * OpenOffice.org is free software: you can redistribute it and/or modify
13 * it under the terms of the GNU Lesser General Public License version 3
14 * only, as published by the Free Software Foundation.
16 * OpenOffice.org is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License version 3 for more details
20 * (a copy is included in the LICENSE file that accompanied this code).
22 * You should have received a copy of the GNU Lesser General Public License
23 * version 3 along with OpenOffice.org. If not, see
24 * <http://www.openoffice.org/license.html>
25 * for a copy of the LGPLv3 License.
27 ************************************************************************/
29 #include "odbc/ODatabaseMetaData.hxx"
30 #include "odbc/OTools.hxx"
31 #include "odbc/ODatabaseMetaDataResultSet.hxx"
32 #include "FDatabaseMetaDataResultSet.hxx"
33 #include <com/sun/star/sdbc/DataType.hpp>
34 #include <com/sun/star/sdbc/ResultSetType.hpp>
35 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
36 #include "odbc/OFunctiondefs.hxx"
37 #include "stdio.h"
38 #include "TPrivilegesResultSet.hxx"
39 #include <connectivity/dbexception.hxx>
40 #include <rtl/ustrbuf.hxx>
42 using namespace connectivity::odbc;
43 using namespace com::sun::star::uno;
44 using namespace com::sun::star::lang;
45 using namespace com::sun::star::beans;
46 using namespace com::sun::star::sdbc;
48 ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon)
49 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
50 ,m_aConnectionHandle(_pHandle)
51 ,m_pConnection(_pCon)
52 ,m_bUseCatalog(sal_True)
53 ,m_bOdbc3(sal_True)
55 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
56 if(!m_pConnection->isCatalogUsed())
58 osl_incrementInterlockedCount( &m_refCount );
59 try
61 m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
62 ::rtl::OUString sVersion = getDriverVersion();
63 m_bOdbc3 = sVersion != ::rtl::OUString("02.50") && sVersion != ::rtl::OUString("02.00");
65 catch(SQLException& )
66 { // doesn't matter here
68 osl_decrementInterlockedCount( &m_refCount );
71 // -------------------------------------------------------------------------
72 ODatabaseMetaData::~ODatabaseMetaData()
75 // -------------------------------------------------------------------------
76 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
78 Reference< XResultSet > xRef;
79 try
81 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
82 xRef = pResult;
83 pResult->openTypeInfo();
85 catch(SQLException&)
87 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
90 return xRef;
92 // -------------------------------------------------------------------------
93 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
95 Reference< XResultSet > xRef;
96 if(!m_bUseCatalog)
98 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
100 else
104 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
105 xRef = pResult;
106 pResult->openCatalogs();
108 catch(SQLException&)
110 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
114 return xRef;
116 // -------------------------------------------------------------------------
117 ::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
119 ::rtl::OUString aVal;
120 if ( m_bUseCatalog )
121 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_NAME_SEPARATOR,aVal,*this,m_pConnection->getTextEncoding());
123 return aVal;
125 // -------------------------------------------------------------------------
126 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
128 Reference< XResultSet > xRef;
131 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
132 xRef = pResult;
133 pResult->openSchemas();
135 catch(SQLException&)
137 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eSchemas);
139 return xRef;
141 // -------------------------------------------------------------------------
142 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
143 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
144 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
146 Reference< XResultSet > xRef;
149 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
150 xRef = pResult;
151 pResult->openColumnPrivileges(m_bUseCatalog ? catalog : Any(),schema,table,columnNamePattern);
153 catch(SQLException&)
155 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumnPrivileges);
157 return xRef;
159 // -------------------------------------------------------------------------
160 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
161 const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
162 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
164 Reference< XResultSet > xRef;
167 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
168 xRef = pResult;
169 pResult->openColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,columnNamePattern);
171 catch(SQLException&)
173 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
175 return xRef;
177 // -------------------------------------------------------------------------
178 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
179 const Any& catalog, const ::rtl::OUString& schemaPattern,
180 const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
182 Reference< XResultSet > xRef;
185 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
186 xRef = pResult;
187 pResult->openTables(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,types);
189 catch(SQLException&)
191 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
193 return xRef;
195 // -------------------------------------------------------------------------
196 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
197 const Any& catalog, const ::rtl::OUString& schemaPattern,
198 const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
200 Reference< XResultSet > xRef;
203 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
204 xRef = pResult;
205 pResult->openProcedureColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern,columnNamePattern);
207 catch(SQLException&)
209 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedureColumns);
211 return xRef;
213 // -------------------------------------------------------------------------
214 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
215 const Any& catalog, const ::rtl::OUString& schemaPattern,
216 const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
218 Reference< XResultSet > xRef;
221 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
222 xRef = pResult;
223 pResult->openProcedures(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern);
225 catch(SQLException&)
227 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedures);
229 return xRef;
231 // -------------------------------------------------------------------------
232 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
233 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
235 Reference< XResultSet > xRef;
236 bool bSuccess = false;
239 if ( !m_pConnection->preventGetVersionColumns() )
241 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
242 xRef = pResult;
243 pResult->openVersionColumns(m_bUseCatalog ? catalog : Any(),schema,table);
244 bSuccess = true;
247 catch(SQLException&)
251 if ( !bSuccess )
253 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
256 return xRef;
258 // -------------------------------------------------------------------------
259 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
261 SQLUINTEGER nValue;
262 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_BINARY_LITERAL_LEN,nValue,*this);
263 return nValue;
265 // -------------------------------------------------------------------------
266 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
268 SQLUINTEGER nValue;
269 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE,nValue,*this);
270 return nValue;
272 // -------------------------------------------------------------------------
273 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
275 SQLUSMALLINT nValue;
276 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CATALOG_NAME_LEN,nValue,*this);
277 return nValue;
279 // -------------------------------------------------------------------------
280 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
282 SQLUINTEGER nValue;
283 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CHAR_LITERAL_LEN,nValue,*this);
284 return nValue;
286 // -------------------------------------------------------------------------
287 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
289 SQLUSMALLINT nValue;
290 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMN_NAME_LEN,nValue,*this);
291 return nValue;
293 // -------------------------------------------------------------------------
294 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
296 SQLUSMALLINT nValue;
297 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_INDEX,nValue,*this);
298 return nValue;
300 // -------------------------------------------------------------------------
301 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
303 SQLUSMALLINT nValue;
304 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CURSOR_NAME_LEN,nValue,*this);
305 return nValue;
307 // -------------------------------------------------------------------------
308 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
310 SQLUSMALLINT nValue;
311 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_DRIVER_CONNECTIONS/*SQL_ACTIVE_CONNECTIONS*/,nValue,*this);
312 return nValue;
314 // -------------------------------------------------------------------------
315 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
317 SQLUSMALLINT nValue;
318 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_TABLE,nValue,*this);
319 return nValue;
321 // -------------------------------------------------------------------------
322 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
324 SQLUINTEGER nValue;
325 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_STATEMENT_LEN,nValue,*this);
326 return nValue;
328 // -------------------------------------------------------------------------
329 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
331 SQLUSMALLINT nValue;
332 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLE_NAME_LEN,nValue,*this);
333 return nValue;
335 // -------------------------------------------------------------------------
336 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
338 SQLUSMALLINT nValue;
339 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLES_IN_SELECT,nValue,*this);
340 return nValue;
342 // -------------------------------------------------------------------------
343 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
344 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
346 Reference< XResultSet > xRef;
349 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
350 xRef = pResult;
351 pResult->openExportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
353 catch(SQLException&)
355 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eExportedKeys);
357 return xRef;
359 // -------------------------------------------------------------------------
360 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
361 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
363 Reference< XResultSet > xRef;
366 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
367 xRef = pResult;
368 pResult->openImportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
370 catch(SQLException&)
372 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eImportedKeys);
374 return xRef;
376 // -------------------------------------------------------------------------
377 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
378 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
380 Reference< XResultSet > xRef;
383 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
384 xRef = pResult;
385 pResult->openPrimaryKeys(m_bUseCatalog ? catalog : Any(),schema,table);
387 catch(SQLException&)
389 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::ePrimaryKeys);
391 return xRef;
393 // -------------------------------------------------------------------------
394 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
395 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
396 sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
398 Reference< XResultSet > xRef;
401 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
402 xRef = pResult;
403 pResult->openIndexInfo(m_bUseCatalog ? catalog : Any(),schema,table,unique,approximate);
405 catch(SQLException&)
407 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo);
409 return xRef;
411 // -------------------------------------------------------------------------
412 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
413 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
414 sal_Bool nullable ) throw(SQLException, RuntimeException)
416 Reference< XResultSet > xRef;
419 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
420 xRef = pResult;
421 pResult->openBestRowIdentifier(m_bUseCatalog ? catalog : Any(),schema,table,scope,nullable);
423 catch(SQLException&)
425 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eBestRowIdentifier);
427 return xRef;
429 // -------------------------------------------------------------------------
430 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
431 const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
433 if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
435 return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
437 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
438 Reference< XResultSet > xRef = pResult;
439 pResult->openTablePrivileges(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern);
440 return xRef;
442 // -------------------------------------------------------------------------
443 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
444 const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
445 const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
446 const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
448 Reference< XResultSet > xRef;
451 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
452 xRef = pResult;
453 pResult->openForeignKeys(m_bUseCatalog ? primaryCatalog : Any(),primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable,
454 m_bUseCatalog ? foreignCatalog : Any(), foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable);
456 catch(SQLException&)
458 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCrossReference);
460 return xRef;
462 // -------------------------------------------------------------------------
463 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
465 ::rtl::OUString aVal;
466 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE_INCLUDES_LONG,aVal,*this,m_pConnection->getTextEncoding());
467 return aVal.toChar() == 'Y';
469 // -------------------------------------------------------------------------
470 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
472 SQLUSMALLINT nValue;
473 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
474 return nValue == SQL_IC_LOWER;
476 // -------------------------------------------------------------------------
477 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
479 SQLUSMALLINT nValue;
480 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
481 return nValue == SQL_IC_LOWER;
483 // -------------------------------------------------------------------------
484 sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
486 SQLUSMALLINT nValue;
487 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
488 return nValue == SQL_IC_MIXED;
490 // -------------------------------------------------------------------------
491 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
493 SQLUSMALLINT nValue;
494 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
495 return nValue == SQL_IC_MIXED;
497 // -------------------------------------------------------------------------
498 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
500 SQLUSMALLINT nValue;
501 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
502 return nValue == SQL_IC_UPPER;
504 // -------------------------------------------------------------------------
505 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
507 SQLUSMALLINT nValue;
508 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
509 return nValue == SQL_IC_UPPER;
511 // -------------------------------------------------------------------------
512 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
514 SQLUINTEGER nValue;
515 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
516 return (nValue & SQL_AT_ADD_COLUMN) == SQL_AT_ADD_COLUMN;
518 // -------------------------------------------------------------------------
519 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
521 SQLUINTEGER nValue;
522 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
523 return ((nValue & SQL_AT_DROP_COLUMN) == SQL_AT_DROP_COLUMN) ||
524 ((nValue & SQL_AT_DROP_COLUMN_CASCADE) == SQL_AT_DROP_COLUMN_CASCADE) ||
525 ((nValue & SQL_AT_DROP_COLUMN_RESTRICT) == SQL_AT_DROP_COLUMN_RESTRICT);
527 // -------------------------------------------------------------------------
528 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
530 SQLUINTEGER nValue;
531 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_INDEX_SIZE,nValue,*this);
532 return nValue;
534 // -------------------------------------------------------------------------
535 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
537 SQLUSMALLINT nValue;
538 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NON_NULLABLE_COLUMNS,nValue,*this);
539 return nValue == SQL_NNC_NON_NULL;
541 // -------------------------------------------------------------------------
542 ::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
544 ::rtl::OUString aVal;
545 if(m_bUseCatalog)
546 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_TERM,aVal,*this,m_pConnection->getTextEncoding());
547 return aVal;
549 // -------------------------------------------------------------------------
550 ::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
552 ::rtl::OUString aVal;
553 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_QUOTE_CHAR,aVal,*this,m_pConnection->getTextEncoding());
554 return aVal;
556 // -------------------------------------------------------------------------
557 ::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
559 ::rtl::OUString aVal;
560 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SPECIAL_CHARACTERS,aVal,*this,m_pConnection->getTextEncoding());
561 return aVal;
563 // -------------------------------------------------------------------------
564 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
566 SQLUSMALLINT nValue;
567 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
568 return nValue != SQL_CN_NONE;
570 // -------------------------------------------------------------------------
571 sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
573 SQLUSMALLINT nValue=0;
574 if ( m_bUseCatalog )
575 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_LOCATION,nValue,*this);
576 return nValue == SQL_CL_START;
578 // -------------------------------------------------------------------------
579 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
581 SQLUSMALLINT nValue;
582 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
583 return nValue == SQL_TC_DDL_IGNORE;
585 // -------------------------------------------------------------------------
586 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
588 SQLUSMALLINT nValue;
589 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
590 return nValue == SQL_TC_DDL_COMMIT;
592 // -------------------------------------------------------------------------
593 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
595 SQLUSMALLINT nValue;
596 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
597 return nValue == SQL_TC_DML;
599 // -------------------------------------------------------------------------
600 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
602 SQLUSMALLINT nValue;
603 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
604 return nValue == SQL_TC_ALL;
606 // -------------------------------------------------------------------------
607 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
609 SQLUINTEGER nValue;
610 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
611 return (nValue & SQL_CA1_POS_DELETE) == SQL_CA1_POS_DELETE;
613 // -------------------------------------------------------------------------
614 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
616 SQLUINTEGER nValue;
617 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
618 return (nValue & SQL_CA1_POS_UPDATE) == SQL_CA1_POS_UPDATE;
620 // -------------------------------------------------------------------------
621 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
623 SQLUSMALLINT nValue;
624 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
625 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
627 // -------------------------------------------------------------------------
628 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
630 SQLUSMALLINT nValue;
631 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
632 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
634 // -------------------------------------------------------------------------
635 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
637 SQLUSMALLINT nValue;
638 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
639 return nValue == SQL_CB_PRESERVE;
641 // -------------------------------------------------------------------------
642 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
644 SQLUSMALLINT nValue;
645 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
646 return nValue == SQL_CB_PRESERVE;
648 // -------------------------------------------------------------------------
649 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
651 SQLUINTEGER nValue;
652 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_ISOLATION_OPTION,nValue,*this);
653 return (nValue & static_cast<SQLUINTEGER>(level)) == static_cast<SQLUINTEGER>(level);
655 // -------------------------------------------------------------------------
656 sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
658 SQLUINTEGER nValue;
659 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
660 return (nValue & SQL_SU_DML_STATEMENTS) == SQL_SU_DML_STATEMENTS;
662 // -------------------------------------------------------------------------
663 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
665 SQLUINTEGER nValue;
666 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
667 return nValue == SQL_SC_SQL92_FULL;
669 // -------------------------------------------------------------------------
670 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
672 SQLUINTEGER nValue;
673 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
674 return nValue == SQL_SC_SQL92_ENTRY;
676 // -------------------------------------------------------------------------
677 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
679 ::rtl::OUString aStr;
680 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_INTEGRITY,aStr,*this,m_pConnection->getTextEncoding());
681 return aStr.toChar() == 'Y';
683 // -------------------------------------------------------------------------
684 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
686 SQLUINTEGER nValue;
687 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
688 return (nValue & SQL_SU_INDEX_DEFINITION) == SQL_SU_INDEX_DEFINITION;
690 // -------------------------------------------------------------------------
691 sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
693 SQLUINTEGER nValue;
694 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
695 return (nValue & SQL_SU_TABLE_DEFINITION) == SQL_SU_TABLE_DEFINITION;
697 // -------------------------------------------------------------------------
698 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
700 SQLUINTEGER nValue=0;
701 if(m_bUseCatalog)
702 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
703 return (nValue & SQL_CU_TABLE_DEFINITION) == SQL_CU_TABLE_DEFINITION;
705 // -------------------------------------------------------------------------
706 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
708 SQLUINTEGER nValue=0;
709 if(m_bUseCatalog)
710 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
711 return (nValue & SQL_CU_INDEX_DEFINITION) == SQL_CU_INDEX_DEFINITION;
713 // -------------------------------------------------------------------------
714 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
716 SQLUINTEGER nValue=0;
717 if(m_bUseCatalog)
718 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
719 return (nValue & SQL_CU_DML_STATEMENTS) == SQL_CU_DML_STATEMENTS;
721 // -------------------------------------------------------------------------
722 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
724 SQLUINTEGER nValue;
725 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
726 return ((nValue & (SQL_OJ_FULL|SQL_OJ_LEFT|SQL_OJ_RIGHT|SQL_OJ_NESTED|SQL_OJ_NOT_ORDERED|SQL_OJ_ALL_COMPARISON_OPS|SQL_OJ_INNER)) != 0);
728 // -------------------------------------------------------------------------
729 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
731 Reference< XResultSet > xRef;
734 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
735 xRef = pResult;
736 pResult->openTablesTypes();
738 catch(SQLException&)
740 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
742 return xRef;
744 // -------------------------------------------------------------------------
745 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
747 SQLUSMALLINT nValue;
748 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CONCURRENT_ACTIVITIES,nValue,*this);
749 return nValue;
751 // -------------------------------------------------------------------------
752 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
754 SQLUSMALLINT nValue;
755 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_PROCEDURE_NAME_LEN,nValue,*this);
756 return nValue;
758 // -------------------------------------------------------------------------
759 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
761 SQLUSMALLINT nValue;
762 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_SCHEMA_NAME_LEN,nValue,*this);
763 return nValue;
765 // -------------------------------------------------------------------------
766 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
768 SQLUSMALLINT nValue;
769 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
770 return nValue != SQL_TC_NONE;
772 // -------------------------------------------------------------------------
773 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
775 ::rtl::OUString aValue;
776 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
777 return aValue.toChar() == 'Y';
779 // -------------------------------------------------------------------------
780 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
782 ::rtl::OUString aValue;
783 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
784 return aValue.toChar() == 'Y';
786 // -------------------------------------------------------------------------
787 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
789 SQLUINTEGER nValue;
790 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
791 return (nValue & SQL_CA1_POSITIONED_UPDATE) == SQL_CA1_POSITIONED_UPDATE;
793 // -------------------------------------------------------------------------
794 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
796 ::rtl::OUString aValue;
797 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_TABLES,aValue,*this,m_pConnection->getTextEncoding());
798 return aValue.toChar() == 'Y';
800 // -------------------------------------------------------------------------
801 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
803 return m_pConnection->isReadOnly();
805 // -------------------------------------------------------------------------
806 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
808 SQLUSMALLINT nValue;
809 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
810 return nValue == SQL_FILE_CATALOG;
812 // -------------------------------------------------------------------------
813 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
815 SQLUSMALLINT nValue;
816 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
817 return nValue == SQL_FILE_TABLE;
819 // -------------------------------------------------------------------------
820 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
822 SQLUINTEGER nValue;
823 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FUNCTIONS,nValue,*this);
824 return (nValue & SQL_FN_CVT_CONVERT) == SQL_FN_CVT_CONVERT;
826 // -------------------------------------------------------------------------
827 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
829 SQLUSMALLINT nValue;
830 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONCAT_NULL_BEHAVIOR,nValue,*this);
831 return nValue == SQL_CB_NULL;
833 // -------------------------------------------------------------------------
834 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
836 ::rtl::OUString aValue;
837 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_COLUMN_ALIAS,aValue,*this,m_pConnection->getTextEncoding());
838 return aValue.toChar() == 'Y';
840 // -------------------------------------------------------------------------
841 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
843 SQLUSMALLINT nValue;
844 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
845 return nValue != SQL_CN_NONE;
847 // -------------------------------------------------------------------------
848 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException)
850 if(fromType == toType)
851 return sal_True;
853 SQLUINTEGER nValue=0;
854 switch(fromType)
856 case DataType::BIT:
857 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIT,nValue,*this);
858 break;
859 case DataType::TINYINT:
860 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TINYINT,nValue,*this);
861 break;
862 case DataType::SMALLINT:
863 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_SMALLINT,nValue,*this);
864 break;
865 case DataType::INTEGER:
866 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_INTEGER,nValue,*this);
867 break;
868 case DataType::BIGINT:
869 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIGINT,nValue,*this);
870 break;
871 case DataType::FLOAT:
872 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FLOAT,nValue,*this);
873 break;
874 case DataType::REAL:
875 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_REAL,nValue,*this);
876 break;
877 case DataType::DOUBLE:
878 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DOUBLE,nValue,*this);
879 break;
880 case DataType::NUMERIC:
881 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_NUMERIC,nValue,*this);
882 break;
883 case DataType::DECIMAL:
884 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DECIMAL,nValue,*this);
885 break;
886 case DataType::CHAR:
887 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_CHAR,nValue,*this);
888 break;
889 case DataType::VARCHAR:
890 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this);
891 break;
892 case DataType::LONGVARCHAR:
893 case DataType::CLOB:
894 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this);
895 break;
896 case DataType::DATE:
897 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DATE,nValue,*this);
898 break;
899 case DataType::TIME:
900 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIME,nValue,*this);
901 break;
902 case DataType::TIMESTAMP:
903 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIMESTAMP,nValue,*this);
904 break;
905 case DataType::BINARY:
906 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BINARY,nValue,*this);
907 break;
908 case DataType::VARBINARY:
909 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this);
910 break;
911 case DataType::LONGVARBINARY:
912 case DataType::BLOB:
913 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this);
914 break;
915 case DataType::SQLNULL:
916 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
917 break;
918 case DataType::OTHER:
919 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
920 break;
921 case DataType::OBJECT:
922 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
923 break;
924 case DataType::DISTINCT:
925 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
926 break;
927 case DataType::STRUCT:
928 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
929 break;
930 case DataType::ARRAY:
931 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
932 break;
933 case DataType::REF:
934 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
935 break;
937 sal_Bool bConvert = sal_False;
938 switch(toType)
940 case DataType::BIT:
941 bConvert = (nValue & SQL_CVT_BIT) == SQL_CVT_BIT;
942 break;
943 case DataType::TINYINT:
944 bConvert = (nValue & SQL_CVT_TINYINT) == SQL_CVT_TINYINT;
945 break;
946 case DataType::SMALLINT:
947 bConvert = (nValue & SQL_CVT_SMALLINT) == SQL_CVT_SMALLINT;
948 break;
949 case DataType::INTEGER:
950 bConvert = (nValue & SQL_CVT_INTEGER) == SQL_CVT_INTEGER;
951 break;
952 case DataType::BIGINT:
953 bConvert = (nValue & SQL_CVT_BIGINT) == SQL_CVT_BIGINT;
954 break;
955 case DataType::FLOAT:
956 bConvert = (nValue & SQL_CVT_FLOAT) == SQL_CVT_FLOAT;
957 break;
958 case DataType::REAL:
959 bConvert = (nValue & SQL_CVT_REAL) == SQL_CVT_REAL;
960 break;
961 case DataType::DOUBLE:
962 bConvert = (nValue & SQL_CVT_DOUBLE) == SQL_CVT_DOUBLE;
963 break;
964 case DataType::NUMERIC:
965 bConvert = (nValue & SQL_CVT_NUMERIC) == SQL_CVT_NUMERIC;
966 break;
967 case DataType::DECIMAL:
968 bConvert = (nValue & SQL_CVT_DECIMAL) == SQL_CVT_DECIMAL;
969 break;
970 case DataType::CHAR:
971 bConvert = (nValue & SQL_CVT_CHAR) == SQL_CVT_CHAR;
972 break;
973 case DataType::VARCHAR:
974 bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR;
975 break;
976 case DataType::LONGVARCHAR:
977 case DataType::CLOB:
978 bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR;
979 break;
980 case DataType::DATE:
981 bConvert = (nValue & SQL_CVT_DATE) == SQL_CVT_DATE;
982 break;
983 case DataType::TIME:
984 bConvert = (nValue & SQL_CVT_TIME) == SQL_CVT_TIME;
985 break;
986 case DataType::TIMESTAMP:
987 bConvert = (nValue & SQL_CVT_TIMESTAMP) == SQL_CVT_TIMESTAMP;
988 break;
989 case DataType::BINARY:
990 bConvert = (nValue & SQL_CVT_BINARY) == SQL_CVT_BINARY;
991 break;
992 case DataType::VARBINARY:
993 bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY;
994 break;
995 case DataType::LONGVARBINARY:
996 case DataType::BLOB:
997 bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY;
998 break;
1001 return bConvert;
1003 // -------------------------------------------------------------------------
1004 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
1006 ::rtl::OUString aValue;
1007 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_EXPRESSIONS_IN_ORDERBY,aValue,*this,m_pConnection->getTextEncoding());
1008 return aValue.toChar() == 'Y';
1010 // -------------------------------------------------------------------------
1011 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
1013 SQLUSMALLINT nValue;
1014 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1015 return nValue != SQL_GB_NOT_SUPPORTED;
1017 // -------------------------------------------------------------------------
1018 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
1020 SQLUSMALLINT nValue;
1021 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1022 return nValue != SQL_GB_GROUP_BY_CONTAINS_SELECT;
1024 // -------------------------------------------------------------------------
1025 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
1027 SQLUSMALLINT nValue;
1028 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1029 return nValue == SQL_GB_NO_RELATION;
1031 // -------------------------------------------------------------------------
1032 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
1034 ::rtl::OUString aValue;
1035 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULTIPLE_ACTIVE_TXN,aValue,*this,m_pConnection->getTextEncoding());
1036 return aValue.toChar() == 'Y';
1038 // -------------------------------------------------------------------------
1039 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
1041 ::rtl::OUString aValue;
1042 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULT_RESULT_SETS,aValue,*this,m_pConnection->getTextEncoding());
1043 return aValue.toChar() == 'Y';
1045 // -------------------------------------------------------------------------
1046 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
1048 ::rtl::OUString aValue;
1049 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_LIKE_ESCAPE_CLAUSE,aValue,*this,m_pConnection->getTextEncoding());
1050 return aValue.toChar() == 'Y';
1052 // -------------------------------------------------------------------------
1053 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
1055 ::rtl::OUString aValue;
1056 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ORDER_BY_COLUMNS_IN_SELECT,aValue,*this,m_pConnection->getTextEncoding());
1057 return aValue.toChar() == 'N';
1059 // -------------------------------------------------------------------------
1060 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
1062 SQLUINTEGER nValue;
1063 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1064 return (nValue & SQL_U_UNION) == SQL_U_UNION;
1066 // -------------------------------------------------------------------------
1067 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
1069 SQLUINTEGER nValue;
1070 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1071 return (nValue & SQL_U_UNION_ALL) == SQL_U_UNION_ALL;
1073 // -------------------------------------------------------------------------
1074 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
1076 SQLUSMALLINT nValue;
1077 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
1078 return nValue == SQL_IC_MIXED;
1080 // -------------------------------------------------------------------------
1081 sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1083 SQLUSMALLINT nValue;
1084 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
1085 return nValue == SQL_IC_MIXED;
1087 // -------------------------------------------------------------------------
1088 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
1090 SQLUSMALLINT nValue;
1091 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1092 return nValue == SQL_NC_END;
1094 // -------------------------------------------------------------------------
1095 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
1097 SQLUSMALLINT nValue;
1098 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1099 return nValue == SQL_NC_START;
1101 // -------------------------------------------------------------------------
1102 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
1104 SQLUSMALLINT nValue;
1105 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1106 return nValue == SQL_NC_HIGH;
1108 // -------------------------------------------------------------------------
1109 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
1111 SQLUSMALLINT nValue;
1112 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1113 return nValue == SQL_NC_LOW;
1115 // -------------------------------------------------------------------------
1116 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
1118 SQLUINTEGER nValue;
1119 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1120 return (nValue & SQL_SU_PROCEDURE_INVOCATION) == SQL_SU_PROCEDURE_INVOCATION;
1122 // -------------------------------------------------------------------------
1123 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
1125 SQLUINTEGER nValue;
1126 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1127 return (nValue & SQL_SU_PRIVILEGE_DEFINITION) == SQL_SU_PRIVILEGE_DEFINITION;
1129 // -------------------------------------------------------------------------
1130 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
1132 SQLUINTEGER nValue=0;
1133 if(m_bUseCatalog)
1134 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1135 return (nValue & SQL_CU_PROCEDURE_INVOCATION) == SQL_CU_PROCEDURE_INVOCATION;
1137 // -------------------------------------------------------------------------
1138 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
1140 SQLUINTEGER nValue=0;
1141 if(m_bUseCatalog)
1142 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1143 return (nValue & SQL_CU_PRIVILEGE_DEFINITION) == SQL_CU_PRIVILEGE_DEFINITION;
1145 // -------------------------------------------------------------------------
1146 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
1148 SQLUINTEGER nValue;
1149 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1150 return (nValue & SQL_SQ_CORRELATED_SUBQUERIES) == SQL_SQ_CORRELATED_SUBQUERIES;
1152 // -------------------------------------------------------------------------
1153 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
1155 SQLUINTEGER nValue;
1156 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1157 return (nValue & SQL_SQ_COMPARISON) == SQL_SQ_COMPARISON;
1159 // -------------------------------------------------------------------------
1160 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
1162 SQLUINTEGER nValue;
1163 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1164 return (nValue & SQL_SQ_EXISTS) == SQL_SQ_EXISTS;
1166 // -------------------------------------------------------------------------
1167 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
1169 SQLUINTEGER nValue;
1170 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1171 return (nValue & SQL_SQ_IN) == SQL_SQ_IN;
1173 // -------------------------------------------------------------------------
1174 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
1176 SQLUINTEGER nValue;
1177 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1178 return (nValue & SQL_SQ_QUANTIFIED) == SQL_SQ_QUANTIFIED;
1180 // -------------------------------------------------------------------------
1181 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
1183 SQLUINTEGER nValue;
1184 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
1185 return nValue == SQL_SC_SQL92_INTERMEDIATE;
1187 // -----------------------------------------------------------------------------
1188 ::rtl::OUString ODatabaseMetaData::getURLImpl()
1190 ::rtl::OUString aValue;
1191 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_NAME,aValue,*this,m_pConnection->getTextEncoding());
1192 return aValue;
1194 // -------------------------------------------------------------------------
1195 ::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
1197 ::rtl::OUString aValue = m_pConnection->getURL();
1198 if ( aValue.isEmpty() )
1200 aValue = ::rtl::OUString("sdbc:odbc:");
1201 aValue += getURLImpl();
1203 return aValue;
1205 // -------------------------------------------------------------------------
1206 ::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
1208 ::rtl::OUString aValue;
1209 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_USER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1210 return aValue;
1212 // -------------------------------------------------------------------------
1213 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
1215 ::rtl::OUString aValue;
1216 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1217 return aValue;
1219 // -------------------------------------------------------------------------
1220 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
1222 ::rtl::OUString aValue;
1223 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_ODBC_VER,aValue,*this,m_pConnection->getTextEncoding());
1224 return aValue;
1226 // -------------------------------------------------------------------------
1227 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
1229 ::rtl::OUString aValue;
1230 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1231 return aValue;
1233 // -------------------------------------------------------------------------
1234 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
1236 ::rtl::OUString aValue;
1237 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DBMS_NAME,aValue,*this,m_pConnection->getTextEncoding());
1238 return aValue;
1240 // -------------------------------------------------------------------------
1241 ::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
1243 ::rtl::OUString aValue;
1244 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURE_TERM,aValue,*this,m_pConnection->getTextEncoding());
1245 return aValue;
1247 // -------------------------------------------------------------------------
1248 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
1250 ::rtl::OUString aValue;
1251 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_TERM,aValue,*this,m_pConnection->getTextEncoding());
1252 return aValue;
1254 // -------------------------------------------------------------------------
1255 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
1257 ::rtl::OUString aValue;
1258 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1259 return aValue.copy(0,aValue.indexOf('.')).toInt32();
1261 // -------------------------------------------------------------------------
1262 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
1264 SQLUINTEGER nValue;
1265 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1266 return nValue;
1268 // -------------------------------------------------------------------------
1269 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
1271 ::rtl::OUString aValue;
1272 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1273 return aValue.copy(0,aValue.lastIndexOf('.')).toInt32();
1275 // -------------------------------------------------------------------------
1276 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
1278 ::rtl::OUString aValue;
1279 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_KEYWORDS,aValue,*this,m_pConnection->getTextEncoding());
1280 return aValue;
1282 // -------------------------------------------------------------------------
1283 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
1285 ::rtl::OUString aValue;
1286 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SEARCH_PATTERN_ESCAPE,aValue,*this,m_pConnection->getTextEncoding());
1287 return aValue;
1289 // -------------------------------------------------------------------------
1290 ::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
1292 SQLUINTEGER nValue;
1293 ::rtl::OUStringBuffer aValue;
1294 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
1295 if(nValue & SQL_FN_STR_ASCII)
1296 aValue.appendAscii("ASCII,");
1297 if(nValue & SQL_FN_STR_BIT_LENGTH)
1298 aValue.appendAscii("BIT_LENGTH,");
1299 if(nValue & SQL_FN_STR_CHAR)
1300 aValue.appendAscii("CHAR,");
1301 if(nValue & SQL_FN_STR_CHAR_LENGTH)
1302 aValue.appendAscii("CHAR_LENGTH,");
1303 if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
1304 aValue.appendAscii("CHARACTER_LENGTH,");
1305 if(nValue & SQL_FN_STR_CONCAT)
1306 aValue.appendAscii("CONCAT,");
1307 if(nValue & SQL_FN_STR_DIFFERENCE)
1308 aValue.appendAscii("DIFFERENCE,");
1309 if(nValue & SQL_FN_STR_INSERT)
1310 aValue.appendAscii("INSERT,");
1311 if(nValue & SQL_FN_STR_LCASE)
1312 aValue.appendAscii("LCASE,");
1313 if(nValue & SQL_FN_STR_LEFT)
1314 aValue.appendAscii("LEFT,");
1315 if(nValue & SQL_FN_STR_LENGTH)
1316 aValue.appendAscii("LENGTH,");
1317 if(nValue & SQL_FN_STR_LOCATE)
1318 aValue.appendAscii("LOCATE,");
1319 if(nValue & SQL_FN_STR_LOCATE_2)
1320 aValue.appendAscii("LOCATE_2,");
1321 if(nValue & SQL_FN_STR_LTRIM)
1322 aValue.appendAscii("LTRIM,");
1323 if(nValue & SQL_FN_STR_OCTET_LENGTH)
1324 aValue.appendAscii("OCTET_LENGTH,");
1325 if(nValue & SQL_FN_STR_POSITION)
1326 aValue.appendAscii("POSITION,");
1327 if(nValue & SQL_FN_STR_REPEAT)
1328 aValue.appendAscii("REPEAT,");
1329 if(nValue & SQL_FN_STR_REPLACE)
1330 aValue.appendAscii("REPLACE,");
1331 if(nValue & SQL_FN_STR_RIGHT)
1332 aValue.appendAscii("RIGHT,");
1333 if(nValue & SQL_FN_STR_RTRIM)
1334 aValue.appendAscii("RTRIM,");
1335 if(nValue & SQL_FN_STR_SOUNDEX)
1336 aValue.appendAscii("SOUNDEX,");
1337 if(nValue & SQL_FN_STR_SPACE)
1338 aValue.appendAscii("SPACE,");
1339 if(nValue & SQL_FN_STR_SUBSTRING)
1340 aValue.appendAscii("SUBSTRING,");
1341 if(nValue & SQL_FN_STR_UCASE)
1342 aValue.appendAscii("UCASE,");
1345 if ( aValue.getLength() )
1346 aValue.setLength(aValue.getLength()-1);
1348 return aValue.makeStringAndClear();
1350 // -------------------------------------------------------------------------
1351 ::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
1353 SQLUINTEGER nValue;
1354 ::rtl::OUStringBuffer aValue;
1355 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this);
1357 if(nValue & SQL_FN_TD_CURRENT_DATE)
1358 aValue.appendAscii("CURRENT_DATE,");
1359 if(nValue & SQL_FN_TD_CURRENT_TIME)
1360 aValue.appendAscii("CURRENT_TIME,");
1361 if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP)
1362 aValue.appendAscii("CURRENT_TIMESTAMP,");
1363 if(nValue & SQL_FN_TD_CURDATE)
1364 aValue.appendAscii("CURDATE,");
1365 if(nValue & SQL_FN_TD_CURTIME)
1366 aValue.appendAscii("CURTIME,");
1367 if(nValue & SQL_FN_TD_DAYNAME)
1368 aValue.appendAscii("DAYNAME,");
1369 if(nValue & SQL_FN_TD_DAYOFMONTH)
1370 aValue.appendAscii("DAYOFMONTH,");
1371 if(nValue & SQL_FN_TD_DAYOFWEEK)
1372 aValue.appendAscii("DAYOFWEEK,");
1373 if(nValue & SQL_FN_TD_DAYOFYEAR)
1374 aValue.appendAscii("DAYOFYEAR,");
1375 if(nValue & SQL_FN_TD_EXTRACT)
1376 aValue.appendAscii("EXTRACT,");
1377 if(nValue & SQL_FN_TD_HOUR)
1378 aValue.appendAscii("HOUR,");
1379 if(nValue & SQL_FN_TD_MINUTE)
1380 aValue.appendAscii("MINUTE,");
1381 if(nValue & SQL_FN_TD_MONTH)
1382 aValue.appendAscii("MONTH,");
1383 if(nValue & SQL_FN_TD_MONTHNAME)
1384 aValue.appendAscii("MONTHNAME,");
1385 if(nValue & SQL_FN_TD_NOW)
1386 aValue.appendAscii("NOW,");
1387 if(nValue & SQL_FN_TD_QUARTER)
1388 aValue.appendAscii("QUARTER,");
1389 if(nValue & SQL_FN_TD_SECOND)
1390 aValue.appendAscii("SECOND,");
1391 if(nValue & SQL_FN_TD_TIMESTAMPADD)
1392 aValue.appendAscii("TIMESTAMPADD,");
1393 if(nValue & SQL_FN_TD_TIMESTAMPDIFF)
1394 aValue.appendAscii("TIMESTAMPDIFF,");
1395 if(nValue & SQL_FN_TD_WEEK)
1396 aValue.appendAscii("WEEK,");
1397 if(nValue & SQL_FN_TD_YEAR)
1398 aValue.appendAscii("YEAR,");
1400 if ( aValue.getLength() )
1401 aValue.setLength(aValue.getLength()-1);
1403 return aValue.makeStringAndClear();
1405 // -------------------------------------------------------------------------
1406 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
1408 SQLUINTEGER nValue;
1409 ::rtl::OUStringBuffer aValue;
1410 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this);
1412 if(nValue & SQL_FN_SYS_DBNAME)
1413 aValue.appendAscii("DBNAME,");
1414 if(nValue & SQL_FN_SYS_IFNULL)
1415 aValue.appendAscii("IFNULL,");
1416 if(nValue & SQL_FN_SYS_USERNAME)
1417 aValue.appendAscii("USERNAME,");
1419 if ( aValue.getLength() )
1420 aValue.setLength(aValue.getLength()-1);
1422 return aValue.makeStringAndClear();
1424 // -------------------------------------------------------------------------
1425 ::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
1427 SQLUINTEGER nValue;
1428 ::rtl::OUStringBuffer aValue;
1429 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this);
1431 if(nValue & SQL_FN_NUM_ABS)
1432 aValue.appendAscii("ABS,");
1433 if(nValue & SQL_FN_NUM_ACOS)
1434 aValue.appendAscii("ACOS,");
1435 if(nValue & SQL_FN_NUM_ASIN)
1436 aValue.appendAscii("ASIN,");
1437 if(nValue & SQL_FN_NUM_ATAN)
1438 aValue.appendAscii("ATAN,");
1439 if(nValue & SQL_FN_NUM_ATAN2)
1440 aValue.appendAscii("ATAN2,");
1441 if(nValue & SQL_FN_NUM_CEILING)
1442 aValue.appendAscii("CEILING,");
1443 if(nValue & SQL_FN_NUM_COS)
1444 aValue.appendAscii("COS,");
1445 if(nValue & SQL_FN_NUM_COT)
1446 aValue.appendAscii("COT,");
1447 if(nValue & SQL_FN_NUM_DEGREES)
1448 aValue.appendAscii("DEGREES,");
1449 if(nValue & SQL_FN_NUM_EXP)
1450 aValue.appendAscii("EXP,");
1451 if(nValue & SQL_FN_NUM_FLOOR)
1452 aValue.appendAscii("FLOOR,");
1453 if(nValue & SQL_FN_NUM_LOG)
1454 aValue.appendAscii("LOGF,");
1455 if(nValue & SQL_FN_NUM_LOG10)
1456 aValue.appendAscii("LOG10,");
1457 if(nValue & SQL_FN_NUM_MOD)
1458 aValue.appendAscii("MOD,");
1459 if(nValue & SQL_FN_NUM_PI)
1460 aValue.appendAscii("PI,");
1461 if(nValue & SQL_FN_NUM_POWER)
1462 aValue.appendAscii("POWER,");
1463 if(nValue & SQL_FN_NUM_RADIANS)
1464 aValue.appendAscii("RADIANS,");
1465 if(nValue & SQL_FN_NUM_RAND)
1466 aValue.appendAscii("RAND,");
1467 if(nValue & SQL_FN_NUM_ROUND)
1468 aValue.appendAscii("ROUND,");
1469 if(nValue & SQL_FN_NUM_SIGN)
1470 aValue.appendAscii("SIGN,");
1471 if(nValue & SQL_FN_NUM_SIN)
1472 aValue.appendAscii("SIN,");
1473 if(nValue & SQL_FN_NUM_SQRT)
1474 aValue.appendAscii("SQRT,");
1475 if(nValue & SQL_FN_NUM_TAN)
1476 aValue.appendAscii("TAN,");
1477 if(nValue & SQL_FN_NUM_TRUNCATE)
1478 aValue.appendAscii("TRUNCATE,");
1480 if ( aValue.getLength() )
1481 aValue.setLength(aValue.getLength()-1);
1483 return aValue.makeStringAndClear();
1485 // -------------------------------------------------------------------------
1486 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
1488 SQLUINTEGER nValue;
1489 if(m_bOdbc3)
1491 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1492 return nValue == SQL_OIC_LEVEL2;
1494 else
1496 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1497 return nValue == SQL_OAC_LEVEL2;
1500 // -------------------------------------------------------------------------
1501 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
1503 SQLUINTEGER nValue;
1504 if(m_bOdbc3)
1506 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1507 return nValue == SQL_OIC_CORE || nValue == SQL_OIC_LEVEL2 || nValue == SQL_OIC_LEVEL1;
1509 else
1511 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
1512 return nValue == SQL_OSC_CORE || nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
1515 // -------------------------------------------------------------------------
1516 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
1518 SQLUINTEGER nValue;
1519 if(m_bOdbc3)
1521 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1522 return nValue == SQL_OIC_LEVEL1 || nValue == SQL_OIC_LEVEL2;
1524 else
1526 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1527 return nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
1530 // -------------------------------------------------------------------------
1531 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
1533 SQLUINTEGER nValue;
1534 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
1535 return (nValue & SQL_OJ_FULL) == SQL_OJ_FULL;
1537 // -------------------------------------------------------------------------
1538 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
1540 return supportsFullOuterJoins( );
1542 // -------------------------------------------------------------------------
1543 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
1545 SQLUSMALLINT nValue;
1546 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_GROUP_BY,nValue,*this);
1547 return nValue;
1549 // -------------------------------------------------------------------------
1550 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
1552 SQLUSMALLINT nValue;
1553 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_ORDER_BY,nValue,*this);
1554 return nValue;
1556 // -------------------------------------------------------------------------
1557 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
1559 SQLUSMALLINT nValue;
1560 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_SELECT,nValue,*this);
1561 return nValue;
1563 // -------------------------------------------------------------------------
1564 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
1566 SQLUSMALLINT nValue;
1567 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_USER_NAME_LEN,nValue,*this);
1568 return nValue;
1570 // -------------------------------------------------------------------------
1571 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
1573 SQLUINTEGER nValue;
1574 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_SENSITIVITY,nValue,*this);
1575 return (nValue & static_cast<SQLUINTEGER>(setType)) == static_cast<SQLUINTEGER>(setType);
1577 // -------------------------------------------------------------------------
1578 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException)
1580 SQLUINTEGER nValue;
1581 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1582 switch(setType)
1584 default:
1585 case ResultSetType::FORWARD_ONLY:
1586 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1587 break;
1588 case ResultSetType::SCROLL_INSENSITIVE:
1589 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1590 break;
1591 case ResultSetType::SCROLL_SENSITIVE:
1592 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1593 break;
1596 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1597 sal_Bool bRet = sal_False;
1598 switch(concurrency)
1600 case ResultSetConcurrency::READ_ONLY:
1601 bRet = (nValue & SQL_CA2_READ_ONLY_CONCURRENCY) == SQL_CA2_READ_ONLY_CONCURRENCY;
1602 break;
1603 case ResultSetConcurrency::UPDATABLE:
1604 bRet = (nValue & SQL_CA2_OPT_VALUES_CONCURRENCY) == SQL_CA2_OPT_VALUES_CONCURRENCY;
1605 break;
1607 return bRet;
1609 // -------------------------------------------------------------------------
1610 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1612 SQLUINTEGER nValue;
1613 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1614 switch(setType)
1616 default:
1617 case ResultSetType::FORWARD_ONLY:
1618 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1619 break;
1620 case ResultSetType::SCROLL_INSENSITIVE:
1621 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1622 break;
1623 case ResultSetType::SCROLL_SENSITIVE:
1624 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1625 break;
1628 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1629 return (nValue & SQL_CA2_SENSITIVITY_UPDATES) == SQL_CA2_SENSITIVITY_UPDATES;
1631 // -------------------------------------------------------------------------
1632 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1634 SQLUINTEGER nValue;
1635 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1636 switch(setType)
1638 default:
1639 case ResultSetType::FORWARD_ONLY:
1640 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1641 break;
1642 case ResultSetType::SCROLL_INSENSITIVE:
1643 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1644 break;
1645 case ResultSetType::SCROLL_SENSITIVE:
1646 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1647 break;
1650 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1651 return (nValue & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS;
1653 // -------------------------------------------------------------------------
1654 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1656 SQLUINTEGER nValue;
1657 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1658 switch(setType)
1660 default:
1661 case ResultSetType::FORWARD_ONLY:
1662 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1663 break;
1664 case ResultSetType::SCROLL_INSENSITIVE:
1665 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1666 break;
1667 case ResultSetType::SCROLL_SENSITIVE:
1668 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1669 break;
1672 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1673 return (nValue & SQL_CA2_SENSITIVITY_ADDITIONS) == SQL_CA2_SENSITIVITY_ADDITIONS;
1675 // -------------------------------------------------------------------------
1676 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1678 return ownUpdatesAreVisible(setType);
1680 // -------------------------------------------------------------------------
1681 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1683 return ownDeletesAreVisible(setType);
1685 // -------------------------------------------------------------------------
1686 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1688 return ownInsertsAreVisible(setType);
1690 // -------------------------------------------------------------------------
1691 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1693 return sal_False;
1695 // -------------------------------------------------------------------------
1696 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1698 return sal_False;
1700 // -------------------------------------------------------------------------
1701 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1703 return sal_False;
1705 // -------------------------------------------------------------------------
1706 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
1708 return sal_False;
1710 // -------------------------------------------------------------------------
1711 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getUDTs( const Any& /*catalog*/, const ::rtl::OUString& /*schemaPattern*/, const ::rtl::OUString& /*typeNamePattern*/, const Sequence< sal_Int32 >& /*types*/ ) throw(SQLException, RuntimeException)
1713 return NULL;
1715 // -----------------------------------------------------------------------------
1717 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */