1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 <com/sun/star/sdbc/DataType.hpp>
21 #include <com/sun/star/beans/PropertyAttribute.hpp>
22 #include <comphelper/property.hxx>
23 #include <comphelper/sequence.hxx>
24 #include <cppuhelper/typeprovider.hxx>
25 #include <comphelper/extract.hxx>
26 #include <com/sun/star/lang/DisposedException.hpp>
27 #include <com/sun/star/sdbc/ResultSetType.hpp>
28 #include <com/sun/star/sdbc/FetchDirection.hpp>
29 #include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
30 #include <comphelper/types.hxx>
31 #include <connectivity/dbexception.hxx>
32 #include <connectivity/dbtools.hxx>
34 #include <TSortIndex.hxx>
35 #include <rtl/string.hxx>
38 #include "MResultSet.hxx"
39 #include "MResultSetMetaData.hxx"
40 #include "FDatabaseMetaDataResultSet.hxx"
42 #include "resource/mork_res.hrc"
43 #include "resource/common_res.hrc"
45 #if OSL_DEBUG_LEVEL > 0
46 # define OUtoCStr( x ) ( OUStringToOString ( (x), RTL_TEXTENCODING_ASCII_US).getStr())
47 #else /* OSL_DEBUG_LEVEL */
48 # define OUtoCStr( x ) ("dummy")
49 #endif /* OSL_DEBUG_LEVEL */
51 using namespace ::comphelper
;
52 using namespace connectivity
;
53 using namespace connectivity::mork
;
54 using namespace ::cppu
;
55 using namespace com::sun::star::uno
;
56 using namespace com::sun::star::lang
;
57 using namespace com::sun::star::beans
;
58 using namespace com::sun::star::sdbc
;
59 using namespace com::sun::star::container
;
60 using namespace com::sun::star::io
;
61 using namespace com::sun::star::util
;
63 //------------------------------------------------------------------------------
64 // IMPLEMENT_SERVICE_INFO(OResultSet,"com.sun.star.sdbcx.OResultSet","com.sun.star.sdbc.ResultSet");
65 OUString SAL_CALL
OResultSet::getImplementationName( ) throw ( RuntimeException
) \
67 return OUString("com.sun.star.sdbcx.mork.ResultSet");
69 // -------------------------------------------------------------------------
70 Sequence
< OUString
> SAL_CALL
OResultSet::getSupportedServiceNames( ) throw( RuntimeException
)
72 ::com::sun::star::uno::Sequence
< OUString
> aSupported(2);
73 aSupported
[0] = OUString("com.sun.star.sdbc.ResultSet");
74 aSupported
[1] = OUString("com.sun.star.sdbcx.ResultSet");
77 // -------------------------------------------------------------------------
78 sal_Bool SAL_CALL
OResultSet::supportsService( const OUString
& _rServiceName
) throw( RuntimeException
)
80 Sequence
< OUString
> aSupported(getSupportedServiceNames());
81 const OUString
* pSupported
= aSupported
.getConstArray();
82 const OUString
* pEnd
= pSupported
+ aSupported
.getLength();
83 for (;pSupported
!= pEnd
&& !pSupported
->equals(_rServiceName
); ++pSupported
)
86 return pSupported
!= pEnd
;
89 // -------------------------------------------------------------------------
90 OResultSet::OResultSet(OCommonStatement
* pStmt
, const ::boost::shared_ptr
< connectivity::OSQLParseTreeIterator
>& _pSQLIterator
)
91 : OResultSet_BASE(m_aMutex
)
92 ,OPropertySetHelper(OResultSet_BASE::rBHelper
)
99 ,m_nResultSetType(ResultSetType::SCROLL_INSENSITIVE
)
100 ,m_nFetchDirection(FetchDirection::FORWARD
)
101 ,m_nResultSetConcurrency(ResultSetConcurrency::UPDATABLE
)
102 ,m_pSQLIterator( _pSQLIterator
)
103 ,m_pParseTree( _pSQLIterator
->getParseTree() )
104 ,m_aQueryHelper(pStmt
->getOwnConnection()->getColumnAlias())
106 ,m_CurrentRowCount(0)
108 ,m_bIsAlwaysFalseQuery(sal_False
)
116 //m_aQuery.setMaxNrOfReturns(pStmt->getOwnConnection()->getMaxResultRecords());
118 // -------------------------------------------------------------------------
119 OResultSet::~OResultSet()
123 // -------------------------------------------------------------------------
124 void OResultSet::disposing(void)
126 OPropertySetHelper::disposing();
128 ::osl::MutexGuard
aGuard(m_aMutex
);
130 m_xStatement
.clear();
134 m_xParamColumns
= NULL
;
142 // -------------------------------------------------------------------------
143 Any SAL_CALL
OResultSet::queryInterface( const Type
& rType
) throw(RuntimeException
)
145 Any aRet
= OPropertySetHelper::queryInterface(rType
);
147 aRet
= OResultSet_BASE::queryInterface(rType
);
150 // -------------------------------------------------------------------------
151 Sequence
< Type
> SAL_CALL
OResultSet::getTypes( ) throw( RuntimeException
)
153 OTypeCollection
aTypes( ::getCppuType( (const Reference
< ::com::sun::star::beans::XMultiPropertySet
> *)0 ),
154 ::getCppuType( (const Reference
< ::com::sun::star::beans::XFastPropertySet
> *)0 ),
155 ::getCppuType( (const Reference
< ::com::sun::star::beans::XPropertySet
> *)0 ));
157 return ::comphelper::concatSequences(aTypes
.getTypes(),OResultSet_BASE::getTypes());
159 // -------------------------------------------------------------------------
160 void OResultSet::methodEntry()
162 checkDisposed(OResultSet_BASE::rBHelper
.bDisposed
);
165 OSL_FAIL( "OResultSet::methodEntry: looks like we're disposed, but how is this possible?" );
166 throw DisposedException( OUString(), *this );
170 // -------------------------------------------------------------------------
171 sal_Int32 SAL_CALL
OResultSet::findColumn( const OUString
& columnName
) throw(SQLException
, RuntimeException
)
173 ResultSetEntryGuard
aGuard( *this );
175 // find the first column with the name columnName
176 Reference
< XResultSetMetaData
> xMeta
= getMetaData();
177 sal_Int32 nLen
= xMeta
->getColumnCount();
180 if(xMeta
->isCaseSensitive(i
) ? columnName
== xMeta
->getColumnName(i
) :
181 columnName
.equalsIgnoreAsciiCase(xMeta
->getColumnName(i
)))
185 // -------------------------------------------------------------------------
186 Reference
< XInputStream
> SAL_CALL
OResultSet::getBinaryStream( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
190 // -------------------------------------------------------------------------
191 Reference
< XInputStream
> SAL_CALL
OResultSet::getCharacterStream( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
196 // -------------------------------------------------------------------------
197 sal_Bool SAL_CALL
OResultSet::getBoolean( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
199 ResultSetEntryGuard
aGuard( *this );
200 m_bWasNull
= sal_True
;
203 // -------------------------------------------------------------------------
205 sal_Int8 SAL_CALL
OResultSet::getByte( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
207 ResultSetEntryGuard
aGuard( *this );
210 // -------------------------------------------------------------------------
212 Sequence
< sal_Int8
> SAL_CALL
OResultSet::getBytes( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
214 ResultSetEntryGuard
aGuard( *this );
215 return Sequence
< sal_Int8
>();
217 // -------------------------------------------------------------------------
219 Date SAL_CALL
OResultSet::getDate( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
221 ResultSetEntryGuard
aGuard( *this );
224 // -------------------------------------------------------------------------
226 double SAL_CALL
OResultSet::getDouble( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
228 ResultSetEntryGuard
aGuard( *this );
231 // -------------------------------------------------------------------------
233 float SAL_CALL
OResultSet::getFloat( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
235 ResultSetEntryGuard
aGuard( *this );
238 // -------------------------------------------------------------------------
240 sal_Int32 SAL_CALL
OResultSet::getInt( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
242 ResultSetEntryGuard
aGuard( *this );
246 // -------------------------------------------------------------------------
247 sal_Int32 SAL_CALL
OResultSet::getRow( ) throw(SQLException
, RuntimeException
)
249 ResultSetEntryGuard
aGuard( *this );
251 OSL_TRACE("In/Out: OResultSet::getRow, return = %u", m_nRowPos
);
254 // -------------------------------------------------------------------------
256 sal_Int64 SAL_CALL
OResultSet::getLong( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
258 ResultSetEntryGuard
aGuard( *this );
261 // -------------------------------------------------------------------------
263 Reference
< XResultSetMetaData
> SAL_CALL
OResultSet::getMetaData( ) throw(SQLException
, RuntimeException
)
265 ResultSetEntryGuard
aGuard( *this );
267 if(!m_xMetaData
.is())
268 m_xMetaData
= new OResultSetMetaData(
269 m_pSQLIterator
->getSelectColumns(), m_pSQLIterator
->getTables().begin()->first
,m_pTable
,determineReadOnly());
272 // -------------------------------------------------------------------------
273 Reference
< XArray
> SAL_CALL
OResultSet::getArray( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
278 // -------------------------------------------------------------------------
280 Reference
< XClob
> SAL_CALL
OResultSet::getClob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
284 // -------------------------------------------------------------------------
285 Reference
< XBlob
> SAL_CALL
OResultSet::getBlob( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
289 // -------------------------------------------------------------------------
291 Reference
< XRef
> SAL_CALL
OResultSet::getRef( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
295 // -------------------------------------------------------------------------
297 Any SAL_CALL
OResultSet::getObject( sal_Int32
/*columnIndex*/, const Reference
< ::com::sun::star::container::XNameAccess
>& /*typeMap*/ ) throw(SQLException
, RuntimeException
)
301 // -------------------------------------------------------------------------
303 sal_Int16 SAL_CALL
OResultSet::getShort( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
307 // -------------------------------------------------------------------------
309 void OResultSet::checkIndex(sal_Int32 columnIndex
) throw(::com::sun::star::sdbc::SQLException
)
311 if(columnIndex
<= 0 || columnIndex
> (sal_Int32
)m_xColumns
->get().size())
312 ::dbtools::throwInvalidIndexException(*this);
314 // -------------------------------------------------------------------------
315 sal_uInt32
OResultSet::currentRowCount()
317 if ( m_bIsAlwaysFalseQuery
)
319 //return 0;//m_aQuery.getRealRowCount() - deletedCount();
320 // new implementation
321 return m_aQueryHelper
.getResultCount();
324 // -------------------------------------------------------------------------
326 sal_Bool
OResultSet::fetchCurrentRow( ) throw(SQLException
, RuntimeException
)
328 OSL_TRACE("fetchCurrentRow, m_nRowPos = %u", m_nRowPos
);
329 return fetchRow(getCurrentCardNumber());
332 // -------------------------------------------------------------------------
333 sal_Bool
OResultSet::pushCard(sal_uInt32
/*cardNumber*/) throw(SQLException
, RuntimeException
)
335 SAL_INFO("connectivity.mork", "=> OResultSet::pushCard()" );
340 // Check whether we are storing the updated row
341 if ( (m_aRow->get())[0].isNull() || (sal_Int32)(m_aRow->get())[0] != (sal_Int32)cardNumber )
344 sal_Int32 nCount = m_aColumnNames.getLength();
345 m_aQuery.setRowStates(cardNumber,m_RowStates);
346 for( sal_Int32 i = 1; i <= nCount; i++ )
348 if ( (m_aRow->get())[i].isBound() )
351 // Everything in the addressbook is a string!
353 if ( !m_aQuery.setRowValue( (m_aRow->get())[i], cardNumber, m_aColumnNames[i-1], DataType::VARCHAR ))
355 m_pStatement->getOwnConnection()->throwSQLException( m_aQuery.getError(), *this );
362 // -------------------------------------------------------------------------
363 sal_Bool
OResultSet::fetchRow(sal_Int32 cardNumber
,sal_Bool bForceReload
) throw(SQLException
, RuntimeException
)
365 SAL_INFO("connectivity.mork", "=> OResultSet::fetchRow()" );
367 OSL_TRACE("fetchRow, cardNumber = %u", cardNumber
);
370 // Check whether we've already fetched the row...
371 if ( !(m_aRow
->get())[0].isNull() && (sal_Int32
)(m_aRow
->get())[0] == (sal_Int32
)cardNumber
)
373 //Check whether the old row has been changed
374 if (cardNumber
== m_nUpdatedRow
)
376 //write back the changes first
377 if (!pushCard(cardNumber
)) //error write back the changes
378 throw SQLException();
382 // m_aQuery.resyncRow(cardNumber);
384 if ( validRow( cardNumber
) == sal_False
)
387 (m_aRow
->get())[0] = (sal_Int32
)cardNumber
;
388 sal_Int32 nCount
= m_aColumnNames
.getLength();
389 //m_RowStates = m_aQuery.getRowStates(cardNumber);
390 for( sal_Int32 i
= 1; i
<= nCount
; i
++ )
392 if ( (m_aRow
->get())[i
].isBound() )
395 // Everything in the addressbook is a string!
397 if ( !m_aQueryHelper
.getRowValue( (m_aRow
->get())[i
], cardNumber
, m_aColumnNames
[i
-1], DataType::VARCHAR
))
399 m_pStatement
->getOwnConnection()->throwSQLException( m_aQueryHelper
.getError(), *this );
406 // -------------------------------------------------------------------------
408 const ORowSetValue
& OResultSet::getValue(sal_Int32 cardNumber
, sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
410 if ( fetchRow( cardNumber
) == sal_False
)
412 OSL_FAIL("fetchRow() returned False" );
413 m_bWasNull
= sal_True
;
414 return *ODatabaseMetaDataResultSet::getEmptyValue();
417 m_bWasNull
= (m_aRow
->get())[columnIndex
].isNull();
418 return (m_aRow
->get())[columnIndex
];
421 // -------------------------------------------------------------------------
424 OUString SAL_CALL
OResultSet::getString( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
426 ResultSetEntryGuard
aGuard( *this );
428 OSL_ENSURE(m_xColumns
.is(), "Need the Columns!!");
429 OSL_ENSURE(columnIndex
<= (sal_Int32
)m_xColumns
->get().size(), "Trying to access invalid columns number");
430 checkIndex( columnIndex
);
432 // If this query was sorted then we should have a valid KeySet, so use it
433 return getValue(getCurrentCardNumber(), mapColumn( columnIndex
) );
436 // -------------------------------------------------------------------------
438 Time SAL_CALL
OResultSet::getTime( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
440 ResultSetEntryGuard
aGuard( *this );
443 // -------------------------------------------------------------------------
446 DateTime SAL_CALL
OResultSet::getTimestamp( sal_Int32
/*columnIndex*/ ) throw(SQLException
, RuntimeException
)
448 ResultSetEntryGuard
aGuard( *this );
451 // -------------------------------------------------------------------------
453 sal_Bool SAL_CALL
OResultSet::isBeforeFirst( ) throw(SQLException
, RuntimeException
)
455 ResultSetEntryGuard
aGuard( *this );
457 // here you have to implement your movements
458 // return true means there is no data
459 OSL_TRACE("In/Out: OResultSet::isBeforeFirst" );
460 return( m_nRowPos
< 1 );
462 // -------------------------------------------------------------------------
463 sal_Bool SAL_CALL
OResultSet::isAfterLast( ) throw(SQLException
, RuntimeException
)
465 SAL_WARN("connectivity.mork", "OResultSet::isAfterLast() NOT IMPLEMENTED!");
466 ResultSetEntryGuard
aGuard( *this );
468 OSL_TRACE("In/Out: OResultSet::isAfterLast" );
470 return m_nRowPos
> currentRowCount() && m_aQueryHelper
.queryComplete();
472 // -------------------------------------------------------------------------
473 sal_Bool SAL_CALL
OResultSet::isFirst( ) throw(SQLException
, RuntimeException
)
475 ResultSetEntryGuard
aGuard( *this );
477 OSL_TRACE("In/Out: OResultSet::isFirst" );
478 return m_nRowPos
== 1;
480 // -------------------------------------------------------------------------
481 sal_Bool SAL_CALL
OResultSet::isLast( ) throw(SQLException
, RuntimeException
)
483 SAL_WARN("connectivity.mork", "OResultSet::isLast() NOT IMPLEMENTED!");
484 ResultSetEntryGuard
aGuard( *this );
486 OSL_TRACE("In/Out: OResultSet::isLast" );
488 return m_nRowPos
== currentRowCount() && m_aQueryHelper
.queryComplete();
490 // -------------------------------------------------------------------------
491 void SAL_CALL
OResultSet::beforeFirst( ) throw(SQLException
, RuntimeException
)
493 ResultSetEntryGuard
aGuard( *this );
495 // move before the first row so that isBeforeFirst returns false
496 OSL_TRACE("In/Out: OResultSet::beforeFirst" );
500 // -------------------------------------------------------------------------
501 void SAL_CALL
OResultSet::afterLast( ) throw(SQLException
, RuntimeException
)
503 ResultSetEntryGuard
aGuard( *this );
504 OSL_TRACE("In/Out: OResultSet::afterLast" );
509 // -------------------------------------------------------------------------
511 void SAL_CALL
OResultSet::close() throw(SQLException
, RuntimeException
)
513 OSL_TRACE("In/Out: OResultSet::close" );
516 // -------------------------------------------------------------------------
518 sal_Bool SAL_CALL
OResultSet::first( ) throw(SQLException
, RuntimeException
)
520 OSL_TRACE("In/Out: OResultSet::first" );
521 return seekRow( FIRST_POS
);
523 // -------------------------------------------------------------------------
525 sal_Bool SAL_CALL
OResultSet::last( ) throw(SQLException
, RuntimeException
)
527 OSL_TRACE("In/Out: OResultSet::last" );
528 return seekRow( LAST_POS
);
530 // -------------------------------------------------------------------------
531 sal_Bool SAL_CALL
OResultSet::absolute( sal_Int32 row
) throw(SQLException
, RuntimeException
)
533 OSL_TRACE("In/Out: OResultSet::absolute" );
534 return seekRow( ABSOLUTE_POS
, row
);
536 // -------------------------------------------------------------------------
537 sal_Bool SAL_CALL
OResultSet::relative( sal_Int32 row
) throw(SQLException
, RuntimeException
)
539 OSL_TRACE("In/Out: OResultSet::relative" );
540 return seekRow( RELATIVE_POS
, row
);
542 // -------------------------------------------------------------------------
543 sal_Bool SAL_CALL
OResultSet::previous( ) throw(SQLException
, RuntimeException
)
545 ResultSetEntryGuard
aGuard( *this );
546 OSL_TRACE("In/Out: OResultSet::previous" );
547 return seekRow( PRIOR_POS
);
549 // -------------------------------------------------------------------------
550 Reference
< XInterface
> SAL_CALL
OResultSet::getStatement( ) throw(SQLException
, RuntimeException
)
552 ResultSetEntryGuard
aGuard( *this );
554 OSL_TRACE("In/Out: OResultSet::getStatement" );
557 // -------------------------------------------------------------------------
559 sal_Bool SAL_CALL
OResultSet::rowDeleted( ) throw(SQLException
, RuntimeException
)
561 SAL_WARN("connectivity.mork", "OResultSet::rowDeleted() NOT IMPLEMENTED!");
562 ResultSetEntryGuard
aGuard( *this );
563 OSL_TRACE("In/Out: OResultSet::rowDeleted, m_RowStates=%u",m_RowStates
);
564 return sal_True
;//return ((m_RowStates & RowStates_Deleted) == RowStates_Deleted) ;
566 // -------------------------------------------------------------------------
567 sal_Bool SAL_CALL
OResultSet::rowInserted( ) throw(SQLException
, RuntimeException
)
569 SAL_WARN("connectivity.mork", "OResultSet::rowInserted() NOT IMPLEMENTED!");
570 ResultSetEntryGuard
aGuard( *this );
571 OSL_TRACE("In/Out: OResultSet::rowInserted,m_RowStates=%u",m_RowStates
);
572 return sal_True
;//return ((m_RowStates & RowStates_Inserted) == RowStates_Inserted);
574 // -------------------------------------------------------------------------
575 sal_Bool SAL_CALL
OResultSet::rowUpdated( ) throw(SQLException
, RuntimeException
)
577 SAL_WARN("connectivity.mork", "OResultSet::rowUpdated() NOT IMPLEMENTED!");
578 ResultSetEntryGuard
aGuard( *this );
579 OSL_TRACE("In/Out: OResultSet::rowUpdated,m_RowStates=%u",m_RowStates
);
580 return sal_True
;// return ((m_RowStates & RowStates_Updated) == RowStates_Updated) ;
582 // -------------------------------------------------------------------------
584 sal_Bool SAL_CALL
OResultSet::next( ) throw(SQLException
, RuntimeException
)
586 return seekRow( NEXT_POS
);
588 // -------------------------------------------------------------------------
590 sal_Bool SAL_CALL
OResultSet::wasNull( ) throw(SQLException
, RuntimeException
)
592 ResultSetEntryGuard
aGuard( *this );
596 // -------------------------------------------------------------------------
598 void SAL_CALL
OResultSet::cancel( ) throw(RuntimeException
)
600 ResultSetEntryGuard
aGuard( *this );
601 OSL_TRACE("In/Out: OResultSet::cancel" );
604 // -------------------------------------------------------------------------
605 void SAL_CALL
OResultSet::clearWarnings( ) throw(SQLException
, RuntimeException
)
607 OSL_TRACE("In/Out: OResultSet::clearWarnings" );
609 // -------------------------------------------------------------------------
610 Any SAL_CALL
OResultSet::getWarnings( ) throw(SQLException
, RuntimeException
)
612 OSL_TRACE("In/Out: OResultSet::getWarnings" );
615 // -------------------------------------------------------------------------
616 void SAL_CALL
OResultSet::refreshRow( ) throw(SQLException
, RuntimeException
)
618 OSL_TRACE("In/Out: OResultSet::refreshRow" );
619 if (fetchRow(getCurrentCardNumber(),sal_True
)) {
620 //force fetch current row will cause we lose all change to the current row
621 m_pStatement
->getOwnConnection()->throwSQLException( STR_ERROR_REFRESH_ROW
, *this );
624 // -------------------------------------------------------------------------
625 IPropertyArrayHelper
* OResultSet::createArrayHelper( ) const
627 Sequence
< Property
> aProps(5);
628 Property
* pProperties
= aProps
.getArray();
630 DECL_PROP0(FETCHDIRECTION
, sal_Int32
);
631 DECL_PROP0(FETCHSIZE
, sal_Int32
);
632 DECL_BOOL_PROP1IMPL(ISBOOKMARKABLE
) PropertyAttribute::READONLY
);
633 DECL_PROP1IMPL(RESULTSETCONCURRENCY
,sal_Int32
) PropertyAttribute::READONLY
);
634 DECL_PROP1IMPL(RESULTSETTYPE
, sal_Int32
) PropertyAttribute::READONLY
);
636 return new OPropertyArrayHelper(aProps
);
638 // -------------------------------------------------------------------------
639 IPropertyArrayHelper
& OResultSet::getInfoHelper()
641 return *const_cast<OResultSet
*>(this)->getArrayHelper();
643 // -------------------------------------------------------------------------
644 sal_Bool
OResultSet::convertFastPropertyValue(
645 Any
& /*rConvertedValue*/,
648 const Any
& /*rValue*/ )
649 throw (::com::sun::star::lang::IllegalArgumentException
)
651 OSL_FAIL( "OResultSet::convertFastPropertyValue: not implemented!" );
654 case PROPERTY_ID_ISBOOKMARKABLE
:
655 case PROPERTY_ID_RESULTSETCONCURRENCY
:
656 case PROPERTY_ID_RESULTSETTYPE
:
657 throw ::com::sun::star::lang::IllegalArgumentException();
658 case PROPERTY_ID_FETCHDIRECTION
:
659 case PROPERTY_ID_FETCHSIZE
:
665 // -------------------------------------------------------------------------
666 void OResultSet::setFastPropertyValue_NoBroadcast(
668 const Any
& /*rValue*/
672 OSL_FAIL( "OResultSet::setFastPropertyValue_NoBroadcast: not implemented!" );
675 case PROPERTY_ID_ISBOOKMARKABLE
:
676 case PROPERTY_ID_RESULTSETCONCURRENCY
:
677 case PROPERTY_ID_RESULTSETTYPE
:
679 case PROPERTY_ID_FETCHDIRECTION
:
681 case PROPERTY_ID_FETCHSIZE
:
687 // -------------------------------------------------------------------------
688 void OResultSet::getFastPropertyValue(
695 case PROPERTY_ID_RESULTSETCONCURRENCY
:
696 rValue
<<= (sal_Int32
)m_nResultSetConcurrency
;
698 case PROPERTY_ID_RESULTSETTYPE
:
699 rValue
<<= m_nResultSetType
;
701 case PROPERTY_ID_FETCHDIRECTION
:
702 rValue
<<= m_nFetchDirection
;
704 case PROPERTY_ID_FETCHSIZE
:
705 rValue
<<= m_nFetchSize
;
707 case PROPERTY_ID_ISBOOKMARKABLE
:
708 const_cast< OResultSet
* >( this )->determineReadOnly();
709 rValue
<<= !m_bIsReadOnly
;
713 // -----------------------------------------------------------------------------
714 void SAL_CALL
OResultSet::acquire() throw()
716 OResultSet_BASE::acquire();
718 // -----------------------------------------------------------------------------
719 void SAL_CALL
OResultSet::release() throw()
721 OResultSet_BASE::release();
723 // -----------------------------------------------------------------------------
724 ::com::sun::star::uno::Reference
< ::com::sun::star::beans::XPropertySetInfo
> SAL_CALL
OResultSet::getPropertySetInfo( ) throw(::com::sun::star::uno::RuntimeException
)
726 return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
729 // -------------------------------------------------------------------------
730 void OResultSet::parseParameter( const OSQLParseNode
* pNode
, OUString
& rMatchString
)
732 OSL_ENSURE(pNode
->count() > 0,"Error parsing parameter in Parse Tree");
733 OSQLParseNode
*pMark
= pNode
->getChild(0);
735 // Initialize to empty string
736 rMatchString
= OUString("");
738 OUString aParameterName
;
739 if (SQL_ISPUNCTUATION(pMark
,"?")) {
740 aParameterName
= OUString("?");
742 else if (SQL_ISPUNCTUATION(pMark
,":")) {
743 aParameterName
= pNode
->getChild(1)->getTokenValue();
745 // XXX - Now we know name, what's value????
747 OSL_TRACE("Parameter name [%d]: %s", m_nParamIndex
,OUtoCStr(aParameterName
) );
749 if ( m_aParameterRow
.is() ) {
750 OSL_ENSURE( m_nParamIndex
< (sal_Int32
)m_aParameterRow
->get().size() + 1, "More parameters than values found" );
751 rMatchString
= (m_aParameterRow
->get())[(sal_uInt16
)m_nParamIndex
];
752 #if OSL_DEBUG_LEVEL > 0
753 OSL_TRACE("Prop Value : %s", OUtoCStr( rMatchString
) );
756 #if OSL_DEBUG_LEVEL > 0
758 OSL_TRACE("Prop Value : Invalid ParameterRow!" );
763 void OResultSet::analyseWhereClause( const OSQLParseNode
* parseTree
,
764 MQueryExpression
&queryExpression
)
767 MQueryOp::cond_type
op( MQueryOp::Is
);
768 OUString matchString
;
770 if ( parseTree
== NULL
)
773 if ( m_pSQLIterator
->getParseTree() != NULL
) {
774 ::rtl::Reference
<OSQLColumns
> xColumns
= m_pSQLIterator
->getParameters();
777 OUString aColName
, aParameterValue
;
778 OSQLColumns::Vector::iterator aIter
= xColumns
->get().begin();
780 for(;aIter
!= xColumns
->get().end();++aIter
)
782 (*aIter
)->getPropertyValue(OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
)) >>= aColName
;
783 OSL_TRACE("Prop Column Name : %s", OUtoCStr( aColName
) );
784 if ( m_aParameterRow
.is() ) {
785 aParameterValue
= (m_aParameterRow
->get())[(sal_uInt16
)i
];
786 #if OSL_DEBUG_LEVEL > 0
787 OSL_TRACE("Prop Value : %s", OUtoCStr( aParameterValue
) );
790 #if OSL_DEBUG_LEVEL > 0
792 OSL_TRACE("Prop Value : Invalid ParameterRow!" );
801 if ( SQL_ISRULE(parseTree
,where_clause
) )
803 OSL_TRACE("analyseSQL : Got WHERE clause");
804 // Reset Parameter Counter
806 analyseWhereClause( parseTree
->getChild( 1 ), queryExpression
);
808 else if ( parseTree
->count() == 3 && // Handle ()'s
809 SQL_ISPUNCTUATION(parseTree
->getChild(0),"(") &&
810 SQL_ISPUNCTUATION(parseTree
->getChild(2),")"))
813 OSL_TRACE("analyseSQL : Got Punctuation ()");
814 MQueryExpression
*subExpression
= new MQueryExpression();
815 analyseWhereClause( parseTree
->getChild( 1 ), *subExpression
);
816 queryExpression
.getExpressions().push_back( subExpression
);
818 else if ((SQL_ISRULE(parseTree
,search_condition
) || (SQL_ISRULE(parseTree
,boolean_term
)))
819 && parseTree
->count() == 3) // Handle AND/OR
822 OSL_TRACE("analyseSQL : Got AND/OR clause");
824 // TODO - Need to take care or AND, for now match is always OR
825 analyseWhereClause( parseTree
->getChild( 0 ), queryExpression
);
826 analyseWhereClause( parseTree
->getChild( 2 ), queryExpression
);
828 if (SQL_ISTOKEN(parseTree
->getChild(1),OR
)) { // OR-Operator
829 queryExpression
.setExpressionCondition( MQueryExpression::OR
);
831 else if (SQL_ISTOKEN(parseTree
->getChild(1),AND
)) { // AND-Operator
832 queryExpression
.setExpressionCondition( MQueryExpression::AND
);
835 OSL_FAIL("analyseSQL: Error in Parse Tree");
838 else if (SQL_ISRULE(parseTree
,comparison_predicate
))
840 OSL_ENSURE(parseTree
->count() == 3, "Error parsing COMPARE predicate");
841 if (!(SQL_ISRULE(parseTree
->getChild(0),column_ref
) ||
842 parseTree
->getChild(2)->getNodeType() == SQL_NODE_STRING
||
843 parseTree
->getChild(2)->getNodeType() == SQL_NODE_INTNUM
||
844 parseTree
->getChild(2)->getNodeType() == SQL_NODE_APPROXNUM
||
845 SQL_ISTOKEN(parseTree
->getChild(2),TRUE
) ||
846 SQL_ISTOKEN(parseTree
->getChild(2),FALSE
) ||
847 SQL_ISRULE(parseTree
->getChild(2),parameter
) ||
849 (SQL_ISRULE(parseTree
->getChild(2),set_fct_spec
) && SQL_ISPUNCTUATION(parseTree
->getChild(2)->getChild(0),"{"))))
851 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX
, *this );
854 OSQLParseNode
*pPrec
= parseTree
->getChild(1);
855 if (pPrec
->getNodeType() == SQL_NODE_EQUAL
)
857 else if (pPrec
->getNodeType() == SQL_NODE_NOTEQUAL
)
858 op
= MQueryOp::IsNot
;
860 OUString sTableRange
;
861 if(SQL_ISRULE(parseTree
->getChild(0),column_ref
))
862 m_pSQLIterator
->getColumnRange(parseTree
->getChild(0),columnName
,sTableRange
);
863 else if(parseTree
->getChild(0)->isToken())
864 columnName
= parseTree
->getChild(0)->getTokenValue();
866 if ( SQL_ISRULE(parseTree
->getChild(2),parameter
) ) {
867 parseParameter( parseTree
->getChild(2), matchString
);
870 matchString
= parseTree
->getChild(2)->getTokenValue();
873 if ( columnName
.compareToAscii("0") ==0 && op
== MQueryOp::Is
&&
874 matchString
.compareToAscii("1") == 0 ) {
875 OSL_TRACE("Query always evaluates to FALSE");
876 m_bIsAlwaysFalseQuery
= sal_True
;
878 queryExpression
.getExpressions().push_back( new MQueryExpressionString( columnName
, op
, matchString
));
880 else if (SQL_ISRULE(parseTree
,like_predicate
))
882 OSL_ENSURE(parseTree
->count() == 2, "Error parsing LIKE predicate");
884 OSL_TRACE("analyseSQL : Got LIKE rule");
886 if ( !(SQL_ISRULE(parseTree
->getChild(0), column_ref
)) )
888 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_COLUMN
, *this );
892 OSQLParseNode
*pColumn
;
893 OSQLParseNode
*pAtom
;
894 OSQLParseNode
*pOptEscape
;
895 const OSQLParseNode
* pPart2
= parseTree
->getChild(1);
896 pColumn
= parseTree
->getChild(0); // Match Item
897 pAtom
= pPart2
->getChild(static_cast<sal_uInt32
>(pPart2
->count()-2)); // Match String
898 pOptEscape
= pPart2
->getChild(static_cast<sal_uInt32
>(pPart2
->count()-1)); // Opt Escape Rule
900 const bool bNot
= SQL_ISTOKEN(pPart2
->getChild(0), NOT
);
902 if (!(pAtom
->getNodeType() == SQL_NODE_STRING
||
903 pAtom
->getNodeType() == SQL_NODE_NAME
||
904 SQL_ISRULE(pAtom
,parameter
) ||
905 ( pAtom
->getChild(0) && pAtom
->getChild(0)->getNodeType() == SQL_NODE_NAME
) ||
906 ( pAtom
->getChild(0) && pAtom
->getChild(0)->getNodeType() == SQL_NODE_STRING
)
909 OSL_TRACE("analyseSQL : pAtom->count() = %d", pAtom
->count() );
911 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_LIKE_STRING
, *this );
914 const sal_Unicode WILDCARD
= '%';
915 const sal_Unicode ALT_WILDCARD
= '*';
916 const sal_Unicode MATCHCHAR
= '_';
918 OUString sTableRange
;
919 if(SQL_ISRULE(pColumn
,column_ref
))
920 m_pSQLIterator
->getColumnRange(pColumn
,columnName
,sTableRange
);
922 OSL_TRACE("ColumnName = %s", OUtoCStr( columnName
) );
924 if ( SQL_ISRULE(pAtom
,parameter
) ) {
925 parseParameter( pAtom
, matchString
);
926 // Replace all '*' with '%' : UI Usually does this but not with
927 // Parameters for some reason.
928 matchString
= matchString
.replace( ALT_WILDCARD
, WILDCARD
);
932 matchString
= pAtom
->getTokenValue();
935 // Determine where '%' character is...
937 if ( matchString
.equals( OUString::valueOf( WILDCARD
) ) )
939 // String containing only a '%' and nothing else
940 op
= MQueryOp::Exists
;
941 // Will be ignored for Exists case, but clear anyway.
942 matchString
= OUString("");
944 else if ( matchString
.indexOf ( WILDCARD
) == -1 &&
945 matchString
.indexOf ( MATCHCHAR
) == -1 )
947 // Simple string , eg. "to match"
949 op
= MQueryOp::DoesNotContain
;
951 op
= MQueryOp::Contains
;
953 else if ( matchString
.indexOf ( WILDCARD
) == 0
954 && matchString
.lastIndexOf ( WILDCARD
) == matchString
.getLength() -1
955 && matchString
.indexOf ( WILDCARD
, 1 ) == matchString
.lastIndexOf ( WILDCARD
)
956 && matchString
.indexOf( MATCHCHAR
) == -1
959 // Relatively simple "%string%" - ie, contains...
960 // Cut '%' from front and rear
961 matchString
= matchString
.replaceAt( 0, 1, OUString() );
962 matchString
= matchString
.replaceAt( matchString
.getLength() -1 , 1, OUString() );
965 op
= MQueryOp::DoesNotContain
;
967 op
= MQueryOp::Contains
;
971 // We currently can't handle a 'NOT LIKE' when there are '%' or
972 // '_' dispersed throughout
973 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_NOT_LIKE_TOO_COMPLEX
, *this );
977 if ( (matchString
.indexOf ( WILDCARD
) == matchString
.lastIndexOf ( WILDCARD
))
978 && matchString
.indexOf( MATCHCHAR
) == -1
981 // One occurrence of '%' - no '_' matches...
982 if ( matchString
.indexOf ( WILDCARD
) == 0 )
984 op
= MQueryOp::EndsWith
;
985 matchString
= matchString
.replaceAt( 0, 1, OUString());
987 else if ( matchString
.indexOf ( WILDCARD
) == matchString
.getLength() -1 )
989 op
= MQueryOp::BeginsWith
;
990 matchString
= matchString
.replaceAt( matchString
.getLength() -1 , 1, OUString() );
994 sal_Int32 pos
= matchString
.indexOf ( WILDCARD
);
995 matchString
= matchString
.replaceAt( pos
, 1,OUString(".*") );
996 op
= MQueryOp::RegExp
;
1002 // Most Complex, need to use an RE
1003 sal_Int32 pos
= matchString
.indexOf ( WILDCARD
);
1004 while ( (pos
= matchString
.indexOf ( WILDCARD
)) != -1 )
1006 matchString
= matchString
.replaceAt( pos
, 1, OUString(".*") );
1009 pos
= matchString
.indexOf ( MATCHCHAR
);
1010 while ( (pos
= matchString
.indexOf( MATCHCHAR
)) != -1 )
1012 matchString
= matchString
.replaceAt( pos
, 1, OUString(".") );
1015 op
= MQueryOp::RegExp
;
1019 queryExpression
.getExpressions().push_back( new MQueryExpressionString( columnName
, op
, matchString
));
1021 else if (SQL_ISRULE(parseTree
,test_for_null
))
1023 OSL_ENSURE(parseTree
->count() == 2,"Error in ParseTree");
1024 const OSQLParseNode
* pPart2
= parseTree
->getChild(1);
1025 OSL_ENSURE(SQL_ISTOKEN(pPart2
->getChild(0),IS
),"Error in ParseTree");
1027 if (!SQL_ISRULE(parseTree
->getChild(0),column_ref
))
1029 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_INVALID_IS_NULL_COLUMN
, *this );
1032 if (SQL_ISTOKEN(pPart2
->getChild(1),NOT
))
1034 op
= MQueryOp::Exists
;
1038 op
= MQueryOp::DoesNotExist
;
1041 OUString sTableRange
;
1042 m_pSQLIterator
->getColumnRange(parseTree
->getChild(0),columnName
,sTableRange
);
1044 queryExpression
.getExpressions().push_back( new MQueryExpressionString( columnName
, op
));
1048 OSL_TRACE( "Unexpected statement!!!" );
1050 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX
, *this );
1054 // -----------------------------------------------------------------------------
1056 void OResultSet::fillRowData()
1057 throw( ::com::sun::star::sdbc::SQLException
)
1059 OSL_ENSURE( m_pStatement
, "Require a statement" );
1061 MQueryExpression queryExpression
;
1063 OConnection
* xConnection
= static_cast<OConnection
*>(m_pStatement
->getConnection().get());
1064 m_xColumns
= m_pSQLIterator
->getSelectColumns();
1066 OSL_ENSURE(m_xColumns
.is(), "Need the Columns!!");
1068 OSQLColumns::Vector::const_iterator aIter
= m_xColumns
->get().begin();
1069 const OUString sProprtyName
= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
);
1071 m_aAttributeStrings
.clear();
1072 m_aAttributeStrings
.reserve(m_xColumns
->get().size());
1073 for (sal_Int32 i
= 1; aIter
!= m_xColumns
->get().end();++aIter
, i
++)
1075 (*aIter
)->getPropertyValue(sProprtyName
) >>= sName
;
1076 #if OSL_DEBUG_LEVEL > 0
1077 OSL_TRACE("Query Columns : (%d) %s", i
, OUtoCStr(sName
) );
1079 m_aAttributeStrings
.push_back( sName
);
1082 // Generate Match Conditions for Query
1083 const OSQLParseNode
* pParseTree
= m_pSQLIterator
->getWhereTree();
1085 m_bIsAlwaysFalseQuery
= sal_False
;
1086 if ( pParseTree
!= NULL
)
1088 // Extract required info
1090 OSL_TRACE("\tHave a Where Clause");
1092 analyseWhereClause( pParseTree
, queryExpression
);
1094 // If the query is a 0=1 then set Row count to 0 and return
1095 if ( m_bIsAlwaysFalseQuery
)
1101 m_aQueryHelper
.setExpression( queryExpression
);
1103 OUString
aStr( m_pTable
->getName() );
1104 m_aQueryHelper
.setAddressbook( aStr
);
1106 sal_Int32 rv
= m_aQueryHelper
.executeQuery(xConnection
);
1108 m_pStatement
->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY
, *this );
1111 if (m_aQueryHelper
.hadError())
1113 m_pStatement
->getOwnConnection()->throwSQLException( m_aQueryHelper
.getError(), *this );
1116 //determine whether the address book is readonly
1117 determineReadOnly();
1119 #if OSL_DEBUG_LEVEL > 0
1120 OSL_TRACE( "executeQuery returned %d", rv
);
1122 OSL_TRACE( "\tOUT OResultSet::fillRowData()" );
1126 // -----------------------------------------------------------------------------
1127 static sal_Bool
matchRow( OValueRow
& row1
, OValueRow
& row2
)
1129 OValueVector::Vector::iterator row1Iter
= row1
->get().begin();
1130 OValueVector::Vector::iterator row2Iter
= row2
->get().begin();
1131 for ( ++row1Iter
,++row2Iter
; // the first column is the bookmark column
1132 row1Iter
!= row1
->get().end(); ++row1Iter
,++row2Iter
)
1134 if ( row1Iter
->isBound())
1136 // Compare values, if at anytime there's a mismatch return false
1137 if ( !( (*row1Iter
) == (*row2Iter
) ) )
1142 // If we get to here the rows match
1146 sal_Int32
OResultSet::getRowForCardNumber(sal_Int32 nCardNum
)
1148 OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, nCardNum = %u", nCardNum
);
1150 if ( m_pKeySet
.is() )
1153 for(nPos
=0;nPos
< (sal_Int32
)m_pKeySet
->get().size();nPos
++)
1155 if (nCardNum
== (m_pKeySet
->get())[nPos
])
1157 OSL_TRACE("In/Out: OResultSet::getRowForCardNumber, return = %u", nPos
+1 );
1163 m_pStatement
->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK
, *this );
1168 // -----------------------------------------------------------------------------
1169 void SAL_CALL
OResultSet::executeQuery() throw( ::com::sun::star::sdbc::SQLException
,
1170 ::com::sun::star::uno::RuntimeException
)
1172 ResultSetEntryGuard
aGuard( *this );
1174 OSL_ENSURE( m_pTable
, "Need a Table object");
1177 const OSQLTables
& xTabs
= m_pSQLIterator
->getTables();
1178 if ((xTabs
.begin() == xTabs
.end()) || !xTabs
.begin()->second
.is())
1179 m_pStatement
->getOwnConnection()->throwSQLException( STR_QUERY_TOO_COMPLEX
, *this );
1181 m_pTable
= static_cast< OTable
* > ((xTabs
.begin()->second
).get());
1189 OSL_ENSURE(m_xColumns
.is(), "Need the Columns!!");
1191 switch( m_pSQLIterator
->getStatementType() )
1193 case SQL_STATEMENT_SELECT
:
1195 if(m_bIsAlwaysFalseQuery
) {
1200 m_pStatement
->getOwnConnection()->throwSQLException( STR_NO_COUNT_SUPPORT
, *this );
1204 sal_Bool bDistinct
= sal_False
;
1205 OSQLParseNode
*pDistinct
= m_pParseTree
->getChild(1);
1206 if (pDistinct
&& pDistinct
->getTokenID() == SQL_TOKEN_DISTINCT
)
1210 m_aOrderbyColumnNumber
.push_back(m_aColMapping
[1]);
1211 m_aOrderbyAscending
.push_back(SQL_DESC
);
1213 bDistinct
= sal_True
;
1216 OSortIndex::TKeyTypeVector
eKeyType(m_aOrderbyColumnNumber
.size());
1217 ::std::vector
<sal_Int32
>::iterator aOrderByIter
= m_aOrderbyColumnNumber
.begin();
1218 for ( ::std::vector
<sal_Int16
>::size_type i
= 0; aOrderByIter
!= m_aOrderbyColumnNumber
.end(); ++aOrderByIter
,++i
)
1220 OSL_ENSURE((sal_Int32
)m_aRow
->get().size() > *aOrderByIter
,"Invalid Index");
1221 switch ((m_aRow
->get().begin()+*aOrderByIter
)->getTypeKind())
1223 case DataType::CHAR
:
1224 case DataType::VARCHAR
:
1225 eKeyType
[i
] = SQL_ORDERBYKEY_STRING
;
1228 case DataType::OTHER
:
1229 case DataType::TINYINT
:
1230 case DataType::SMALLINT
:
1231 case DataType::INTEGER
:
1232 case DataType::DECIMAL
:
1233 case DataType::NUMERIC
:
1234 case DataType::REAL
:
1235 case DataType::DOUBLE
:
1236 case DataType::DATE
:
1237 case DataType::TIME
:
1238 case DataType::TIMESTAMP
:
1240 eKeyType
[i
] = SQL_ORDERBYKEY_DOUBLE
;
1243 // Other types aren't implemented (so they are always FALSE)
1245 eKeyType
[i
] = SQL_ORDERBYKEY_NONE
;
1246 OSL_FAIL("MResultSet::executeQuery: Order By Data Type not implemented");
1253 // Implement Sorting
1255 // So that we can sort we need to wait until the executed
1256 // query to the mozilla addressbooks has returned all
1259 OSL_TRACE("Query is to be sorted");
1261 OSL_ENSURE( m_aQueryHelper
.queryComplete(), "Query not complete!!");
1263 m_pSortIndex
= new OSortIndex(eKeyType
,m_aOrderbyAscending
);
1265 OSL_TRACE("OrderbyColumnNumber->size() = %d",m_aOrderbyColumnNumber
.size());
1266 #if OSL_DEBUG_LEVEL > 0
1267 for ( ::std::vector
<sal_Int32
>::size_type i
= 0; i
< m_aColMapping
.size(); i
++ )
1268 OSL_TRACE("Mapped: %d -> %d", i
, m_aColMapping
[i
] );
1270 for ( sal_Int32 nRow
= 1; nRow
<= m_aQueryHelper
.getResultCount(); nRow
++ ) {
1272 OKeyValue
* pKeyValue
= OKeyValue::createKeyValue((nRow
));
1274 ::std::vector
<sal_Int32
>::iterator aIter
= m_aOrderbyColumnNumber
.begin();
1275 for (;aIter
!= m_aOrderbyColumnNumber
.end(); ++aIter
)
1277 const ORowSetValue
& value
= getValue(nRow
, *aIter
);
1279 OSL_TRACE( "Adding Value: (%d,%d) : %s", nRow
, *aIter
,OUtoCStr( value
));
1281 pKeyValue
->pushKey(new ORowSetValueDecorator(value
));
1284 m_pSortIndex
->AddKeyValue( pKeyValue
);
1287 m_pKeySet
= m_pSortIndex
->CreateKeySet();
1288 m_CurrentRowCount
= static_cast<sal_Int32
>(m_pKeySet
->get().size());
1289 #if OSL_DEBUG_LEVEL > 0
1290 for( OKeySet::Vector::size_type i
= 0; i
< m_pKeySet
->get().size(); i
++ )
1291 OSL_TRACE("Sorted: %d -> %d", i
, (m_pKeySet
->get())[i
] );
1294 m_pSortIndex
= NULL
;
1295 beforeFirst(); // Go back to start
1297 else //we always need m_pKeySet now
1298 m_pKeySet
= new OKeySet();
1300 // Handle the DISTINCT case
1301 if ( bDistinct
&& m_pKeySet
.is() )
1303 OValueRow aSearchRow
= new OValueVector( m_aRow
->get().size() );
1305 for( OKeySet::Vector::size_type i
= 0; i
< m_pKeySet
->get().size(); i
++ )
1307 fetchRow( (m_pKeySet
->get())[i
] ); // Fills m_aRow
1308 if ( matchRow( m_aRow
, aSearchRow
) )
1310 (m_pKeySet
->get())[i
] = 0; // Marker for later to be removed
1314 // They don't match, so it's not a duplicate.
1315 // Use the current Row as the next one to match against
1316 *aSearchRow
= *m_aRow
;
1319 // Now remove any keys marked with a 0
1320 m_pKeySet
->get().erase(::std::remove_if(m_pKeySet
->get().begin(),m_pKeySet
->get().end()
1321 ,::std::bind2nd(::std::equal_to
<sal_Int32
>(),0))
1322 ,m_pKeySet
->get().end());
1328 case SQL_STATEMENT_UPDATE
:
1329 case SQL_STATEMENT_DELETE
:
1330 case SQL_STATEMENT_INSERT
:
1333 m_pStatement
->getOwnConnection()->throwSQLException( STR_STMT_TYPE_NOT_SUPPORTED
, *this );
1338 // -----------------------------------------------------------------------------
1341 void OResultSet::setBoundedColumns(const OValueRow
& _rRow
,
1342 const ::rtl::Reference
<connectivity::OSQLColumns
>& _rxColumns
,
1343 const Reference
<XIndexAccess
>& _xNames
,
1344 sal_Bool _bSetColumnMapping
,
1345 const Reference
<XDatabaseMetaData
>& _xMetaData
,
1346 ::std::vector
<sal_Int32
>& _rColMapping
)
1348 ::comphelper::UStringMixEqual
aCase(_xMetaData
->supportsMixedCaseQuotedIdentifiers());
1350 Reference
<XPropertySet
> xTableColumn
;
1351 OUString sTableColumnName
, sSelectColumnRealName
;
1353 const OUString sName
= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_NAME
);
1354 const OUString sRealName
= OMetaConnection::getPropMap().getNameByIndex(PROPERTY_ID_REALNAME
);
1356 ::std::vector
< OUString
> aColumnNames
;
1357 aColumnNames
.reserve(_rxColumns
->get().size());
1358 OValueVector::Vector::iterator aRowIter
= _rRow
->get().begin()+1;
1359 for (sal_Int32 i
=0; // the first column is the bookmark column
1360 aRowIter
!= _rRow
->get().end();
1366 // get the table column and it's name
1367 _xNames
->getByIndex(i
) >>= xTableColumn
;
1368 OSL_ENSURE(xTableColumn
.is(), "OResultSet::setBoundedColumns: invalid table column!");
1369 if (xTableColumn
.is())
1370 xTableColumn
->getPropertyValue(sName
) >>= sTableColumnName
;
1372 sTableColumnName
= OUString();
1374 // look if we have such a select column
1375 // TODO: would like to have a O(log n) search here ...
1376 sal_Int32 nColumnPos
= 0;
1377 for ( OSQLColumns::Vector::iterator aIter
= _rxColumns
->get().begin();
1378 aIter
!= _rxColumns
->get().end();
1379 ++aIter
,++nColumnPos
1382 if ( nColumnPos
< (sal_Int32
)aColumnNames
.size() )
1383 sSelectColumnRealName
= aColumnNames
[nColumnPos
];
1386 if((*aIter
)->getPropertySetInfo()->hasPropertyByName(sRealName
))
1387 (*aIter
)->getPropertyValue(sRealName
) >>= sSelectColumnRealName
;
1389 (*aIter
)->getPropertyValue(sName
) >>= sSelectColumnRealName
;
1390 aColumnNames
.push_back(sSelectColumnRealName
);
1393 if (aCase(sTableColumnName
, sSelectColumnRealName
))
1395 if(_bSetColumnMapping
)
1397 sal_Int32 nSelectColumnPos
= static_cast<sal_Int32
>(aIter
- _rxColumns
->get().begin() + 1);
1398 // the getXXX methods are 1-based ...
1399 sal_Int32 nTableColumnPos
= i
+ 1;
1400 // get first table column is the bookmark column
1402 #if OSL_DEBUG_LEVEL > 0
1403 OSL_TRACE("Set Col Mapping: %d -> %d", nSelectColumnPos
, nTableColumnPos
);
1405 _rColMapping
[nSelectColumnPos
] = nTableColumnPos
;
1408 aRowIter
->setBound(sal_True
);
1409 aRowIter
->setTypeKind(DataType::VARCHAR
);
1415 OSL_FAIL("OResultSet::setBoundedColumns: caught an Exception!");
1421 // -----------------------------------------------------------------------------
1422 sal_Bool
OResultSet::isCount() const
1424 return (m_pParseTree
&&
1425 m_pParseTree
->count() > 2 &&
1426 SQL_ISRULE(m_pParseTree
->getChild(2),scalar_exp_commalist
) &&
1427 SQL_ISRULE(m_pParseTree
->getChild(2)->getChild(0),derived_column
) &&
1428 SQL_ISRULE(m_pParseTree
->getChild(2)->getChild(0)->getChild(0),general_set_fct
) &&
1429 m_pParseTree
->getChild(2)->getChild(0)->getChild(0)->count() == 4
1433 // -----------------------------------------------------------------------------
1435 // Check for valid row in m_aQuery
1437 sal_Bool
OResultSet::validRow( sal_uInt32 nRow
)
1439 sal_Int32 nNumberOfRecords
= m_aQueryHelper
.getResultCount();
1441 while ( nRow
> (sal_uInt32
)nNumberOfRecords
&& !m_aQueryHelper
.queryComplete() ) {
1442 #if OSL_DEBUG_LEVEL > 0
1443 OSL_TRACE("validRow: waiting...");
1445 if (m_aQueryHelper
.checkRowAvailable( nRow
) == sal_False
)
1447 OSL_TRACE("validRow(%u): return False", nRow
);
1451 if ( m_aQueryHelper
.hadError() )
1453 m_pStatement
->getOwnConnection()->throwSQLException( m_aQueryHelper
.getError(), *this );
1456 nNumberOfRecords
= m_aQueryHelper
.getResultCount();
1459 if (( nRow
== 0 ) ||
1460 ( nRow
> (sal_uInt32
)nNumberOfRecords
&& m_aQueryHelper
.queryComplete()) ){
1461 OSL_TRACE("validRow(%u): return False", nRow
);
1464 #if OSL_DEBUG_LEVEL > 0
1465 OSL_TRACE("validRow(%u): return True", nRow
);
1470 sal_Bool
OResultSet::fillKeySet(sal_Int32 nMaxCardNumber
)
1472 impl_ensureKeySet();
1473 if (m_CurrentRowCount
< nMaxCardNumber
)
1475 sal_Int32 nKeyValue
;
1476 if ( (sal_Int32
)m_pKeySet
->get().capacity() < nMaxCardNumber
)
1477 m_pKeySet
->get().reserve(nMaxCardNumber
+ 20 );
1479 for (nKeyValue
= m_CurrentRowCount
+1; nKeyValue
<= nMaxCardNumber
; nKeyValue
++)
1480 m_pKeySet
->get().push_back( nKeyValue
);
1481 m_CurrentRowCount
= nMaxCardNumber
;
1486 sal_Int32
OResultSet::deletedCount()
1488 impl_ensureKeySet();
1489 return m_CurrentRowCount
- static_cast<sal_Int32
>(m_pKeySet
->get().size());
1492 // -----------------------------------------------------------------------------
1493 sal_Bool
OResultSet::seekRow( eRowPosition pos
, sal_Int32 nOffset
)
1495 SAL_INFO("connectivity.mork", "=> OResultSet::seekRow()" );
1497 ResultSetEntryGuard
aGuard( *this );
1498 if ( !m_pKeySet
.is() )
1499 m_pStatement
->getOwnConnection()->throwSQLException( STR_ILLEGAL_MOVEMENT
, *this );
1501 sal_Int32 nNumberOfRecords
= m_aQueryHelper
.getResultCount();
1502 sal_Int32 nRetrivedRows
= currentRowCount();
1503 sal_Int32 nCurPos
= m_nRowPos
;
1505 OSL_TRACE("seekRow: nCurPos = %d", nCurPos
);
1508 OSL_TRACE("seekRow: NEXT");
1512 OSL_TRACE("seekRow: PRIOR");
1518 OSL_TRACE("seekRow: FIRST");
1523 OSL_TRACE("seekRow: LAST");
1524 nCurPos
= nRetrivedRows
;
1527 OSL_TRACE("seekRow: ABSOLUTE : %d", nOffset
);
1531 OSL_TRACE("seekRow: RELATIVE : %d", nOffset
);
1532 nCurPos
+= sal_uInt32( nOffset
);
1536 if ( nCurPos
<= 0 ) {
1538 OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos
);
1541 sal_Int32 nCurCard
= nCurPos
;
1542 if ( nCurPos
< (sal_Int32
)m_pKeySet
->get().size() ) //The requested row is exist in m_pKeySet, so we just use it
1544 nCurCard
= (m_pKeySet
->get())[nCurPos
-1];
1546 else //The requested row has not been retrived until now. We should get the right card for it.
1547 nCurCard
= nCurPos
+ deletedCount();
1549 if ( nCurCard
> nNumberOfRecords
) {
1550 fillKeySet(nNumberOfRecords
);
1551 m_nRowPos
= static_cast<sal_uInt32
>(m_pKeySet
->get().size() + 1);
1552 OSL_TRACE("seekRow: return False, m_nRowPos = %u", m_nRowPos
);
1555 //Insert new retrived items for later use
1556 fillKeySet(nNumberOfRecords
);
1557 m_nRowPos
= (sal_uInt32
)nCurPos
;
1558 OSL_TRACE("seekRow: return True, m_nRowPos = %u", m_nRowPos
);
1562 // -----------------------------------------------------------------------------
1563 void OResultSet::setColumnMapping(const ::std::vector
<sal_Int32
>& _aColumnMapping
)
1565 m_aColMapping
= _aColumnMapping
;
1566 #if OSL_DEBUG_LEVEL > 0
1567 for ( sal_uInt32 i
= 0; i
< m_aColMapping
.size(); i
++ )
1568 OSL_TRACE("Set Mapped: %d -> %d", i
, m_aColMapping
[i
] );
1571 // -----------------------------------------------------------------------------
1573 ::com::sun::star::uno::Any
OResultSet::getBookmark( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1575 OSL_TRACE("getBookmark, m_nRowPos = %u", m_nRowPos
);
1576 ResultSetEntryGuard
aGuard( *this );
1577 if ( fetchCurrentRow() == sal_False
) {
1578 m_pStatement
->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW
, *this );
1581 OSL_ENSURE((!m_aRow
->isDeleted()),"getBookmark called for deleted row");
1582 return makeAny((sal_Int32
)(m_aRow
->get())[0]);
1584 sal_Bool
OResultSet::moveToBookmark( const ::com::sun::star::uno::Any
& bookmark
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1586 ResultSetEntryGuard
aGuard( *this );
1587 OSL_TRACE("moveToBookmark, bookmark = %u", comphelper::getINT32(bookmark
) );
1588 sal_Int32 nCardNum
= comphelper::getINT32(bookmark
);
1589 m_nRowPos
= getRowForCardNumber(nCardNum
);
1593 sal_Bool
OResultSet::moveRelativeToBookmark( const ::com::sun::star::uno::Any
& bookmark
, sal_Int32 rows
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1595 ResultSetEntryGuard
aGuard( *this );
1596 OSL_TRACE("moveRelativeToBookmark, bookmark = %u rows= %u", comphelper::getINT32(bookmark
),rows
);
1597 sal_Int32 nCardNum
= comphelper::getINT32(bookmark
);
1598 m_nRowPos
= getRowForCardNumber(nCardNum
);
1599 return seekRow(RELATIVE_POS
,rows
);
1601 sal_Int32
OResultSet::compareBookmarks( const ::com::sun::star::uno::Any
& lhs
, const ::com::sun::star::uno::Any
& rhs
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1603 ResultSetEntryGuard
aGuard( *this );
1604 OSL_TRACE("compareBookmarks, m_nRowPos = %u", m_nRowPos
);
1606 sal_Int32 nSecond
=0;
1607 sal_Int32 nResult
=0;
1609 if ( !( lhs
>>= nFirst
) || !( rhs
>>= nSecond
) ) {
1610 m_pStatement
->getOwnConnection()->throwSQLException( STR_INVALID_BOOKMARK
, *this );
1613 if(nFirst
< nSecond
)
1615 else if(nFirst
> nSecond
)
1622 sal_Bool
OResultSet::hasOrderedBookmarks( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1624 ResultSetEntryGuard
aGuard( *this );
1625 OSL_TRACE("hasOrderedBookmarks, m_nRowPos = %u", m_nRowPos
);
1628 sal_Int32
OResultSet::hashBookmark( const ::com::sun::star::uno::Any
& bookmark
) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1630 ResultSetEntryGuard
aGuard( *this );
1631 OSL_TRACE("hashBookmark, m_nRowPos = %u", m_nRowPos
);
1632 return comphelper::getINT32(bookmark
);
1635 sal_Int32
OResultSet::getCurrentCardNumber()
1637 if ( ( m_nRowPos
== 0 ) || !m_pKeySet
.is() )
1639 if (m_pKeySet
->get().size() < m_nRowPos
)
1641 return (m_pKeySet
->get())[m_nRowPos
-1];
1643 void OResultSet::checkPendingUpdate() throw(SQLException
, RuntimeException
)
1645 OSL_FAIL( "OResultSet::checkPendingUpdate() not implemented" );
1647 OSL_TRACE("checkPendingUpdate, m_nRowPos = %u", m_nRowPos );
1648 const sal_Int32 nCurrentRow = getCurrentCardNumber();
1650 if ((m_nNewRow && nCurrentRow != m_nNewRow)
1651 || ( m_nUpdatedRow && m_nUpdatedRow != nCurrentRow))
1653 const OUString sError( m_pStatement->getOwnConnection()->getResources().getResourceStringWithSubstitution(
1655 "$position$", OUString::valueOf(nCurrentRow)
1657 ::dbtools::throwGenericSQLException(sError,*this);
1662 void OResultSet::updateValue(sal_Int32 columnIndex
,const ORowSetValue
& x
) throw(SQLException
, RuntimeException
)
1664 OSL_TRACE("updateValue, m_nRowPos = %u", m_nRowPos
);
1665 ResultSetEntryGuard
aGuard( *this );
1666 if ( fetchCurrentRow() == sal_False
) {
1667 m_pStatement
->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW
, *this );
1670 checkPendingUpdate();
1672 checkIndex(columnIndex
);
1673 columnIndex
= mapColumn(columnIndex
);
1675 (m_aRow
->get())[columnIndex
].setBound(sal_True
);
1676 (m_aRow
->get())[columnIndex
] = x
;
1677 m_nUpdatedRow
= getCurrentCardNumber();
1678 // m_RowStates = m_RowStates | RowStates_Updated;
1680 // -----------------------------------------------------------------------------
1682 void SAL_CALL
OResultSet::updateNull( sal_Int32 columnIndex
) throw(SQLException
, RuntimeException
)
1684 OSL_TRACE("updateNull, m_nRowPos = %u", m_nRowPos
);
1685 ResultSetEntryGuard
aGuard( *this );
1686 if ( fetchCurrentRow() == sal_False
)
1687 m_pStatement
->getOwnConnection()->throwSQLException( STR_ERROR_GET_ROW
, *this );
1689 checkPendingUpdate();
1690 checkIndex(columnIndex
);
1691 columnIndex
= mapColumn(columnIndex
);
1693 (m_aRow
->get())[columnIndex
].setBound(sal_True
);
1694 (m_aRow
->get())[columnIndex
].setNull();
1695 m_nUpdatedRow
= getCurrentCardNumber();
1696 // m_RowStates = m_RowStates | RowStates_Updated;
1698 // -------------------------------------------------------------------------
1700 void SAL_CALL
OResultSet::updateBoolean( sal_Int32 columnIndex
, sal_Bool x
) throw(SQLException
, RuntimeException
)
1702 updateValue(columnIndex
, static_cast<bool>(x
));
1704 // -------------------------------------------------------------------------
1705 void SAL_CALL
OResultSet::updateByte( sal_Int32 columnIndex
, sal_Int8 x
) throw(SQLException
, RuntimeException
)
1707 updateValue(columnIndex
,x
);
1709 // -------------------------------------------------------------------------
1711 void SAL_CALL
OResultSet::updateShort( sal_Int32 columnIndex
, sal_Int16 x
) throw(SQLException
, RuntimeException
)
1713 updateValue(columnIndex
,x
);
1715 // -------------------------------------------------------------------------
1716 void SAL_CALL
OResultSet::updateInt( sal_Int32 columnIndex
, sal_Int32 x
) throw(SQLException
, RuntimeException
)
1718 updateValue(columnIndex
,x
);
1720 // -------------------------------------------------------------------------
1721 void SAL_CALL
OResultSet::updateLong( sal_Int32
/*columnIndex*/, sal_Int64
/*x*/ ) throw(SQLException
, RuntimeException
)
1723 ::dbtools::throwFeatureNotImplementedException( "XRowUpdate::updateLong", *this );
1725 // -----------------------------------------------------------------------
1726 void SAL_CALL
OResultSet::updateFloat( sal_Int32 columnIndex
, float x
) throw(SQLException
, RuntimeException
)
1728 updateValue(columnIndex
,x
);
1730 // -------------------------------------------------------------------------
1732 void SAL_CALL
OResultSet::updateDouble( sal_Int32 columnIndex
, double x
) throw(SQLException
, RuntimeException
)
1734 updateValue(columnIndex
,x
);
1736 // -------------------------------------------------------------------------
1737 void SAL_CALL
OResultSet::updateString( sal_Int32 columnIndex
, const OUString
& x
) throw(SQLException
, RuntimeException
)
1739 updateValue(columnIndex
,x
);
1741 // -------------------------------------------------------------------------
1742 void SAL_CALL
OResultSet::updateBytes( sal_Int32 columnIndex
, const Sequence
< sal_Int8
>& x
) throw(SQLException
, RuntimeException
)
1744 updateValue(columnIndex
,x
);
1746 // -------------------------------------------------------------------------
1747 void SAL_CALL
OResultSet::updateDate( sal_Int32 columnIndex
, const ::com::sun::star::util::Date
& x
) throw(SQLException
, RuntimeException
)
1749 updateValue(columnIndex
,x
);
1751 // -------------------------------------------------------------------------
1753 void SAL_CALL
OResultSet::updateTime( sal_Int32 columnIndex
, const ::com::sun::star::util::Time
& x
) throw(SQLException
, RuntimeException
)
1755 updateValue(columnIndex
,x
);
1757 // -------------------------------------------------------------------------
1759 void SAL_CALL
OResultSet::updateTimestamp( sal_Int32 columnIndex
, const ::com::sun::star::util::DateTime
& x
) throw(SQLException
, RuntimeException
)
1761 updateValue(columnIndex
,x
);
1763 // -------------------------------------------------------------------------
1765 void SAL_CALL
OResultSet::updateBinaryStream( sal_Int32 columnIndex
, const Reference
< ::com::sun::star::io::XInputStream
>& x
, sal_Int32 length
) throw(SQLException
, RuntimeException
)
1767 ResultSetEntryGuard
aGuard( *this );
1770 ::dbtools::throwFunctionSequenceException(*this);
1772 Sequence
<sal_Int8
> aSeq
;
1773 x
->readBytes(aSeq
,length
);
1774 updateValue(columnIndex
,aSeq
);
1776 // -------------------------------------------------------------------------
1777 void SAL_CALL
OResultSet::updateCharacterStream( sal_Int32 columnIndex
, const Reference
< ::com::sun::star::io::XInputStream
>& x
, sal_Int32 length
) throw(SQLException
, RuntimeException
)
1779 updateBinaryStream(columnIndex
,x
,length
);
1781 // -------------------------------------------------------------------------
1782 void SAL_CALL
OResultSet::updateObject( sal_Int32 columnIndex
, const Any
& x
) throw(SQLException
, RuntimeException
)
1784 if (!::dbtools::implUpdateObject(this, columnIndex
, x
))
1786 const OUString
sError( m_pStatement
->getOwnConnection()->getResources().getResourceStringWithSubstitution(
1787 STR_COLUMN_NOT_UPDATEABLE
,
1788 "$position$", OUString::valueOf(columnIndex
)
1790 ::dbtools::throwGenericSQLException(sError
,*this);
1791 } // if (!::dbtools::implUpdateObject(this, columnIndex, x))
1793 // -------------------------------------------------------------------------
1795 void SAL_CALL
OResultSet::updateNumericObject( sal_Int32 columnIndex
, const Any
& x
, sal_Int32
/*scale*/ ) throw(SQLException
, RuntimeException
)
1797 if (!::dbtools::implUpdateObject(this, columnIndex
, x
))
1799 const OUString
sError( m_pStatement
->getOwnConnection()->getResources().getResourceStringWithSubstitution(
1800 STR_COLUMN_NOT_UPDATEABLE
,
1801 "$position$", OUString::valueOf(columnIndex
)
1803 ::dbtools::throwGenericSQLException(sError
,*this);
1808 // -------------------------------------------------------------------------
1809 void SAL_CALL
OResultSet::insertRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1811 ResultSetEntryGuard
aGuard( *this );
1812 OSL_TRACE("insertRow in, m_nRowPos = %u", m_nRowPos
);
1813 // m_RowStates = RowStates_Inserted;
1817 //m_aQueryHelper.setRowStates(getCurrentCardNumber(),m_RowStates);
1818 OSL_TRACE("insertRow out, m_nRowPos = %u", m_nRowPos
);
1820 // -------------------------------------------------------------------------
1821 void SAL_CALL
OResultSet::updateRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1823 OSL_FAIL( "OResultSet::updateRow( ) not implemented" );
1825 // -------------------------------------------------------------------------
1826 void SAL_CALL
OResultSet::deleteRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1828 OSL_FAIL( "OResultSet::deleteRow( ) not implemented" );
1830 // -------------------------------------------------------------------------
1831 void SAL_CALL
OResultSet::cancelRowUpdates( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1833 OSL_FAIL( "OResultSet::cancelRowUpdates( ) not implemented" );
1835 // -------------------------------------------------------------------------
1836 void SAL_CALL
OResultSet::moveToInsertRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1838 OSL_FAIL( "OResultSet::moveToInsertRow( ) not implemented" );
1840 // -------------------------------------------------------------------------
1841 void SAL_CALL
OResultSet::moveToCurrentRow( ) throw(::com::sun::star::sdbc::SQLException
, ::com::sun::star::uno::RuntimeException
)
1843 ResultSetEntryGuard
aGuard( *this );
1844 OSL_TRACE("moveToCurrentRow, m_nRowPos = %u", m_nRowPos
);
1847 m_nRowPos
= m_nOldRowPos
;
1852 sal_Bool
OResultSet::determineReadOnly()
1854 // OSL_FAIL( "OResultSet::determineReadOnly( ) not implemented" );
1856 if (m_bIsReadOnly
== -1)
1858 m_bIsReadOnly
= sal_True
;
1859 // OConnection* xConnection = static_cast<OConnection*>(m_pStatement->getConnection().get());
1860 // m_bIsReadOnly = !m_aQueryHelper.isWritable(xConnection) || m_bIsAlwaysFalseQuery;
1863 return m_bIsReadOnly
!= 0;
1866 void OResultSet::setTable(OTable
* _rTable
)
1868 OSL_TRACE("In : setTable");
1870 m_pTable
->acquire();
1871 m_xTableColumns
= m_pTable
->getColumns();
1872 if(m_xTableColumns
.is())
1873 m_aColumnNames
= m_xTableColumns
->getElementNames();
1874 OSL_TRACE("Out : setTable");
1877 void OResultSet::setOrderByColumns(const ::std::vector
<sal_Int32
>& _aColumnOrderBy
)
1879 m_aOrderbyColumnNumber
= _aColumnOrderBy
;
1882 void OResultSet::setOrderByAscending(const ::std::vector
<TAscendingOrder
>& _aOrderbyAsc
)
1884 m_aOrderbyAscending
= _aOrderbyAsc
;
1886 Sequence
< sal_Int32
> SAL_CALL
OResultSet::deleteRows( const Sequence
< Any
>& /*rows*/ ) throw(SQLException
, RuntimeException
)
1888 ::dbtools::throwFeatureNotImplementedException( "XDeleteRows::deleteRows", *this );
1889 return Sequence
< sal_Int32
>();
1892 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */