update emoji autocorrect entries from po-files
[LibreOffice.git] / connectivity / source / drivers / firebird / ResultSet.cxx
blob4b1477440007e45e91003a331dec5802a0e2259f
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include "ResultSet.hxx"
21 #include "ResultSetMetaData.hxx"
22 #include "Util.hxx"
24 #include <comphelper/sequence.hxx>
25 #include <cppuhelper/typeprovider.hxx>
26 #include <cppuhelper/supportsservice.hxx>
27 #include <connectivity/dbexception.hxx>
28 #include <propertyids.hxx>
29 #include <rtl/string.hxx>
30 #include <rtl/ustrbuf.hxx>
31 #include <time.h>
32 #include <TConnection.hxx>
34 #include <com/sun/star/beans/PropertyAttribute.hpp>
35 #include <com/sun/star/lang/DisposedException.hpp>
36 #include <com/sun/star/sdbc/DataType.hpp>
37 #include <com/sun/star/sdbcx/CompareBookmark.hpp>
39 using namespace ::comphelper;
40 using namespace ::connectivity;
41 using namespace ::connectivity::firebird;
42 using namespace ::cppu;
43 using namespace ::dbtools;
44 using namespace ::osl;
46 using namespace ::com::sun::star;
47 using namespace ::com::sun::star::uno;
48 using namespace ::com::sun::star::lang;
49 using namespace ::com::sun::star::beans;
50 using namespace ::com::sun::star::sdbc;
51 using namespace ::com::sun::star::sdbcx;
52 using namespace ::com::sun::star::container;
53 using namespace ::com::sun::star::io;
54 using namespace ::com::sun::star::util;
56 OResultSet::OResultSet(Connection* pConnection,
57 ::osl::Mutex& rMutex,
58 const uno::Reference< XInterface >& xStatement,
59 isc_stmt_handle& aStatementHandle,
60 XSQLDA* pSqlda)
61 : OResultSet_BASE(rMutex)
62 , OPropertyContainer(OResultSet_BASE::rBHelper)
63 , m_bIsBookmarkable(false)
64 , m_nFetchSize(1)
65 , m_nResultSetType(::com::sun::star::sdbc::ResultSetType::FORWARD_ONLY)
66 , m_nFetchDirection(::com::sun::star::sdbc::FetchDirection::FORWARD)
67 , m_nResultSetConcurrency(::com::sun::star::sdbc::ResultSetConcurrency::READ_ONLY)
68 , m_pConnection(pConnection)
69 , m_rMutex(rMutex)
70 , m_xStatement(xStatement)
71 , m_xMetaData(0)
72 , m_pSqlda(pSqlda)
73 , m_statementHandle(aStatementHandle)
74 , m_bWasNull(false)
75 , m_currentRow(0)
76 , m_bIsAfterLastRow(false)
77 , m_fieldCount(pSqlda? pSqlda->sqld : 0)
79 SAL_INFO("connectivity.firebird", "OResultSet().");
80 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_ISBOOKMARKABLE),
81 PROPERTY_ID_ISBOOKMARKABLE,
82 PropertyAttribute::READONLY,
83 &m_bIsBookmarkable,
84 cppu::UnoType<decltype(m_bIsBookmarkable)>::get());
85 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHSIZE),
86 PROPERTY_ID_FETCHSIZE,
87 PropertyAttribute::READONLY,
88 &m_nFetchSize,
89 cppu::UnoType<decltype(m_nFetchSize)>::get());
90 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETTYPE),
91 PROPERTY_ID_RESULTSETTYPE,
92 PropertyAttribute::READONLY,
93 &m_nResultSetType,
94 cppu::UnoType<decltype(m_nResultSetType)>::get());
95 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_FETCHDIRECTION),
96 PROPERTY_ID_FETCHDIRECTION,
97 PropertyAttribute::READONLY,
98 &m_nFetchDirection,
99 cppu::UnoType<decltype(m_nFetchDirection)>::get());
100 registerProperty(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_RESULTSETCONCURRENCY),
101 PROPERTY_ID_RESULTSETCONCURRENCY,
102 PropertyAttribute::READONLY,
103 &m_nResultSetConcurrency,
104 cppu::UnoType<decltype(m_nResultSetConcurrency)>::get());
106 if (!pSqlda)
107 return; // TODO: what?
111 OResultSet::~OResultSet()
115 // ---- XResultSet -- Row retrieval methods ------------------------------------
116 sal_Int32 SAL_CALL OResultSet::getRow() throw(SQLException, RuntimeException, std::exception)
118 MutexGuard aGuard(m_rMutex);
119 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
121 return m_currentRow;
124 sal_Bool SAL_CALL OResultSet::next() throw(SQLException, RuntimeException, std::exception)
126 MutexGuard aGuard(m_rMutex);
127 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
129 m_currentRow++;
131 ISC_STATUS fetchStat = isc_dsql_fetch(m_statusVector,
132 &m_statementHandle,
134 m_pSqlda);
135 if (fetchStat == 0) // SUCCESSFUL
137 return sal_True;
139 else if (fetchStat == 100L) // END OF DATASET
141 m_bIsAfterLastRow = true;
142 return sal_False;
144 else
146 SAL_WARN("connectivity.firebird", "Error when fetching data");
147 // Throws sql exception as appropriate
148 evaluateStatusVector(m_statusVector, "isc_dsql_fetch", *this);
149 return sal_False;
153 sal_Bool SAL_CALL OResultSet::previous() throw(SQLException, RuntimeException, std::exception)
155 ::dbtools::throwFunctionNotSupportedSQLException("previous not supported in firebird",
156 *this);
157 return sal_False;
160 sal_Bool SAL_CALL OResultSet::isLast() throw(SQLException, RuntimeException, std::exception)
162 ::dbtools::throwFunctionNotSupportedSQLException("isLast not supported in firebird",
163 *this);
164 return sal_False;
167 sal_Bool SAL_CALL OResultSet::isBeforeFirst() throw(SQLException, RuntimeException, std::exception)
169 MutexGuard aGuard(m_rMutex);
170 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
172 return m_currentRow == 0;
175 sal_Bool SAL_CALL OResultSet::isAfterLast() throw(SQLException, RuntimeException, std::exception)
177 MutexGuard aGuard(m_rMutex);
178 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
180 return m_bIsAfterLastRow;
183 sal_Bool SAL_CALL OResultSet::isFirst() throw(SQLException, RuntimeException, std::exception)
185 MutexGuard aGuard(m_rMutex);
186 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
188 return m_currentRow == 1 && !m_bIsAfterLastRow;
191 void SAL_CALL OResultSet::beforeFirst() throw(SQLException, RuntimeException, std::exception)
193 MutexGuard aGuard(m_rMutex);
194 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
196 if (m_currentRow != 0)
197 ::dbtools::throwFunctionNotSupportedSQLException("beforeFirst not supported in firebird",
198 *this);
201 void SAL_CALL OResultSet::afterLast() throw(SQLException, RuntimeException, std::exception)
203 MutexGuard aGuard(m_rMutex);
204 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
206 if (!m_bIsAfterLastRow)
207 ::dbtools::throwFunctionNotSupportedSQLException("afterLast not supported in firebird",
208 *this);
211 sal_Bool SAL_CALL OResultSet::first() throw(SQLException, RuntimeException, std::exception)
213 MutexGuard aGuard(m_rMutex);
214 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
216 if (m_currentRow == 0)
218 return next();
220 else if (m_currentRow == 1 && !m_bIsAfterLastRow)
222 return sal_True;
224 else
226 ::dbtools::throwFunctionNotSupportedSQLException("first not supported in firebird",
227 *this);
228 return sal_False;
232 sal_Bool SAL_CALL OResultSet::last() throw(SQLException, RuntimeException, std::exception)
234 // We need to iterate past the last row to know when we've passed the last
235 // row, hence we can't actually move to last.
236 ::dbtools::throwFunctionNotSupportedSQLException("last not supported in firebird",
237 *this);
238 return sal_False;
241 sal_Bool SAL_CALL OResultSet::absolute(sal_Int32 aRow) throw(SQLException, RuntimeException, std::exception)
243 MutexGuard aGuard(m_rMutex);
244 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
246 if (aRow > m_currentRow)
248 sal_Int32 aIterations = aRow - m_currentRow;
249 return relative(aIterations);
251 else
253 ::dbtools::throwFunctionNotSupportedSQLException("absolute not supported in firebird",
254 *this);
255 return sal_False;
259 sal_Bool SAL_CALL OResultSet::relative(sal_Int32 row) throw(SQLException, RuntimeException, std::exception)
261 MutexGuard aGuard(m_rMutex);
262 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
264 if (row > 0)
266 while (row--)
268 if (!next())
269 return sal_False;
271 return sal_True;
273 else
275 ::dbtools::throwFunctionNotSupportedSQLException("relative not supported in firebird",
276 *this);
277 return sal_False;
281 void SAL_CALL OResultSet::checkColumnIndex(sal_Int32 nIndex)
282 throw (SQLException, RuntimeException)
284 MutexGuard aGuard(m_rMutex);
285 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
287 if( nIndex < 1 || nIndex > m_fieldCount )
289 ::dbtools::throwSQLException(
290 "No column " + OUString::number(nIndex),
291 ::dbtools::SQL_COLUMN_NOT_FOUND,
292 *this);
296 void SAL_CALL OResultSet::checkRowIndex()
297 throw (SQLException, RuntimeException)
299 MutexGuard aGuard(m_rMutex);
300 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
302 if((m_currentRow < 1) || m_bIsAfterLastRow)
304 ::dbtools::throwSQLException(
305 "Invalid Row",
306 ::dbtools::SQL_INVALID_CURSOR_POSITION,
307 *this);
311 Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeException, std::exception)
313 Any aRet = OPropertySetHelper::queryInterface(rType);
314 return aRet.hasValue() ? aRet : OResultSet_BASE::queryInterface(rType);
317 Sequence< Type > SAL_CALL OResultSet::getTypes() throw( RuntimeException, std::exception)
319 return concatSequences(OPropertySetHelper::getTypes(), OResultSet_BASE::getTypes());
321 // ---- XColumnLocate ---------------------------------------------------------
322 sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& rColumnName)
323 throw(SQLException, RuntimeException, std::exception)
325 MutexGuard aGuard(m_rMutex);
326 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
328 uno::Reference< XResultSetMetaData > xMeta = getMetaData();
329 sal_Int32 nLen = xMeta->getColumnCount();
330 sal_Int32 i;
332 for(i = 1; i<=nLen; ++i)
334 // We assume case sensitive, otherwise you'd have to test
335 // xMeta->isCaseSensitive and use qualsIgnoreAsciiCase as needed.
336 if (rColumnName == xMeta->getColumnName(i))
337 return i;
340 ::dbtools::throwInvalidColumnException(rColumnName, *this);
341 assert(false);
342 return 0; // Never reached
345 uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
347 (void) columnIndex;
348 MutexGuard aGuard(m_rMutex);
349 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
351 return NULL;
354 uno::Reference< XInputStream > SAL_CALL OResultSet::getCharacterStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
356 (void) columnIndex;
357 MutexGuard aGuard(m_rMutex);
358 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
360 return NULL;
363 // ---- Internal Utilities ---------------------------------------------------
364 bool OResultSet::isNull(const sal_Int32 nColumnIndex)
366 assert(nColumnIndex <= m_fieldCount);
367 XSQLVAR* pVar = m_pSqlda->sqlvar;
369 if (pVar[nColumnIndex-1].sqltype & 1) // Indicates column may contain null
371 if (*pVar[nColumnIndex-1].sqlind == -1)
372 return true;
374 return false;
377 template <typename T>
378 T OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT nType)
380 if ((m_bWasNull = isNull(nColumnIndex)))
381 return T();
383 if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == nType)
384 return *reinterpret_cast<T*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata);
385 else
386 return retrieveValue< ORowSetValue >(nColumnIndex, 0);
389 template <>
390 ORowSetValue OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*nType*/)
392 // See http://wiki.openoffice.org/wiki/Documentation/DevGuide/Database/Using_the_getXXX_Methods
393 // (bottom of page) for a chart of possible conversions, we should allow all
394 // of these -- Blob/Clob will probably need some specialist handling especially
395 // w.r.t. to generating Strings for them.
397 // Basically we just have to map to the correct direct request and
398 // ORowSetValue does the rest for us here.
399 switch (m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1)
401 case SQL_TEXT:
402 case SQL_VARYING:
403 return getString(nColumnIndex);
404 case SQL_SHORT:
405 return getShort(nColumnIndex);
406 case SQL_LONG:
407 return getInt(nColumnIndex);
408 case SQL_FLOAT:
409 return getFloat(nColumnIndex);
410 case SQL_DOUBLE:
411 return getDouble(nColumnIndex);
412 case SQL_D_FLOAT:
413 return getFloat(nColumnIndex);
414 case SQL_TIMESTAMP:
415 return getTimestamp(nColumnIndex);
416 case SQL_TYPE_TIME:
417 return getTime(nColumnIndex);
418 case SQL_TYPE_DATE:
419 return getDate(nColumnIndex);
420 case SQL_INT64:
421 return getLong(nColumnIndex);
422 case SQL_BLOB:
423 case SQL_NULL:
424 case SQL_QUAD:
425 case SQL_ARRAY:
426 // TODO: these are all invalid conversions, so maybe we should
427 // throw an exception?
428 return ORowSetValue();
429 default:
430 assert(false);
431 return ORowSetValue();
435 template <>
436 Date OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*nType*/)
438 if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == SQL_TYPE_DATE)
440 ISC_DATE aISCDate = *(reinterpret_cast<ISC_DATE*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata));
442 struct tm aCTime;
443 isc_decode_sql_date(&aISCDate, &aCTime);
445 return Date(aCTime.tm_mday, aCTime.tm_mon, aCTime.tm_year);
447 else
449 return retrieveValue< ORowSetValue >(nColumnIndex, 0);
453 template <>
454 Time OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*nType*/)
456 if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == SQL_TYPE_TIME)
458 ISC_TIME aISCTime = *(reinterpret_cast<ISC_TIME*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata));
460 struct tm aCTime;
461 isc_decode_sql_time(&aISCTime, &aCTime);
463 // first field is nanoseconds -- not supported in firebird or struct tm.
464 // last field denotes UTC (true) or unknown (false)
465 return Time(0, aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, false);
467 else
469 return retrieveValue< ORowSetValue >(nColumnIndex, 0);
473 template <>
474 DateTime OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*nType*/)
476 if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == SQL_TIMESTAMP)
478 ISC_TIMESTAMP aISCTimestamp = *(reinterpret_cast<ISC_TIMESTAMP*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata));
480 struct tm aCTime;
481 isc_decode_timestamp(&aISCTimestamp, &aCTime);
483 // first field is nanoseconds -- not supported in firebird or struct tm.
484 // last field denotes UTC (true) or unknown (false)
485 return DateTime(0, aCTime.tm_sec, aCTime.tm_min, aCTime.tm_hour, aCTime.tm_mday,
486 aCTime.tm_mon, aCTime.tm_year, false);
488 else
490 return retrieveValue< ORowSetValue >(nColumnIndex, 0);
494 template <>
495 OUString OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT /*nType*/)
497 // &~1 to remove the "can contain NULL" indicator
498 int aSqlType = m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1;
499 if (aSqlType == SQL_TEXT )
501 return OUString(m_pSqlda->sqlvar[nColumnIndex-1].sqldata,
502 m_pSqlda->sqlvar[nColumnIndex-1].sqllen,
503 RTL_TEXTENCODING_UTF8);
505 else if (aSqlType == SQL_VARYING)
507 // First 2 bytes are a short containing the length of the string
508 // No idea if sqllen is still valid here?
509 sal_uInt16 aLength = *(reinterpret_cast<sal_uInt16*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata));
510 return OUString(m_pSqlda->sqlvar[nColumnIndex-1].sqldata + 2,
511 aLength,
512 RTL_TEXTENCODING_UTF8);
514 else
516 return retrieveValue< ORowSetValue >(nColumnIndex, 0);
520 template <>
521 ISC_QUAD* OResultSet::retrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT nType)
523 // TODO: this is probably wrong
524 if ((m_pSqlda->sqlvar[nColumnIndex-1].sqltype & ~1) == nType)
525 return reinterpret_cast<ISC_QUAD*>(m_pSqlda->sqlvar[nColumnIndex-1].sqldata);
526 else
527 throw SQLException(); // TODO: better exception (can't convert Blob)
530 template <typename T>
531 T OResultSet::safelyRetrieveValue(const sal_Int32 nColumnIndex, const ISC_SHORT nType)
533 MutexGuard aGuard(m_rMutex);
534 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
536 checkColumnIndex(nColumnIndex);
537 checkRowIndex();
539 if ((m_bWasNull = isNull(nColumnIndex)))
540 return T();
542 return retrieveValue< T >(nColumnIndex, nType);
545 // ---- XRow -----------------------------------------------------------------
546 sal_Bool SAL_CALL OResultSet::wasNull() throw(SQLException, RuntimeException, std::exception)
548 MutexGuard aGuard(m_rMutex);
549 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
551 return m_bWasNull;
554 // ---- XRow: Simple Numerical types ------------------------------------------
555 sal_Bool SAL_CALL OResultSet::getBoolean(sal_Int32 nColumnIndex)
556 throw(SQLException, RuntimeException, std::exception)
558 // Not a native firebird type hence we always have to convert.
559 return safelyRetrieveValue< ORowSetValue >(nColumnIndex);
562 sal_Int8 SAL_CALL OResultSet::getByte(sal_Int32 nColumnIndex)
563 throw(SQLException, RuntimeException, std::exception)
565 // Not a native firebird type hence we always have to convert.
566 return safelyRetrieveValue< ORowSetValue >(nColumnIndex);
569 Sequence< sal_Int8 > SAL_CALL OResultSet::getBytes(sal_Int32 columnIndex)
570 throw(SQLException, RuntimeException, std::exception)
572 (void) columnIndex;
573 return Sequence< sal_Int8 >(); // TODO: implement
574 //return safelyRetrieveValue(columnIndex);
577 sal_Int16 SAL_CALL OResultSet::getShort(sal_Int32 columnIndex)
578 throw(SQLException, RuntimeException, std::exception)
580 return safelyRetrieveValue< sal_Int16 >(columnIndex, SQL_SHORT);
583 sal_Int32 SAL_CALL OResultSet::getInt(sal_Int32 columnIndex)
584 throw(SQLException, RuntimeException, std::exception)
586 return safelyRetrieveValue< sal_Int32 >(columnIndex, SQL_LONG);
589 sal_Int64 SAL_CALL OResultSet::getLong(sal_Int32 columnIndex)
590 throw(SQLException, RuntimeException, std::exception)
592 return safelyRetrieveValue< sal_Int64 >(columnIndex, SQL_INT64);
595 float SAL_CALL OResultSet::getFloat(sal_Int32 columnIndex)
596 throw(SQLException, RuntimeException, std::exception)
598 return safelyRetrieveValue< float >(columnIndex, SQL_FLOAT);
601 double SAL_CALL OResultSet::getDouble(sal_Int32 columnIndex)
602 throw(SQLException, RuntimeException, std::exception)
604 return safelyRetrieveValue< double >(columnIndex, SQL_DOUBLE);
607 // ---- XRow: More complex types ----------------------------------------------
608 OUString SAL_CALL OResultSet::getString(sal_Int32 nIndex)
609 throw(SQLException, RuntimeException, std::exception)
611 return safelyRetrieveValue< OUString >(nIndex);
614 Date SAL_CALL OResultSet::getDate(sal_Int32 nIndex)
615 throw(SQLException, RuntimeException, std::exception)
617 return safelyRetrieveValue< Date >(nIndex, SQL_TYPE_DATE);
620 Time SAL_CALL OResultSet::getTime(sal_Int32 nIndex)
621 throw(SQLException, RuntimeException, std::exception)
623 return safelyRetrieveValue< css::util::Time >(nIndex, SQL_TYPE_TIME);
626 DateTime SAL_CALL OResultSet::getTimestamp(sal_Int32 nIndex)
627 throw(SQLException, RuntimeException, std::exception)
629 return safelyRetrieveValue< DateTime >(nIndex, SQL_TIMESTAMP);
633 uno::Reference< XResultSetMetaData > SAL_CALL OResultSet::getMetaData( ) throw(SQLException, RuntimeException, std::exception)
635 MutexGuard aGuard(m_rMutex);
636 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
638 if(!m_xMetaData.is())
639 m_xMetaData = new OResultSetMetaData(m_pConnection, m_pSqlda);
640 return m_xMetaData;
643 uno::Reference< XArray > SAL_CALL OResultSet::getArray( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
645 (void) columnIndex;
646 MutexGuard aGuard(m_rMutex);
647 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
649 return NULL;
654 uno::Reference< XClob > SAL_CALL OResultSet::getClob( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
656 (void) columnIndex;
657 MutexGuard aGuard(m_rMutex);
658 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
660 return NULL;
663 uno::Reference< XBlob > SAL_CALL OResultSet::getBlob(sal_Int32 columnIndex)
664 throw(SQLException, RuntimeException, std::exception)
666 MutexGuard aGuard(m_rMutex);
667 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
669 // TODO: CLOB etc. should be valid here too, but we probably want some more
670 // cleverness around this.
671 ISC_QUAD* pBlobID = safelyRetrieveValue< ISC_QUAD* >(columnIndex, SQL_BLOB);
672 if (!pBlobID)
673 return 0;
674 return m_pConnection->createBlob(pBlobID);
678 uno::Reference< XRef > SAL_CALL OResultSet::getRef( sal_Int32 columnIndex ) throw(SQLException, RuntimeException, std::exception)
680 (void) columnIndex;
681 MutexGuard aGuard(m_rMutex);
682 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
684 return NULL;
688 Any SAL_CALL OResultSet::getObject( sal_Int32 columnIndex, const uno::Reference< ::com::sun::star::container::XNameAccess >& typeMap ) throw(SQLException, RuntimeException, std::exception)
690 (void) columnIndex;
691 (void) typeMap;
692 MutexGuard aGuard(m_rMutex);
693 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
695 return Any();
702 void SAL_CALL OResultSet::close() throw(SQLException, RuntimeException, std::exception)
704 SAL_INFO("connectivity.firebird", "close().");
707 MutexGuard aGuard(m_rMutex);
708 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
710 dispose();
714 uno::Reference< XInterface > SAL_CALL OResultSet::getStatement()
715 throw(SQLException, RuntimeException, std::exception)
717 MutexGuard aGuard(m_rMutex);
718 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
720 return m_xStatement;
722 //----- XResultSet: unsupported change detection methods ---------------------
723 sal_Bool SAL_CALL OResultSet::rowDeleted() throw(SQLException, RuntimeException, std::exception)
725 ::dbtools::throwFunctionNotSupportedSQLException("rowDeleted not supported in firebird",
726 *this);
727 return sal_False;
729 sal_Bool SAL_CALL OResultSet::rowInserted() throw(SQLException, RuntimeException, std::exception)
731 ::dbtools::throwFunctionNotSupportedSQLException("rowInserted not supported in firebird",
732 *this);
733 return sal_False;
736 sal_Bool SAL_CALL OResultSet::rowUpdated() throw(SQLException, RuntimeException, std::exception)
738 ::dbtools::throwFunctionNotSupportedSQLException("rowUpdated not supported in firebird",
739 *this);
740 return sal_False;
743 void SAL_CALL OResultSet::refreshRow() throw(SQLException, RuntimeException, std::exception)
745 ::dbtools::throwFunctionNotSupportedSQLException("refreshRow not supported in firebird",
746 *this);
750 void SAL_CALL OResultSet::cancel( ) throw(RuntimeException, std::exception)
752 MutexGuard aGuard(m_rMutex);
753 checkDisposed(OResultSet_BASE::rBHelper.bDisposed);
757 //----- XWarningsSupplier UNSUPPORTED -----------------------------------------
758 #if 0
759 void SAL_CALL OResultSet::clearWarnings() throw(SQLException, RuntimeException, std::exception)
761 ::dbtools::throwFunctionNotSupportedSQLException("clearWarnings not supported in firebird",
762 *this);
765 Any SAL_CALL OResultSet::getWarnings() throw(SQLException, RuntimeException, std::exception)
767 ::dbtools::throwFunctionNotSupportedSQLException("getWarnings not supported in firebird",
768 *this);
769 return Any();
771 #endif
773 //----- OIdPropertyArrayUsageHelper ------------------------------------------
774 IPropertyArrayHelper* OResultSet::createArrayHelper() const
776 Sequence< Property > aProperties;
777 describeProperties(aProperties);
778 return new ::cppu::OPropertyArrayHelper(aProperties);
781 IPropertyArrayHelper & OResultSet::getInfoHelper()
783 return *getArrayHelper();
786 void SAL_CALL OResultSet::acquire() throw()
788 OResultSet_BASE::acquire();
791 void SAL_CALL OResultSet::release() throw()
793 OResultSet_BASE::release();
796 uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException, std::exception)
798 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
801 // ---- XServiceInfo -----------------------------------------------------------
802 OUString SAL_CALL OResultSet::getImplementationName() throw ( RuntimeException, std::exception)
804 return OUString("com.sun.star.sdbcx.firebird.ResultSet");
807 Sequence< OUString > SAL_CALL OResultSet::getSupportedServiceNames()
808 throw( RuntimeException, std::exception)
810 Sequence< OUString > aSupported(2);
811 aSupported[0] = "com.sun.star.sdbc.ResultSet";
812 aSupported[1] = "com.sun.star.sdbcx.ResultSet";
813 return aSupported;
816 sal_Bool SAL_CALL OResultSet::supportsService(const OUString& _rServiceName)
817 throw( RuntimeException, std::exception)
819 return cppu::supportsService(this, _rServiceName);
822 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */