merge the formfield patch from ooo-build
[ooovba.git] / connectivity / source / drivers / odbcbase / ODatabaseMetaData.cxx
blob97edeeffeb6a776d23bcf965e6409d320b0102f1
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: ODatabaseMetaData.cxx,v $
10 * $Revision: 1.35.56.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_connectivity.hxx"
33 #include "odbc/ODatabaseMetaData.hxx"
34 #include "odbc/OTools.hxx"
35 #ifndef _CONNECTIVITY_ODBC_ORESULTSET_HXX_
36 #include "odbc/ODatabaseMetaDataResultSet.hxx"
37 #endif
38 #include "FDatabaseMetaDataResultSet.hxx"
39 #include <com/sun/star/sdbc/DataType.hpp>
40 #include <com/sun/star/sdbc/ResultSetType.hpp>
41 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
42 #include "odbc/OFunctiondefs.hxx"
43 #include "stdio.h"
44 #include "TPrivilegesResultSet.hxx"
45 #include <connectivity/dbexception.hxx>
46 #include <rtl/ustrbuf.hxx>
48 using namespace connectivity::odbc;
49 using namespace com::sun::star::uno;
50 using namespace com::sun::star::lang;
51 using namespace com::sun::star::beans;
52 using namespace com::sun::star::sdbc;
54 ODatabaseMetaData::ODatabaseMetaData(const SQLHANDLE _pHandle,OConnection* _pCon)
55 : ::connectivity::ODatabaseMetaDataBase(_pCon,_pCon->getConnectionInfo())
56 ,m_aConnectionHandle(_pHandle)
57 ,m_pConnection(_pCon)
58 ,m_bUseCatalog(sal_True)
59 ,m_bOdbc3(sal_True)
61 OSL_ENSURE(m_pConnection,"ODatabaseMetaData::ODatabaseMetaData: No connection set!");
62 if(!m_pConnection->isCatalogUsed())
64 osl_incrementInterlockedCount( &m_refCount );
65 try
67 m_bUseCatalog = !(usesLocalFiles() || usesLocalFilePerTable());
68 ::rtl::OUString sVersion = getDriverVersion();
69 m_bOdbc3 = sVersion != ::rtl::OUString::createFromAscii("02.50") && sVersion != ::rtl::OUString::createFromAscii("02.00");
71 catch(SQLException& )
72 { // doesn't matter here
74 osl_decrementInterlockedCount( &m_refCount );
77 // -------------------------------------------------------------------------
78 ODatabaseMetaData::~ODatabaseMetaData()
81 // -------------------------------------------------------------------------
82 Reference< XResultSet > ODatabaseMetaData::impl_getTypeInfo_throw( )
84 Reference< XResultSet > xRef;
85 try
87 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
88 xRef = pResult;
89 pResult->openTypeInfo();
91 catch(SQLException&)
93 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTypeInfo);
96 return xRef;
98 // -------------------------------------------------------------------------
99 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCatalogs( ) throw(SQLException, RuntimeException)
101 Reference< XResultSet > xRef;
102 if(!m_bUseCatalog)
104 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
106 else
110 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
111 xRef = pResult;
112 pResult->openCatalogs();
114 catch(SQLException&)
116 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCatalogs);
120 return xRef;
122 // -------------------------------------------------------------------------
123 ::rtl::OUString ODatabaseMetaData::impl_getCatalogSeparator_throw( )
125 ::rtl::OUString aVal;
126 if ( m_bUseCatalog )
127 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_NAME_SEPARATOR,aVal,*this,m_pConnection->getTextEncoding());
129 return aVal;
131 // -------------------------------------------------------------------------
132 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getSchemas( ) throw(SQLException, RuntimeException)
134 Reference< XResultSet > xRef;
137 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
138 xRef = pResult;
139 pResult->openSchemas();
141 catch(SQLException&)
143 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eSchemas);
145 return xRef;
147 // -------------------------------------------------------------------------
148 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumnPrivileges(
149 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
150 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
152 Reference< XResultSet > xRef;
155 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
156 xRef = pResult;
157 pResult->openColumnPrivileges(m_bUseCatalog ? catalog : Any(),schema,table,columnNamePattern);
159 catch(SQLException&)
161 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumnPrivileges);
163 return xRef;
165 // -------------------------------------------------------------------------
166 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getColumns(
167 const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern,
168 const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
170 Reference< XResultSet > xRef;
173 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
174 xRef = pResult;
175 pResult->openColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,columnNamePattern);
177 catch(SQLException&)
179 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eColumns);
181 return xRef;
183 // -------------------------------------------------------------------------
184 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTables(
185 const Any& catalog, const ::rtl::OUString& schemaPattern,
186 const ::rtl::OUString& tableNamePattern, const Sequence< ::rtl::OUString >& types ) throw(SQLException, RuntimeException)
188 Reference< XResultSet > xRef;
191 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
192 xRef = pResult;
193 pResult->openTables(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern,types);
195 catch(SQLException&)
197 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTables);
199 return xRef;
201 // -------------------------------------------------------------------------
202 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedureColumns(
203 const Any& catalog, const ::rtl::OUString& schemaPattern,
204 const ::rtl::OUString& procedureNamePattern, const ::rtl::OUString& columnNamePattern ) throw(SQLException, RuntimeException)
206 Reference< XResultSet > xRef;
209 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
210 xRef = pResult;
211 pResult->openProcedureColumns(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern,columnNamePattern);
213 catch(SQLException&)
215 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedureColumns);
217 return xRef;
219 // -------------------------------------------------------------------------
220 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getProcedures(
221 const Any& catalog, const ::rtl::OUString& schemaPattern,
222 const ::rtl::OUString& procedureNamePattern ) throw(SQLException, RuntimeException)
224 Reference< XResultSet > xRef;
227 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
228 xRef = pResult;
229 pResult->openProcedures(m_bUseCatalog ? catalog : Any(),schemaPattern,procedureNamePattern);
231 catch(SQLException&)
233 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eProcedures);
235 return xRef;
237 // -------------------------------------------------------------------------
238 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getVersionColumns(
239 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
241 Reference< XResultSet > xRef;
242 bool bSuccess = false;
245 if ( !m_pConnection->preventGetVersionColumns() )
247 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
248 xRef = pResult;
249 pResult->openVersionColumns(m_bUseCatalog ? catalog : Any(),schema,table);
250 bSuccess = true;
253 catch(SQLException&)
257 if ( !bSuccess )
259 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eVersionColumns);
262 return xRef;
264 // -------------------------------------------------------------------------
265 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxBinaryLiteralLength( ) throw(SQLException, RuntimeException)
267 SQLUINTEGER nValue;
268 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_BINARY_LITERAL_LEN,nValue,*this);
269 return nValue;
271 // -------------------------------------------------------------------------
272 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxRowSize( ) throw(SQLException, RuntimeException)
274 SQLUINTEGER nValue;
275 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE,nValue,*this);
276 return nValue;
278 // -------------------------------------------------------------------------
279 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCatalogNameLength( ) throw(SQLException, RuntimeException)
281 SQLUSMALLINT nValue;
282 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CATALOG_NAME_LEN,nValue,*this);
283 return nValue;
285 // -------------------------------------------------------------------------
286 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCharLiteralLength( ) throw(SQLException, RuntimeException)
288 SQLUINTEGER nValue;
289 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CHAR_LITERAL_LEN,nValue,*this);
290 return nValue;
292 // -------------------------------------------------------------------------
293 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnNameLength( ) throw(SQLException, RuntimeException)
295 SQLUSMALLINT nValue;
296 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMN_NAME_LEN,nValue,*this);
297 return nValue;
299 // -------------------------------------------------------------------------
300 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInIndex( ) throw(SQLException, RuntimeException)
302 SQLUSMALLINT nValue;
303 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_INDEX,nValue,*this);
304 return nValue;
306 // -------------------------------------------------------------------------
307 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxCursorNameLength( ) throw(SQLException, RuntimeException)
309 SQLUSMALLINT nValue;
310 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CURSOR_NAME_LEN,nValue,*this);
311 return nValue;
313 // -------------------------------------------------------------------------
314 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxConnections( ) throw(SQLException, RuntimeException)
316 SQLUSMALLINT nValue;
317 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_DRIVER_CONNECTIONS/*SQL_ACTIVE_CONNECTIONS*/,nValue,*this);
318 return nValue;
320 // -------------------------------------------------------------------------
321 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInTable( ) throw(SQLException, RuntimeException)
323 SQLUSMALLINT nValue;
324 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_TABLE,nValue,*this);
325 return nValue;
327 // -------------------------------------------------------------------------
328 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxStatementLength( ) throw(SQLException, RuntimeException)
330 SQLUINTEGER nValue;
331 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_STATEMENT_LEN,nValue,*this);
332 return nValue;
334 // -------------------------------------------------------------------------
335 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxTableNameLength( ) throw(SQLException, RuntimeException)
337 SQLUSMALLINT nValue;
338 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLE_NAME_LEN,nValue,*this);
339 return nValue;
341 // -------------------------------------------------------------------------
342 sal_Int32 ODatabaseMetaData::impl_getMaxTablesInSelect_throw( )
344 SQLUSMALLINT nValue;
345 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_TABLES_IN_SELECT,nValue,*this);
346 return nValue;
348 // -------------------------------------------------------------------------
349 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getExportedKeys(
350 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
352 Reference< XResultSet > xRef;
355 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
356 xRef = pResult;
357 pResult->openExportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
359 catch(SQLException&)
361 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eExportedKeys);
363 return xRef;
365 // -------------------------------------------------------------------------
366 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getImportedKeys(
367 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
369 Reference< XResultSet > xRef;
372 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
373 xRef = pResult;
374 pResult->openImportedKeys(m_bUseCatalog ? catalog : Any(),schema,table);
376 catch(SQLException&)
378 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eImportedKeys);
380 return xRef;
382 // -------------------------------------------------------------------------
383 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getPrimaryKeys(
384 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table ) throw(SQLException, RuntimeException)
386 Reference< XResultSet > xRef;
389 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
390 xRef = pResult;
391 pResult->openPrimaryKeys(m_bUseCatalog ? catalog : Any(),schema,table);
393 catch(SQLException&)
395 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::ePrimaryKeys);
397 return xRef;
399 // -------------------------------------------------------------------------
400 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getIndexInfo(
401 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table,
402 sal_Bool unique, sal_Bool approximate ) throw(SQLException, RuntimeException)
404 Reference< XResultSet > xRef;
407 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
408 xRef = pResult;
409 pResult->openIndexInfo(m_bUseCatalog ? catalog : Any(),schema,table,unique,approximate);
411 catch(SQLException&)
413 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eIndexInfo);
415 return xRef;
417 // -------------------------------------------------------------------------
418 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getBestRowIdentifier(
419 const Any& catalog, const ::rtl::OUString& schema, const ::rtl::OUString& table, sal_Int32 scope,
420 sal_Bool nullable ) throw(SQLException, RuntimeException)
422 Reference< XResultSet > xRef;
425 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
426 xRef = pResult;
427 pResult->openBestRowIdentifier(m_bUseCatalog ? catalog : Any(),schema,table,scope,nullable);
429 catch(SQLException&)
431 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eBestRowIdentifier);
433 return xRef;
435 // -------------------------------------------------------------------------
436 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTablePrivileges(
437 const Any& catalog, const ::rtl::OUString& schemaPattern, const ::rtl::OUString& tableNamePattern ) throw(SQLException, RuntimeException)
439 if ( m_pConnection->isIgnoreDriverPrivilegesEnabled() )
441 return new OResultSetPrivileges(this,catalog,schemaPattern,tableNamePattern);
443 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
444 Reference< XResultSet > xRef = pResult;
445 pResult->openTablePrivileges(m_bUseCatalog ? catalog : Any(),schemaPattern,tableNamePattern);
446 return xRef;
448 // -------------------------------------------------------------------------
449 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getCrossReference(
450 const Any& primaryCatalog, const ::rtl::OUString& primarySchema,
451 const ::rtl::OUString& primaryTable, const Any& foreignCatalog,
452 const ::rtl::OUString& foreignSchema, const ::rtl::OUString& foreignTable ) throw(SQLException, RuntimeException)
454 Reference< XResultSet > xRef;
457 ODatabaseMetaDataResultSet* pResult = new ODatabaseMetaDataResultSet(m_pConnection);
458 xRef = pResult;
459 pResult->openForeignKeys(m_bUseCatalog ? primaryCatalog : Any(),primarySchema.toChar() == '%' ? &primarySchema : NULL,&primaryTable,
460 m_bUseCatalog ? foreignCatalog : Any(), foreignSchema.toChar() == '%' ? &foreignSchema : NULL,&foreignTable);
462 catch(SQLException&)
464 xRef = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eCrossReference);
466 return xRef;
468 // -------------------------------------------------------------------------
469 sal_Bool SAL_CALL ODatabaseMetaData::doesMaxRowSizeIncludeBlobs( ) throw(SQLException, RuntimeException)
471 ::rtl::OUString aVal;
472 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_ROW_SIZE_INCLUDES_LONG,aVal,*this,m_pConnection->getTextEncoding());
473 return aVal.toChar() == 'Y';
475 // -------------------------------------------------------------------------
476 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
478 SQLUSMALLINT nValue;
479 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
480 return nValue == SQL_IC_LOWER;
482 // -------------------------------------------------------------------------
483 sal_Bool SAL_CALL ODatabaseMetaData::storesLowerCaseIdentifiers( ) throw(SQLException, RuntimeException)
485 SQLUSMALLINT nValue;
486 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
487 return nValue == SQL_IC_LOWER;
489 // -------------------------------------------------------------------------
490 sal_Bool ODatabaseMetaData::impl_storesMixedCaseQuotedIdentifiers_throw( )
492 SQLUSMALLINT nValue;
493 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
494 return nValue == SQL_IC_MIXED;
496 // -------------------------------------------------------------------------
497 sal_Bool SAL_CALL ODatabaseMetaData::storesMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
499 SQLUSMALLINT nValue;
500 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
501 return nValue == SQL_IC_MIXED;
503 // -------------------------------------------------------------------------
504 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseQuotedIdentifiers( ) throw(SQLException, RuntimeException)
506 SQLUSMALLINT nValue;
507 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
508 return nValue == SQL_IC_UPPER;
510 // -------------------------------------------------------------------------
511 sal_Bool SAL_CALL ODatabaseMetaData::storesUpperCaseIdentifiers( ) throw(SQLException, RuntimeException)
513 SQLUSMALLINT nValue;
514 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
515 return nValue == SQL_IC_UPPER;
517 // -------------------------------------------------------------------------
518 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithAddColumn_throw( )
520 SQLUINTEGER nValue;
521 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
522 return (nValue & SQL_AT_ADD_COLUMN) == SQL_AT_ADD_COLUMN;
524 // -------------------------------------------------------------------------
525 sal_Bool ODatabaseMetaData::impl_supportsAlterTableWithDropColumn_throw( )
527 SQLUINTEGER nValue;
528 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ALTER_TABLE,nValue,*this);
529 return ((nValue & SQL_AT_DROP_COLUMN) == SQL_AT_DROP_COLUMN) ||
530 ((nValue & SQL_AT_DROP_COLUMN_CASCADE) == SQL_AT_DROP_COLUMN_CASCADE) ||
531 ((nValue & SQL_AT_DROP_COLUMN_RESTRICT) == SQL_AT_DROP_COLUMN_RESTRICT);
533 // -------------------------------------------------------------------------
534 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxIndexLength( ) throw(SQLException, RuntimeException)
536 SQLUINTEGER nValue;
537 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_INDEX_SIZE,nValue,*this);
538 return nValue;
540 // -------------------------------------------------------------------------
541 sal_Bool SAL_CALL ODatabaseMetaData::supportsNonNullableColumns( ) throw(SQLException, RuntimeException)
543 SQLUSMALLINT nValue;
544 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NON_NULLABLE_COLUMNS,nValue,*this);
545 return nValue == SQL_NNC_NON_NULL;
547 // -------------------------------------------------------------------------
548 ::rtl::OUString SAL_CALL ODatabaseMetaData::getCatalogTerm( ) throw(SQLException, RuntimeException)
550 ::rtl::OUString aVal;
551 if(m_bUseCatalog)
552 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_TERM,aVal,*this,m_pConnection->getTextEncoding());
553 return aVal;
555 // -------------------------------------------------------------------------
556 ::rtl::OUString ODatabaseMetaData::impl_getIdentifierQuoteString_throw( )
558 ::rtl::OUString aVal;
559 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_QUOTE_CHAR,aVal,*this,m_pConnection->getTextEncoding());
560 return aVal;
562 // -------------------------------------------------------------------------
563 ::rtl::OUString SAL_CALL ODatabaseMetaData::getExtraNameCharacters( ) throw(SQLException, RuntimeException)
565 ::rtl::OUString aVal;
566 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SPECIAL_CHARACTERS,aVal,*this,m_pConnection->getTextEncoding());
567 return aVal;
569 // -------------------------------------------------------------------------
570 sal_Bool SAL_CALL ODatabaseMetaData::supportsDifferentTableCorrelationNames( ) throw(SQLException, RuntimeException)
572 SQLUSMALLINT nValue;
573 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
574 return nValue != SQL_CN_NONE;
576 // -------------------------------------------------------------------------
577 sal_Bool ODatabaseMetaData::impl_isCatalogAtStart_throw( )
579 SQLUSMALLINT nValue=0;
580 if ( m_bUseCatalog )
581 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_LOCATION,nValue,*this);
582 return nValue == SQL_CL_START;
584 // -------------------------------------------------------------------------
585 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions( ) throw(SQLException, RuntimeException)
587 SQLUSMALLINT nValue;
588 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
589 return nValue == SQL_TC_DDL_IGNORE;
591 // -------------------------------------------------------------------------
592 sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit( ) throw(SQLException, RuntimeException)
594 SQLUSMALLINT nValue;
595 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
596 return nValue == SQL_TC_DDL_COMMIT;
598 // -------------------------------------------------------------------------
599 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly( ) throw(SQLException, RuntimeException)
601 SQLUSMALLINT nValue;
602 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
603 return nValue == SQL_TC_DML;
605 // -------------------------------------------------------------------------
606 sal_Bool SAL_CALL ODatabaseMetaData::supportsDataDefinitionAndDataManipulationTransactions( ) throw(SQLException, RuntimeException)
608 SQLUSMALLINT nValue;
609 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
610 return nValue == SQL_TC_ALL;
612 // -------------------------------------------------------------------------
613 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedDelete( ) throw(SQLException, RuntimeException)
615 SQLUINTEGER nValue;
616 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
617 return (nValue & SQL_CA1_POS_DELETE) == SQL_CA1_POS_DELETE;
619 // -------------------------------------------------------------------------
620 sal_Bool SAL_CALL ODatabaseMetaData::supportsPositionedUpdate( ) throw(SQLException, RuntimeException)
622 SQLUINTEGER nValue;
623 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
624 return (nValue & SQL_CA1_POS_UPDATE) == SQL_CA1_POS_UPDATE;
626 // -------------------------------------------------------------------------
627 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossRollback( ) throw(SQLException, RuntimeException)
629 SQLUSMALLINT nValue;
630 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
631 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
633 // -------------------------------------------------------------------------
634 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenStatementsAcrossCommit( ) throw(SQLException, RuntimeException)
636 SQLUSMALLINT nValue;
637 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
638 return nValue == SQL_CB_PRESERVE || nValue == SQL_CB_CLOSE;
640 // -------------------------------------------------------------------------
641 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossCommit( ) throw(SQLException, RuntimeException)
643 SQLUSMALLINT nValue;
644 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_COMMIT_BEHAVIOR,nValue,*this);
645 return nValue == SQL_CB_PRESERVE;
647 // -------------------------------------------------------------------------
648 sal_Bool SAL_CALL ODatabaseMetaData::supportsOpenCursorsAcrossRollback( ) throw(SQLException, RuntimeException)
650 SQLUSMALLINT nValue;
651 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_ROLLBACK_BEHAVIOR,nValue,*this);
652 return nValue == SQL_CB_PRESERVE;
654 // -------------------------------------------------------------------------
655 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactionIsolationLevel( sal_Int32 level ) throw(SQLException, RuntimeException)
657 SQLUINTEGER nValue;
658 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_ISOLATION_OPTION,nValue,*this);
659 return (nValue & static_cast<SQLUINTEGER>(level)) == static_cast<SQLUINTEGER>(level);
661 // -------------------------------------------------------------------------
662 sal_Bool ODatabaseMetaData::impl_supportsSchemasInDataManipulation_throw( )
664 SQLUINTEGER nValue;
665 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
666 return (nValue & SQL_SU_DML_STATEMENTS) == SQL_SU_DML_STATEMENTS;
668 // -------------------------------------------------------------------------
669 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92FullSQL( ) throw(SQLException, RuntimeException)
671 SQLUINTEGER nValue;
672 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
673 return nValue == SQL_SC_SQL92_FULL;
675 // -------------------------------------------------------------------------
676 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92EntryLevelSQL( ) throw(SQLException, RuntimeException)
678 SQLUINTEGER nValue;
679 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
680 return nValue == SQL_SC_SQL92_ENTRY;
682 // -------------------------------------------------------------------------
683 sal_Bool SAL_CALL ODatabaseMetaData::supportsIntegrityEnhancementFacility( ) throw(SQLException, RuntimeException)
685 ::rtl::OUString aStr;
686 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_INTEGRITY,aStr,*this,m_pConnection->getTextEncoding());
687 return aStr.toChar() == 'Y';
689 // -------------------------------------------------------------------------
690 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInIndexDefinitions( ) throw(SQLException, RuntimeException)
692 SQLUINTEGER nValue;
693 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
694 return (nValue & SQL_SU_INDEX_DEFINITION) == SQL_SU_INDEX_DEFINITION;
696 // -------------------------------------------------------------------------
697 sal_Bool ODatabaseMetaData::impl_supportsSchemasInTableDefinitions_throw( )
699 SQLUINTEGER nValue;
700 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
701 return (nValue & SQL_SU_TABLE_DEFINITION) == SQL_SU_TABLE_DEFINITION;
703 // -------------------------------------------------------------------------
704 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInTableDefinitions_throw( )
706 SQLUINTEGER nValue=0;
707 if(m_bUseCatalog)
708 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
709 return (nValue & SQL_CU_TABLE_DEFINITION) == SQL_CU_TABLE_DEFINITION;
711 // -------------------------------------------------------------------------
712 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInIndexDefinitions( ) throw(SQLException, RuntimeException)
714 SQLUINTEGER nValue=0;
715 if(m_bUseCatalog)
716 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
717 return (nValue & SQL_CU_INDEX_DEFINITION) == SQL_CU_INDEX_DEFINITION;
719 // -------------------------------------------------------------------------
720 sal_Bool ODatabaseMetaData::impl_supportsCatalogsInDataManipulation_throw( )
722 SQLUINTEGER nValue=0;
723 if(m_bUseCatalog)
724 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
725 return (nValue & SQL_CU_DML_STATEMENTS) == SQL_CU_DML_STATEMENTS;
727 // -------------------------------------------------------------------------
728 sal_Bool SAL_CALL ODatabaseMetaData::supportsOuterJoins( ) throw(SQLException, RuntimeException)
730 SQLUINTEGER nValue;
731 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
732 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);
734 // -------------------------------------------------------------------------
735 Reference< XResultSet > SAL_CALL ODatabaseMetaData::getTableTypes( ) throw(SQLException, RuntimeException)
738 // there exists no possibility to get table types so we have to check
739 static ::rtl::OUString sTableTypes[] =
741 ::rtl::OUString::createFromAscii("TABLE"),
742 ::rtl::OUString::createFromAscii("VIEW"),
743 ::rtl::OUString::createFromAscii("SYSTEM TABLE"),
744 ::rtl::OUString::createFromAscii("GLOBAL TEMPORARY"),
745 ::rtl::OUString::createFromAscii("LOCAL TEMPORARY"),
746 ::rtl::OUString::createFromAscii("ALIAS"),
747 ::rtl::OUString::createFromAscii("SYNONYM")
749 sal_Int32 nSize = sizeof(sTableTypes) / sizeof(::rtl::OUString);
750 ::connectivity::ODatabaseMetaDataResultSet* pResult = new ::connectivity::ODatabaseMetaDataResultSet(::connectivity::ODatabaseMetaDataResultSet::eTableTypes);
751 Reference< XResultSet > xRef = pResult;
752 SQLUINTEGER nValue = 0;
755 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CREATE_VIEW,nValue,*this);
757 catch(const Exception&)
760 sal_Bool bViewsSupported = (nValue & SQL_CV_CREATE_VIEW) == SQL_CV_CREATE_VIEW;
762 ::connectivity::ODatabaseMetaDataResultSet::ORows aRows;
763 for(sal_Int32 i=0;i < nSize;++i)
765 if( !bViewsSupported && i == 1)
766 continue; // no views supported
767 ::connectivity::ODatabaseMetaDataResultSet::ORow aRow;
768 aRow.push_back(::connectivity::ODatabaseMetaDataResultSet::getEmptyValue());
769 aRow.push_back(new ::connectivity::ORowSetValueDecorator(sTableTypes[i]));
770 aRows.push_back(aRow);
772 pResult->setRows(aRows);
773 return xRef;
775 // -------------------------------------------------------------------------
776 sal_Int32 ODatabaseMetaData::impl_getMaxStatements_throw( )
778 SQLUSMALLINT nValue;
779 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_CONCURRENT_ACTIVITIES,nValue,*this);
780 return nValue;
782 // -------------------------------------------------------------------------
783 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxProcedureNameLength( ) throw(SQLException, RuntimeException)
785 SQLUSMALLINT nValue;
786 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_PROCEDURE_NAME_LEN,nValue,*this);
787 return nValue;
789 // -------------------------------------------------------------------------
790 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxSchemaNameLength( ) throw(SQLException, RuntimeException)
792 SQLUSMALLINT nValue;
793 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_SCHEMA_NAME_LEN,nValue,*this);
794 return nValue;
796 // -------------------------------------------------------------------------
797 sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions( ) throw(SQLException, RuntimeException)
799 SQLUSMALLINT nValue;
800 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TXN_CAPABLE,nValue,*this);
801 return nValue != SQL_TC_NONE;
803 // -------------------------------------------------------------------------
804 sal_Bool SAL_CALL ODatabaseMetaData::allProceduresAreCallable( ) throw(SQLException, RuntimeException)
806 ::rtl::OUString aValue;
807 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
808 return aValue.toChar() == 'Y';
810 // -------------------------------------------------------------------------
811 sal_Bool SAL_CALL ODatabaseMetaData::supportsStoredProcedures( ) throw(SQLException, RuntimeException)
813 ::rtl::OUString aValue;
814 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURES,aValue,*this,m_pConnection->getTextEncoding());
815 return aValue.toChar() == 'Y';
817 // -------------------------------------------------------------------------
818 sal_Bool SAL_CALL ODatabaseMetaData::supportsSelectForUpdate( ) throw(SQLException, RuntimeException)
820 SQLUINTEGER nValue;
821 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DYNAMIC_CURSOR_ATTRIBUTES1,nValue,*this);
822 return (nValue & SQL_CA1_POSITIONED_UPDATE) == SQL_CA1_POSITIONED_UPDATE;
824 // -------------------------------------------------------------------------
825 sal_Bool SAL_CALL ODatabaseMetaData::allTablesAreSelectable( ) throw(SQLException, RuntimeException)
827 ::rtl::OUString aValue;
828 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ACCESSIBLE_TABLES,aValue,*this,m_pConnection->getTextEncoding());
829 return aValue.toChar() == 'Y';
831 // -------------------------------------------------------------------------
832 sal_Bool SAL_CALL ODatabaseMetaData::isReadOnly( ) throw(SQLException, RuntimeException)
834 return m_pConnection->isReadOnly();
836 // -------------------------------------------------------------------------
837 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFiles( ) throw(SQLException, RuntimeException)
839 SQLUSMALLINT nValue;
840 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
841 return nValue == SQL_FILE_CATALOG;
843 // -------------------------------------------------------------------------
844 sal_Bool SAL_CALL ODatabaseMetaData::usesLocalFilePerTable( ) throw(SQLException, RuntimeException)
846 SQLUSMALLINT nValue;
847 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_FILE_USAGE,nValue,*this);
848 return nValue == SQL_FILE_TABLE;
850 // -------------------------------------------------------------------------
851 sal_Bool SAL_CALL ODatabaseMetaData::supportsTypeConversion( ) throw(SQLException, RuntimeException)
853 SQLUINTEGER nValue;
854 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FUNCTIONS,nValue,*this);
855 return (nValue & SQL_FN_CVT_CONVERT) == SQL_FN_CVT_CONVERT;
857 // -------------------------------------------------------------------------
858 sal_Bool SAL_CALL ODatabaseMetaData::nullPlusNonNullIsNull( ) throw(SQLException, RuntimeException)
860 SQLUSMALLINT nValue;
861 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONCAT_NULL_BEHAVIOR,nValue,*this);
862 return nValue == SQL_CB_NULL;
864 // -------------------------------------------------------------------------
865 sal_Bool SAL_CALL ODatabaseMetaData::supportsColumnAliasing( ) throw(SQLException, RuntimeException)
867 ::rtl::OUString aValue;
868 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_COLUMN_ALIAS,aValue,*this,m_pConnection->getTextEncoding());
869 return aValue.toChar() == 'Y';
871 // -------------------------------------------------------------------------
872 sal_Bool SAL_CALL ODatabaseMetaData::supportsTableCorrelationNames( ) throw(SQLException, RuntimeException)
874 SQLUSMALLINT nValue;
875 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
876 return nValue != SQL_CN_NONE;
878 // -------------------------------------------------------------------------
879 sal_Bool SAL_CALL ODatabaseMetaData::supportsConvert( sal_Int32 fromType, sal_Int32 toType ) throw(SQLException, RuntimeException)
881 if(fromType == toType)
882 return sal_True;
884 SQLUINTEGER nValue=0;
885 switch(fromType)
887 case DataType::BIT:
888 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIT,nValue,*this);
889 break;
890 case DataType::TINYINT:
891 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TINYINT,nValue,*this);
892 break;
893 case DataType::SMALLINT:
894 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_SMALLINT,nValue,*this);
895 break;
896 case DataType::INTEGER:
897 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_INTEGER,nValue,*this);
898 break;
899 case DataType::BIGINT:
900 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BIGINT,nValue,*this);
901 break;
902 case DataType::FLOAT:
903 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_FLOAT,nValue,*this);
904 break;
905 case DataType::REAL:
906 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_REAL,nValue,*this);
907 break;
908 case DataType::DOUBLE:
909 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DOUBLE,nValue,*this);
910 break;
911 case DataType::NUMERIC:
912 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_NUMERIC,nValue,*this);
913 break;
914 case DataType::DECIMAL:
915 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DECIMAL,nValue,*this);
916 break;
917 case DataType::CHAR:
918 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_CHAR,nValue,*this);
919 break;
920 case DataType::VARCHAR:
921 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARCHAR,nValue,*this);
922 break;
923 case DataType::LONGVARCHAR:
924 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARCHAR,nValue,*this);
925 break;
926 case DataType::DATE:
927 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_DATE,nValue,*this);
928 break;
929 case DataType::TIME:
930 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIME,nValue,*this);
931 break;
932 case DataType::TIMESTAMP:
933 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_TIMESTAMP,nValue,*this);
934 break;
935 case DataType::BINARY:
936 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_BINARY,nValue,*this);
937 break;
938 case DataType::VARBINARY:
939 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_VARBINARY,nValue,*this);
940 break;
941 case DataType::LONGVARBINARY:
942 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CONVERT_LONGVARBINARY,nValue,*this);
943 break;
944 case DataType::SQLNULL:
945 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
946 break;
947 case DataType::OTHER:
948 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
949 break;
950 case DataType::OBJECT:
951 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
952 break;
953 case DataType::DISTINCT:
954 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
955 break;
956 case DataType::STRUCT:
957 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
958 break;
959 case DataType::ARRAY:
960 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
961 break;
962 case DataType::BLOB:
963 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
964 break;
965 case DataType::CLOB:
966 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
967 break;
968 case DataType::REF:
969 // OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CORRELATION_NAME,nValue,*this);
970 break;
972 sal_Bool bConvert = sal_False;
973 switch(toType)
975 case DataType::BIT:
976 bConvert = (nValue & SQL_CVT_BIT) == SQL_CVT_BIT;
977 break;
978 case DataType::TINYINT:
979 bConvert = (nValue & SQL_CVT_TINYINT) == SQL_CVT_TINYINT;
980 break;
981 case DataType::SMALLINT:
982 bConvert = (nValue & SQL_CVT_SMALLINT) == SQL_CVT_SMALLINT;
983 break;
984 case DataType::INTEGER:
985 bConvert = (nValue & SQL_CVT_INTEGER) == SQL_CVT_INTEGER;
986 break;
987 case DataType::BIGINT:
988 bConvert = (nValue & SQL_CVT_BIGINT) == SQL_CVT_BIGINT;
989 break;
990 case DataType::FLOAT:
991 bConvert = (nValue & SQL_CVT_FLOAT) == SQL_CVT_FLOAT;
992 break;
993 case DataType::REAL:
994 bConvert = (nValue & SQL_CVT_REAL) == SQL_CVT_REAL;
995 break;
996 case DataType::DOUBLE:
997 bConvert = (nValue & SQL_CVT_DOUBLE) == SQL_CVT_DOUBLE;
998 break;
999 case DataType::NUMERIC:
1000 bConvert = (nValue & SQL_CVT_NUMERIC) == SQL_CVT_NUMERIC;
1001 break;
1002 case DataType::DECIMAL:
1003 bConvert = (nValue & SQL_CVT_DECIMAL) == SQL_CVT_DECIMAL;
1004 break;
1005 case DataType::CHAR:
1006 bConvert = (nValue & SQL_CVT_CHAR) == SQL_CVT_CHAR;
1007 break;
1008 case DataType::VARCHAR:
1009 bConvert = (nValue & SQL_CVT_VARCHAR) == SQL_CVT_VARCHAR;
1010 break;
1011 case DataType::LONGVARCHAR:
1012 bConvert = (nValue & SQL_CVT_LONGVARCHAR) == SQL_CVT_LONGVARCHAR;
1013 break;
1014 case DataType::DATE:
1015 bConvert = (nValue & SQL_CVT_DATE) == SQL_CVT_DATE;
1016 break;
1017 case DataType::TIME:
1018 bConvert = (nValue & SQL_CVT_TIME) == SQL_CVT_TIME;
1019 break;
1020 case DataType::TIMESTAMP:
1021 bConvert = (nValue & SQL_CVT_TIMESTAMP) == SQL_CVT_TIMESTAMP;
1022 break;
1023 case DataType::BINARY:
1024 bConvert = (nValue & SQL_CVT_BINARY) == SQL_CVT_BINARY;
1025 break;
1026 case DataType::VARBINARY:
1027 bConvert = (nValue & SQL_CVT_VARBINARY) == SQL_CVT_VARBINARY;
1028 break;
1029 case DataType::LONGVARBINARY:
1030 bConvert = (nValue & SQL_CVT_LONGVARBINARY) == SQL_CVT_LONGVARBINARY;
1031 break;
1034 return bConvert;
1036 // -------------------------------------------------------------------------
1037 sal_Bool SAL_CALL ODatabaseMetaData::supportsExpressionsInOrderBy( ) throw(SQLException, RuntimeException)
1039 ::rtl::OUString aValue;
1040 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_EXPRESSIONS_IN_ORDERBY,aValue,*this,m_pConnection->getTextEncoding());
1041 return aValue.toChar() == 'Y';
1043 // -------------------------------------------------------------------------
1044 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupBy( ) throw(SQLException, RuntimeException)
1046 SQLUSMALLINT nValue;
1047 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1048 return nValue != SQL_GB_NOT_SUPPORTED;
1050 // -------------------------------------------------------------------------
1051 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByBeyondSelect( ) throw(SQLException, RuntimeException)
1053 SQLUSMALLINT nValue;
1054 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1055 return nValue != SQL_GB_GROUP_BY_CONTAINS_SELECT;
1057 // -------------------------------------------------------------------------
1058 sal_Bool SAL_CALL ODatabaseMetaData::supportsGroupByUnrelated( ) throw(SQLException, RuntimeException)
1060 SQLUSMALLINT nValue;
1061 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_GROUP_BY,nValue,*this);
1062 return nValue == SQL_GB_NO_RELATION;
1064 // -------------------------------------------------------------------------
1065 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleTransactions( ) throw(SQLException, RuntimeException)
1067 ::rtl::OUString aValue;
1068 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULTIPLE_ACTIVE_TXN,aValue,*this,m_pConnection->getTextEncoding());
1069 return aValue.toChar() == 'Y';
1071 // -------------------------------------------------------------------------
1072 sal_Bool SAL_CALL ODatabaseMetaData::supportsMultipleResultSets( ) throw(SQLException, RuntimeException)
1074 ::rtl::OUString aValue;
1075 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MULT_RESULT_SETS,aValue,*this,m_pConnection->getTextEncoding());
1076 return aValue.toChar() == 'Y';
1078 // -------------------------------------------------------------------------
1079 sal_Bool SAL_CALL ODatabaseMetaData::supportsLikeEscapeClause( ) throw(SQLException, RuntimeException)
1081 ::rtl::OUString aValue;
1082 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_LIKE_ESCAPE_CLAUSE,aValue,*this,m_pConnection->getTextEncoding());
1083 return aValue.toChar() == 'Y';
1085 // -------------------------------------------------------------------------
1086 sal_Bool SAL_CALL ODatabaseMetaData::supportsOrderByUnrelated( ) throw(SQLException, RuntimeException)
1088 ::rtl::OUString aValue;
1089 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ORDER_BY_COLUMNS_IN_SELECT,aValue,*this,m_pConnection->getTextEncoding());
1090 return aValue.toChar() == 'N';
1092 // -------------------------------------------------------------------------
1093 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnion( ) throw(SQLException, RuntimeException)
1095 SQLUINTEGER nValue;
1096 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1097 return (nValue & SQL_U_UNION) == SQL_U_UNION;
1099 // -------------------------------------------------------------------------
1100 sal_Bool SAL_CALL ODatabaseMetaData::supportsUnionAll( ) throw(SQLException, RuntimeException)
1102 SQLUINTEGER nValue;
1103 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_UNION,nValue,*this);
1104 return (nValue & SQL_U_UNION_ALL) == SQL_U_UNION_ALL;
1106 // -------------------------------------------------------------------------
1107 sal_Bool SAL_CALL ODatabaseMetaData::supportsMixedCaseIdentifiers( ) throw(SQLException, RuntimeException)
1109 SQLUSMALLINT nValue;
1110 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_IDENTIFIER_CASE,nValue,*this);
1111 return nValue == SQL_IC_MIXED;
1113 // -------------------------------------------------------------------------
1114 sal_Bool ODatabaseMetaData::impl_supportsMixedCaseQuotedIdentifiers_throw( )
1116 SQLUSMALLINT nValue;
1117 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_QUOTED_IDENTIFIER_CASE,nValue,*this);
1118 return nValue == SQL_IC_MIXED;
1120 // -------------------------------------------------------------------------
1121 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtEnd( ) throw(SQLException, RuntimeException)
1123 SQLUSMALLINT nValue;
1124 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1125 return nValue == SQL_NC_END;
1127 // -------------------------------------------------------------------------
1128 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedAtStart( ) throw(SQLException, RuntimeException)
1130 SQLUSMALLINT nValue;
1131 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1132 return nValue == SQL_NC_START;
1134 // -------------------------------------------------------------------------
1135 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedHigh( ) throw(SQLException, RuntimeException)
1137 SQLUSMALLINT nValue;
1138 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1139 return nValue == SQL_NC_HIGH;
1141 // -------------------------------------------------------------------------
1142 sal_Bool SAL_CALL ODatabaseMetaData::nullsAreSortedLow( ) throw(SQLException, RuntimeException)
1144 SQLUSMALLINT nValue;
1145 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NULL_COLLATION,nValue,*this);
1146 return nValue == SQL_NC_LOW;
1148 // -------------------------------------------------------------------------
1149 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInProcedureCalls( ) throw(SQLException, RuntimeException)
1151 SQLUINTEGER nValue;
1152 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1153 return (nValue & SQL_SU_PROCEDURE_INVOCATION) == SQL_SU_PROCEDURE_INVOCATION;
1155 // -------------------------------------------------------------------------
1156 sal_Bool SAL_CALL ODatabaseMetaData::supportsSchemasInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
1158 SQLUINTEGER nValue;
1159 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_USAGE,nValue,*this);
1160 return (nValue & SQL_SU_PRIVILEGE_DEFINITION) == SQL_SU_PRIVILEGE_DEFINITION;
1162 // -------------------------------------------------------------------------
1163 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInProcedureCalls( ) throw(SQLException, RuntimeException)
1165 SQLUINTEGER nValue=0;
1166 if(m_bUseCatalog)
1167 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1168 return (nValue & SQL_CU_PROCEDURE_INVOCATION) == SQL_CU_PROCEDURE_INVOCATION;
1170 // -------------------------------------------------------------------------
1171 sal_Bool SAL_CALL ODatabaseMetaData::supportsCatalogsInPrivilegeDefinitions( ) throw(SQLException, RuntimeException)
1173 SQLUINTEGER nValue=0;
1174 if(m_bUseCatalog)
1175 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CATALOG_USAGE,nValue,*this);
1176 return (nValue & SQL_CU_PRIVILEGE_DEFINITION) == SQL_CU_PRIVILEGE_DEFINITION;
1178 // -------------------------------------------------------------------------
1179 sal_Bool SAL_CALL ODatabaseMetaData::supportsCorrelatedSubqueries( ) throw(SQLException, RuntimeException)
1181 SQLUINTEGER nValue;
1182 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1183 return (nValue & SQL_SQ_CORRELATED_SUBQUERIES) == SQL_SQ_CORRELATED_SUBQUERIES;
1185 // -------------------------------------------------------------------------
1186 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInComparisons( ) throw(SQLException, RuntimeException)
1188 SQLUINTEGER nValue;
1189 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1190 return (nValue & SQL_SQ_COMPARISON) == SQL_SQ_COMPARISON;
1192 // -------------------------------------------------------------------------
1193 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInExists( ) throw(SQLException, RuntimeException)
1195 SQLUINTEGER nValue;
1196 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1197 return (nValue & SQL_SQ_EXISTS) == SQL_SQ_EXISTS;
1199 // -------------------------------------------------------------------------
1200 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInIns( ) throw(SQLException, RuntimeException)
1202 SQLUINTEGER nValue;
1203 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1204 return (nValue & SQL_SQ_IN) == SQL_SQ_IN;
1206 // -------------------------------------------------------------------------
1207 sal_Bool SAL_CALL ODatabaseMetaData::supportsSubqueriesInQuantifieds( ) throw(SQLException, RuntimeException)
1209 SQLUINTEGER nValue;
1210 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1211 return (nValue & SQL_SQ_QUANTIFIED) == SQL_SQ_QUANTIFIED;
1213 // -------------------------------------------------------------------------
1214 sal_Bool SAL_CALL ODatabaseMetaData::supportsANSI92IntermediateSQL( ) throw(SQLException, RuntimeException)
1216 SQLUINTEGER nValue;
1217 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SQL_CONFORMANCE,nValue,*this);
1218 return nValue == SQL_SC_SQL92_INTERMEDIATE;
1220 // -----------------------------------------------------------------------------
1221 ::rtl::OUString ODatabaseMetaData::getURLImpl()
1223 ::rtl::OUString aValue;
1224 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DATA_SOURCE_NAME,aValue,*this,m_pConnection->getTextEncoding());
1225 return aValue;
1227 // -------------------------------------------------------------------------
1228 ::rtl::OUString SAL_CALL ODatabaseMetaData::getURL( ) throw(SQLException, RuntimeException)
1230 ::rtl::OUString aValue = m_pConnection->getURL();
1231 if ( !aValue.getLength() )
1233 aValue = ::rtl::OUString::createFromAscii("sdbc:odbc:");
1234 aValue += getURLImpl();
1236 return aValue;
1238 // -------------------------------------------------------------------------
1239 ::rtl::OUString SAL_CALL ODatabaseMetaData::getUserName( ) throw(SQLException, RuntimeException)
1241 ::rtl::OUString aValue;
1242 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_USER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1243 return aValue;
1245 // -------------------------------------------------------------------------
1246 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverName( ) throw(SQLException, RuntimeException)
1248 ::rtl::OUString aValue;
1249 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_NAME,aValue,*this,m_pConnection->getTextEncoding());
1250 return aValue;
1252 // -------------------------------------------------------------------------
1253 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDriverVersion() throw(SQLException, RuntimeException)
1255 ::rtl::OUString aValue;
1256 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_ODBC_VER,aValue,*this,m_pConnection->getTextEncoding());
1257 return aValue;
1259 // -------------------------------------------------------------------------
1260 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductVersion( ) throw(SQLException, RuntimeException)
1262 ::rtl::OUString aValue;
1263 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1264 return aValue;
1266 // -------------------------------------------------------------------------
1267 ::rtl::OUString SAL_CALL ODatabaseMetaData::getDatabaseProductName( ) throw(SQLException, RuntimeException)
1269 ::rtl::OUString aValue;
1270 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DBMS_NAME,aValue,*this,m_pConnection->getTextEncoding());
1271 return aValue;
1273 // -------------------------------------------------------------------------
1274 ::rtl::OUString SAL_CALL ODatabaseMetaData::getProcedureTerm( ) throw(SQLException, RuntimeException)
1276 ::rtl::OUString aValue;
1277 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_PROCEDURE_TERM,aValue,*this,m_pConnection->getTextEncoding());
1278 return aValue;
1280 // -------------------------------------------------------------------------
1281 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSchemaTerm( ) throw(SQLException, RuntimeException)
1283 ::rtl::OUString aValue;
1284 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SCHEMA_TERM,aValue,*this,m_pConnection->getTextEncoding());
1285 return aValue;
1287 // -------------------------------------------------------------------------
1288 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMajorVersion( ) throw(RuntimeException)
1290 ::rtl::OUString aValue;
1291 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1292 return aValue.copy(0,aValue.indexOf('.')).toInt32();
1294 // -------------------------------------------------------------------------
1295 sal_Int32 SAL_CALL ODatabaseMetaData::getDefaultTransactionIsolation( ) throw(SQLException, RuntimeException)
1297 SQLUINTEGER nValue;
1298 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SUBQUERIES,nValue,*this);
1299 return nValue;
1301 // -------------------------------------------------------------------------
1302 sal_Int32 SAL_CALL ODatabaseMetaData::getDriverMinorVersion( ) throw(RuntimeException)
1304 ::rtl::OUString aValue;
1305 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_DRIVER_VER,aValue,*this,m_pConnection->getTextEncoding());
1306 return aValue.copy(0,aValue.lastIndexOf('.')).toInt32();
1308 // -------------------------------------------------------------------------
1309 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSQLKeywords( ) throw(SQLException, RuntimeException)
1311 ::rtl::OUString aValue;
1312 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_KEYWORDS,aValue,*this,m_pConnection->getTextEncoding());
1313 return aValue;
1315 // -------------------------------------------------------------------------
1316 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSearchStringEscape( ) throw(SQLException, RuntimeException)
1318 ::rtl::OUString aValue;
1319 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SEARCH_PATTERN_ESCAPE,aValue,*this,m_pConnection->getTextEncoding());
1320 return aValue;
1322 // -------------------------------------------------------------------------
1323 ::rtl::OUString SAL_CALL ODatabaseMetaData::getStringFunctions( ) throw(SQLException, RuntimeException)
1325 SQLUINTEGER nValue;
1326 ::rtl::OUStringBuffer aValue;
1327 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_STRING_FUNCTIONS,nValue,*this);
1328 if(nValue & SQL_FN_STR_ASCII)
1329 aValue.appendAscii("ASCII,");
1330 if(nValue & SQL_FN_STR_BIT_LENGTH)
1331 aValue.appendAscii("BIT_LENGTH,");
1332 if(nValue & SQL_FN_STR_CHAR)
1333 aValue.appendAscii("CHAR,");
1334 if(nValue & SQL_FN_STR_CHAR_LENGTH)
1335 aValue.appendAscii("CHAR_LENGTH,");
1336 if(nValue & SQL_FN_STR_CHARACTER_LENGTH)
1337 aValue.appendAscii("CHARACTER_LENGTH,");
1338 if(nValue & SQL_FN_STR_CONCAT)
1339 aValue.appendAscii("CONCAT,");
1340 if(nValue & SQL_FN_STR_DIFFERENCE)
1341 aValue.appendAscii("DIFFERENCE,");
1342 if(nValue & SQL_FN_STR_INSERT)
1343 aValue.appendAscii("INSERT,");
1344 if(nValue & SQL_FN_STR_LCASE)
1345 aValue.appendAscii("LCASE,");
1346 if(nValue & SQL_FN_STR_LEFT)
1347 aValue.appendAscii("LEFT,");
1348 if(nValue & SQL_FN_STR_LENGTH)
1349 aValue.appendAscii("LENGTH,");
1350 if(nValue & SQL_FN_STR_LOCATE)
1351 aValue.appendAscii("LOCATE,");
1352 if(nValue & SQL_FN_STR_LOCATE_2)
1353 aValue.appendAscii("LOCATE_2,");
1354 if(nValue & SQL_FN_STR_LTRIM)
1355 aValue.appendAscii("LTRIM,");
1356 if(nValue & SQL_FN_STR_OCTET_LENGTH)
1357 aValue.appendAscii("OCTET_LENGTH,");
1358 if(nValue & SQL_FN_STR_POSITION)
1359 aValue.appendAscii("POSITION,");
1360 if(nValue & SQL_FN_STR_REPEAT)
1361 aValue.appendAscii("REPEAT,");
1362 if(nValue & SQL_FN_STR_REPLACE)
1363 aValue.appendAscii("REPLACE,");
1364 if(nValue & SQL_FN_STR_RIGHT)
1365 aValue.appendAscii("RIGHT,");
1366 if(nValue & SQL_FN_STR_RTRIM)
1367 aValue.appendAscii("RTRIM,");
1368 if(nValue & SQL_FN_STR_SOUNDEX)
1369 aValue.appendAscii("SOUNDEX,");
1370 if(nValue & SQL_FN_STR_SPACE)
1371 aValue.appendAscii("SPACE,");
1372 if(nValue & SQL_FN_STR_SUBSTRING)
1373 aValue.appendAscii("SUBSTRING,");
1374 if(nValue & SQL_FN_STR_UCASE)
1375 aValue.appendAscii("UCASE,");
1378 if ( aValue.getLength() )
1379 aValue.setLength(aValue.getLength()-1);
1381 return aValue.makeStringAndClear();
1383 // -------------------------------------------------------------------------
1384 ::rtl::OUString SAL_CALL ODatabaseMetaData::getTimeDateFunctions( ) throw(SQLException, RuntimeException)
1386 SQLUINTEGER nValue;
1387 ::rtl::OUStringBuffer aValue;
1388 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_TIMEDATE_FUNCTIONS,nValue,*this);
1390 if(nValue & SQL_FN_TD_CURRENT_DATE)
1391 aValue.appendAscii("CURRENT_DATE,");
1392 if(nValue & SQL_FN_TD_CURRENT_TIME)
1393 aValue.appendAscii("CURRENT_TIME,");
1394 if(nValue & SQL_FN_TD_CURRENT_TIMESTAMP)
1395 aValue.appendAscii("CURRENT_TIMESTAMP,");
1396 if(nValue & SQL_FN_TD_CURDATE)
1397 aValue.appendAscii("CURDATE,");
1398 if(nValue & SQL_FN_TD_CURTIME)
1399 aValue.appendAscii("CURTIME,");
1400 if(nValue & SQL_FN_TD_DAYNAME)
1401 aValue.appendAscii("DAYNAME,");
1402 if(nValue & SQL_FN_TD_DAYOFMONTH)
1403 aValue.appendAscii("DAYOFMONTH,");
1404 if(nValue & SQL_FN_TD_DAYOFWEEK)
1405 aValue.appendAscii("DAYOFWEEK,");
1406 if(nValue & SQL_FN_TD_DAYOFYEAR)
1407 aValue.appendAscii("DAYOFYEAR,");
1408 if(nValue & SQL_FN_TD_EXTRACT)
1409 aValue.appendAscii("EXTRACT,");
1410 if(nValue & SQL_FN_TD_HOUR)
1411 aValue.appendAscii("HOUR,");
1412 if(nValue & SQL_FN_TD_MINUTE)
1413 aValue.appendAscii("MINUTE,");
1414 if(nValue & SQL_FN_TD_MONTH)
1415 aValue.appendAscii("MONTH,");
1416 if(nValue & SQL_FN_TD_MONTHNAME)
1417 aValue.appendAscii("MONTHNAME,");
1418 if(nValue & SQL_FN_TD_NOW)
1419 aValue.appendAscii("NOW,");
1420 if(nValue & SQL_FN_TD_QUARTER)
1421 aValue.appendAscii("QUARTER,");
1422 if(nValue & SQL_FN_TD_SECOND)
1423 aValue.appendAscii("SECOND,");
1424 if(nValue & SQL_FN_TD_TIMESTAMPADD)
1425 aValue.appendAscii("TIMESTAMPADD,");
1426 if(nValue & SQL_FN_TD_TIMESTAMPDIFF)
1427 aValue.appendAscii("TIMESTAMPDIFF,");
1428 if(nValue & SQL_FN_TD_WEEK)
1429 aValue.appendAscii("WEEK,");
1430 if(nValue & SQL_FN_TD_YEAR)
1431 aValue.appendAscii("YEAR,");
1433 if ( aValue.getLength() )
1434 aValue.setLength(aValue.getLength()-1);
1436 return aValue.makeStringAndClear();
1438 // -------------------------------------------------------------------------
1439 ::rtl::OUString SAL_CALL ODatabaseMetaData::getSystemFunctions( ) throw(SQLException, RuntimeException)
1441 SQLUINTEGER nValue;
1442 ::rtl::OUStringBuffer aValue;
1443 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_SYSTEM_FUNCTIONS,nValue,*this);
1445 if(nValue & SQL_FN_SYS_DBNAME)
1446 aValue.appendAscii("DBNAME,");
1447 if(nValue & SQL_FN_SYS_IFNULL)
1448 aValue.appendAscii("IFNULL,");
1449 if(nValue & SQL_FN_SYS_USERNAME)
1450 aValue.appendAscii("USERNAME,");
1452 if ( aValue.getLength() )
1453 aValue.setLength(aValue.getLength()-1);
1455 return aValue.makeStringAndClear();
1457 // -------------------------------------------------------------------------
1458 ::rtl::OUString SAL_CALL ODatabaseMetaData::getNumericFunctions( ) throw(SQLException, RuntimeException)
1460 SQLUINTEGER nValue;
1461 ::rtl::OUStringBuffer aValue;
1462 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_NUMERIC_FUNCTIONS,nValue,*this);
1464 if(nValue & SQL_FN_NUM_ABS)
1465 aValue.appendAscii("ABS,");
1466 if(nValue & SQL_FN_NUM_ACOS)
1467 aValue.appendAscii("ACOS,");
1468 if(nValue & SQL_FN_NUM_ASIN)
1469 aValue.appendAscii("ASIN,");
1470 if(nValue & SQL_FN_NUM_ATAN)
1471 aValue.appendAscii("ATAN,");
1472 if(nValue & SQL_FN_NUM_ATAN2)
1473 aValue.appendAscii("ATAN2,");
1474 if(nValue & SQL_FN_NUM_CEILING)
1475 aValue.appendAscii("CEILING,");
1476 if(nValue & SQL_FN_NUM_COS)
1477 aValue.appendAscii("COS,");
1478 if(nValue & SQL_FN_NUM_COT)
1479 aValue.appendAscii("COT,");
1480 if(nValue & SQL_FN_NUM_DEGREES)
1481 aValue.appendAscii("DEGREES,");
1482 if(nValue & SQL_FN_NUM_EXP)
1483 aValue.appendAscii("EXP,");
1484 if(nValue & SQL_FN_NUM_FLOOR)
1485 aValue.appendAscii("FLOOR,");
1486 if(nValue & SQL_FN_NUM_LOG)
1487 aValue.appendAscii("LOGF,");
1488 if(nValue & SQL_FN_NUM_LOG10)
1489 aValue.appendAscii("LOG10,");
1490 if(nValue & SQL_FN_NUM_MOD)
1491 aValue.appendAscii("MOD,");
1492 if(nValue & SQL_FN_NUM_PI)
1493 aValue.appendAscii("PI,");
1494 if(nValue & SQL_FN_NUM_POWER)
1495 aValue.appendAscii("POWER,");
1496 if(nValue & SQL_FN_NUM_RADIANS)
1497 aValue.appendAscii("RADIANS,");
1498 if(nValue & SQL_FN_NUM_RAND)
1499 aValue.appendAscii("RAND,");
1500 if(nValue & SQL_FN_NUM_ROUND)
1501 aValue.appendAscii("ROUND,");
1502 if(nValue & SQL_FN_NUM_SIGN)
1503 aValue.appendAscii("SIGN,");
1504 if(nValue & SQL_FN_NUM_SIN)
1505 aValue.appendAscii("SIN,");
1506 if(nValue & SQL_FN_NUM_SQRT)
1507 aValue.appendAscii("SQRT,");
1508 if(nValue & SQL_FN_NUM_TAN)
1509 aValue.appendAscii("TAN,");
1510 if(nValue & SQL_FN_NUM_TRUNCATE)
1511 aValue.appendAscii("TRUNCATE,");
1513 if ( aValue.getLength() )
1514 aValue.setLength(aValue.getLength()-1);
1516 return aValue.makeStringAndClear();
1518 // -------------------------------------------------------------------------
1519 sal_Bool SAL_CALL ODatabaseMetaData::supportsExtendedSQLGrammar( ) throw(SQLException, RuntimeException)
1521 SQLUINTEGER nValue;
1522 if(m_bOdbc3)
1524 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1525 return nValue == SQL_OIC_LEVEL2;
1527 else
1529 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1530 return nValue == SQL_OAC_LEVEL2;
1533 // -------------------------------------------------------------------------
1534 sal_Bool SAL_CALL ODatabaseMetaData::supportsCoreSQLGrammar( ) throw(SQLException, RuntimeException)
1536 SQLUINTEGER nValue;
1537 if(m_bOdbc3)
1539 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1540 return nValue == SQL_OIC_CORE || nValue == SQL_OIC_LEVEL2 || nValue == SQL_OIC_LEVEL1;
1542 else
1544 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_SQL_CONFORMANCE,nValue,*this);
1545 return nValue == SQL_OSC_CORE || nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
1548 // -------------------------------------------------------------------------
1549 sal_Bool SAL_CALL ODatabaseMetaData::supportsMinimumSQLGrammar( ) throw(SQLException, RuntimeException)
1551 SQLUINTEGER nValue;
1552 if(m_bOdbc3)
1554 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1555 return nValue == SQL_OIC_LEVEL1 || nValue == SQL_OIC_LEVEL2;
1557 else
1559 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_ODBC_INTERFACE_CONFORMANCE,nValue,*this);
1560 return nValue == SQL_OAC_LEVEL1 || nValue == SQL_OAC_LEVEL2;
1563 // -------------------------------------------------------------------------
1564 sal_Bool SAL_CALL ODatabaseMetaData::supportsFullOuterJoins( ) throw(SQLException, RuntimeException)
1566 SQLUINTEGER nValue;
1567 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_OJ_CAPABILITIES,nValue,*this);
1568 return (nValue & SQL_OJ_FULL) == SQL_OJ_FULL;
1570 // -------------------------------------------------------------------------
1571 sal_Bool SAL_CALL ODatabaseMetaData::supportsLimitedOuterJoins( ) throw(SQLException, RuntimeException)
1573 return supportsFullOuterJoins( );
1575 // -------------------------------------------------------------------------
1576 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInGroupBy( ) throw(SQLException, RuntimeException)
1578 SQLUSMALLINT nValue;
1579 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_GROUP_BY,nValue,*this);
1580 return nValue;
1582 // -------------------------------------------------------------------------
1583 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInOrderBy( ) throw(SQLException, RuntimeException)
1585 SQLUSMALLINT nValue;
1586 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_ORDER_BY,nValue,*this);
1587 return nValue;
1589 // -------------------------------------------------------------------------
1590 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxColumnsInSelect( ) throw(SQLException, RuntimeException)
1592 SQLUSMALLINT nValue;
1593 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_COLUMNS_IN_SELECT,nValue,*this);
1594 return nValue;
1596 // -------------------------------------------------------------------------
1597 sal_Int32 SAL_CALL ODatabaseMetaData::getMaxUserNameLength( ) throw(SQLException, RuntimeException)
1599 SQLUSMALLINT nValue;
1600 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_MAX_USER_NAME_LEN,nValue,*this);
1601 return nValue;
1603 // -------------------------------------------------------------------------
1604 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetType( sal_Int32 setType ) throw(SQLException, RuntimeException)
1606 SQLUINTEGER nValue;
1607 OTools::GetInfo(m_pConnection,m_aConnectionHandle,SQL_CURSOR_SENSITIVITY,nValue,*this);
1608 return (nValue & static_cast<SQLUINTEGER>(setType)) == static_cast<SQLUINTEGER>(setType);
1610 // -------------------------------------------------------------------------
1611 sal_Bool SAL_CALL ODatabaseMetaData::supportsResultSetConcurrency( sal_Int32 setType, sal_Int32 concurrency ) throw(SQLException, RuntimeException)
1613 SQLUINTEGER nValue;
1614 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1615 switch(setType)
1617 default:
1618 case ResultSetType::FORWARD_ONLY:
1619 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1620 break;
1621 case ResultSetType::SCROLL_INSENSITIVE:
1622 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1623 break;
1624 case ResultSetType::SCROLL_SENSITIVE:
1625 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1626 break;
1629 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1630 sal_Bool bRet = sal_False;
1631 switch(concurrency)
1633 case ResultSetConcurrency::READ_ONLY:
1634 bRet = (nValue & SQL_CA2_READ_ONLY_CONCURRENCY) == SQL_CA2_READ_ONLY_CONCURRENCY;
1635 break;
1636 case ResultSetConcurrency::UPDATABLE:
1637 bRet = (nValue & SQL_CA2_OPT_VALUES_CONCURRENCY) == SQL_CA2_OPT_VALUES_CONCURRENCY;
1638 break;
1640 return bRet;
1642 // -------------------------------------------------------------------------
1643 sal_Bool SAL_CALL ODatabaseMetaData::ownUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1645 SQLUINTEGER nValue;
1646 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1647 switch(setType)
1649 default:
1650 case ResultSetType::FORWARD_ONLY:
1651 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1652 break;
1653 case ResultSetType::SCROLL_INSENSITIVE:
1654 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1655 break;
1656 case ResultSetType::SCROLL_SENSITIVE:
1657 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1658 break;
1661 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1662 return (nValue & SQL_CA2_SENSITIVITY_UPDATES) == SQL_CA2_SENSITIVITY_UPDATES;
1664 // -------------------------------------------------------------------------
1665 sal_Bool SAL_CALL ODatabaseMetaData::ownDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1667 SQLUINTEGER nValue;
1668 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1669 switch(setType)
1671 default:
1672 case ResultSetType::FORWARD_ONLY:
1673 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1674 break;
1675 case ResultSetType::SCROLL_INSENSITIVE:
1676 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1677 break;
1678 case ResultSetType::SCROLL_SENSITIVE:
1679 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1680 break;
1683 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1684 return (nValue & SQL_CA2_SENSITIVITY_DELETIONS) != SQL_CA2_SENSITIVITY_DELETIONS;
1686 // -------------------------------------------------------------------------
1687 sal_Bool SAL_CALL ODatabaseMetaData::ownInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1689 SQLUINTEGER nValue;
1690 SQLUSMALLINT nAskFor( SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2 );
1691 switch(setType)
1693 default:
1694 case ResultSetType::FORWARD_ONLY:
1695 nAskFor = SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2;
1696 break;
1697 case ResultSetType::SCROLL_INSENSITIVE:
1698 nAskFor = SQL_STATIC_CURSOR_ATTRIBUTES2;
1699 break;
1700 case ResultSetType::SCROLL_SENSITIVE:
1701 nAskFor = SQL_DYNAMIC_CURSOR_ATTRIBUTES2;
1702 break;
1705 OTools::GetInfo(m_pConnection,m_aConnectionHandle,nAskFor,nValue,*this);
1706 return (nValue & SQL_CA2_SENSITIVITY_ADDITIONS) == SQL_CA2_SENSITIVITY_ADDITIONS;
1708 // -------------------------------------------------------------------------
1709 sal_Bool SAL_CALL ODatabaseMetaData::othersUpdatesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1711 return ownUpdatesAreVisible(setType);
1713 // -------------------------------------------------------------------------
1714 sal_Bool SAL_CALL ODatabaseMetaData::othersDeletesAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1716 return ownDeletesAreVisible(setType);
1718 // -------------------------------------------------------------------------
1719 sal_Bool SAL_CALL ODatabaseMetaData::othersInsertsAreVisible( sal_Int32 setType ) throw(SQLException, RuntimeException)
1721 return ownInsertsAreVisible(setType);
1723 // -------------------------------------------------------------------------
1724 sal_Bool SAL_CALL ODatabaseMetaData::updatesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1726 return sal_False;
1728 // -------------------------------------------------------------------------
1729 sal_Bool SAL_CALL ODatabaseMetaData::deletesAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1731 return sal_False;
1733 // -------------------------------------------------------------------------
1734 sal_Bool SAL_CALL ODatabaseMetaData::insertsAreDetected( sal_Int32 /*setType*/ ) throw(SQLException, RuntimeException)
1736 return sal_False;
1738 // -------------------------------------------------------------------------
1739 sal_Bool SAL_CALL ODatabaseMetaData::supportsBatchUpdates( ) throw(SQLException, RuntimeException)
1741 return sal_False;
1743 // -------------------------------------------------------------------------
1744 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)
1746 return NULL;
1748 // -----------------------------------------------------------------------------