mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
[SF 2593784] SVN trunk RowIterator
This commit is contained in:
@@ -3036,6 +3036,13 @@ void SQLExecutor::rowIterator()
|
|||||||
v.push_back(Tuple<int, double, std::string>(3, 3.5f, "5"));
|
v.push_back(Tuple<int, double, std::string>(3, 3.5f, "5"));
|
||||||
v.push_back(Tuple<int, double, std::string>(4, 4.5f, "6"));
|
v.push_back(Tuple<int, double, std::string>(4, 4.5f, "6"));
|
||||||
|
|
||||||
|
try { session() << "DELETE FROM Vectors", now; }
|
||||||
|
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
|
||||||
|
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
|
||||||
|
|
||||||
|
RecordSet rset0(session(), "SELECT * FROM Vectors");
|
||||||
|
assert (rset0.begin() == rset0.end());
|
||||||
|
|
||||||
try { session() << "INSERT INTO Vectors VALUES (?,?,?)", use(v), now; }
|
try { session() << "INSERT INTO Vectors VALUES (?,?,?)", use(v), now; }
|
||||||
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
|
catch(ConnectionException& ce){ std::cout << ce.toString() << std::endl; fail (funct); }
|
||||||
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
|
catch(StatementException& se){ std::cout << se.toString() << std::endl; fail (funct); }
|
||||||
@@ -3058,7 +3065,7 @@ void SQLExecutor::rowIterator()
|
|||||||
|
|
||||||
RowFilter::Ptr pRF = new RowFilter(&rset);
|
RowFilter::Ptr pRF = new RowFilter(&rset);
|
||||||
assert (pRF->isEmpty());
|
assert (pRF->isEmpty());
|
||||||
pRF->add("str0", RowFilter::VALUE_EQUAL, 1);
|
pRF->add("str0", RowFilter::VALUE_EQUAL, "3");
|
||||||
assert (!pRF->isEmpty());
|
assert (!pRF->isEmpty());
|
||||||
it = rset.begin();
|
it = rset.begin();
|
||||||
end = rset.end();
|
end = rset.end();
|
||||||
@@ -3067,7 +3074,6 @@ void SQLExecutor::rowIterator()
|
|||||||
assert (it->get(0) == i);
|
assert (it->get(0) == i);
|
||||||
assert (1 == i);
|
assert (1 == i);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -450,8 +450,7 @@ inline Data_API std::ostream& operator << (std::ostream &os, const RecordSet& rs
|
|||||||
|
|
||||||
inline std::size_t RecordSet::totalRowCount() const
|
inline std::size_t RecordSet::totalRowCount() const
|
||||||
{
|
{
|
||||||
poco_assert (extractions().size());
|
return rowsExtracted();
|
||||||
return extractions()[0].get()->numOfRowsHandled();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -369,6 +369,10 @@ public:
|
|||||||
const std::string& getStorage() const;
|
const std::string& getStorage() const;
|
||||||
/// Returns the internal storage type for the stamement.
|
/// Returns the internal storage type for the stamement.
|
||||||
|
|
||||||
|
std::size_t rowsExtracted(int dataSet = -1) const;
|
||||||
|
/// Returns the number of rows returned for current data set.
|
||||||
|
/// Default value (-1) indicates current data set (if any).
|
||||||
|
|
||||||
std::size_t extractionCount() const;
|
std::size_t extractionCount() const;
|
||||||
/// Returns the number of extraction storage buffers associated
|
/// Returns the number of extraction storage buffers associated
|
||||||
/// with the current data set.
|
/// with the current data set.
|
||||||
@@ -701,6 +705,12 @@ inline std::size_t Statement::extractionCount() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
inline std::size_t Statement::rowsExtracted(int dataSet) const
|
||||||
|
{
|
||||||
|
return _pImpl->rowsExtracted(dataSet);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t Statement::dataSetCount() const
|
inline std::size_t Statement::dataSetCount() const
|
||||||
{
|
{
|
||||||
return _pImpl->dataSetCount();
|
return _pImpl->dataSetCount();
|
||||||
|
@@ -218,9 +218,13 @@ protected:
|
|||||||
virtual AbstractBinder& binder() = 0;
|
virtual AbstractBinder& binder() = 0;
|
||||||
/// Returns the concrete binder used by the statement.
|
/// Returns the concrete binder used by the statement.
|
||||||
|
|
||||||
int columnsExtracted() const;
|
std::size_t columnsExtracted() const;
|
||||||
/// Returns the number of columns that the extractors handle.
|
/// Returns the number of columns that the extractors handle.
|
||||||
|
|
||||||
|
std::size_t rowsExtracted(int dataSet = -1) const;
|
||||||
|
/// Returns the number of rows returned for current data set.
|
||||||
|
/// Default value (-1) indicates current data set (if any).
|
||||||
|
|
||||||
const AbstractBindingVec& bindings() const;
|
const AbstractBindingVec& bindings() const;
|
||||||
/// Returns the bindings.
|
/// Returns the bindings.
|
||||||
|
|
||||||
@@ -486,7 +490,7 @@ inline AbstractExtractionVec& StatementImpl::extractions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int StatementImpl::columnsExtracted() const
|
inline std::size_t StatementImpl::columnsExtracted() const
|
||||||
{
|
{
|
||||||
poco_assert (_curDataSet < _columnsExtracted.size());
|
poco_assert (_curDataSet < _columnsExtracted.size());
|
||||||
return _columnsExtracted[_curDataSet];
|
return _columnsExtracted[_curDataSet];
|
||||||
|
@@ -54,7 +54,7 @@ namespace Data {
|
|||||||
RecordSet::RecordSet(const Statement& rStatement):
|
RecordSet::RecordSet(const Statement& rStatement):
|
||||||
Statement(rStatement),
|
Statement(rStatement),
|
||||||
_currentRow(0),
|
_currentRow(0),
|
||||||
_pBegin(new RowIterator(this, 0 == extractionCount())),
|
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
|
||||||
_pEnd(new RowIterator(this, true)),
|
_pEnd(new RowIterator(this, true)),
|
||||||
_pFilter(0)
|
_pFilter(0)
|
||||||
{
|
{
|
||||||
@@ -66,7 +66,7 @@ RecordSet::RecordSet(Session& rSession,
|
|||||||
RowFormatter* pRowFormatter):
|
RowFormatter* pRowFormatter):
|
||||||
Statement((rSession << query, now)),
|
Statement((rSession << query, now)),
|
||||||
_currentRow(0),
|
_currentRow(0),
|
||||||
_pBegin(new RowIterator(this, 0 == extractionCount())),
|
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
|
||||||
_pEnd(new RowIterator(this, true)),
|
_pEnd(new RowIterator(this, true)),
|
||||||
_pFilter(0)
|
_pFilter(0)
|
||||||
{
|
{
|
||||||
@@ -77,7 +77,7 @@ RecordSet::RecordSet(Session& rSession,
|
|||||||
RecordSet::RecordSet(const RecordSet& other):
|
RecordSet::RecordSet(const RecordSet& other):
|
||||||
Statement(other.impl().duplicate()),
|
Statement(other.impl().duplicate()),
|
||||||
_currentRow(other._currentRow),
|
_currentRow(other._currentRow),
|
||||||
_pBegin(new RowIterator(this, 0 == extractionCount())),
|
_pBegin(new RowIterator(this, 0 == rowsExtracted())),
|
||||||
_pEnd(new RowIterator(this, true)),
|
_pEnd(new RowIterator(this, true)),
|
||||||
_pFilter(other._pFilter)
|
_pFilter(other._pFilter)
|
||||||
{
|
{
|
||||||
@@ -161,7 +161,8 @@ Poco::Dynamic::Var RecordSet::value(const std::string& name, std::size_t row, bo
|
|||||||
|
|
||||||
Row& RecordSet::row(std::size_t pos)
|
Row& RecordSet::row(std::size_t pos)
|
||||||
{
|
{
|
||||||
if (pos > rowCount() - 1)
|
std::size_t rowCnt = rowCount();
|
||||||
|
if (0 == rowCnt || pos > rowCnt - 1)
|
||||||
throw RangeException("Invalid recordset row requested.");
|
throw RangeException("Invalid recordset row requested.");
|
||||||
|
|
||||||
RowMap::const_iterator it = _rowMap.find(pos);
|
RowMap::const_iterator it = _rowMap.find(pos);
|
||||||
|
@@ -394,6 +394,20 @@ void StatementImpl::removeBind(const std::string& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::size_t StatementImpl::rowsExtracted(int dataSet) const
|
||||||
|
{
|
||||||
|
if (-1 == dataSet) dataSet = _curDataSet;
|
||||||
|
if (extractions().size() > 0)
|
||||||
|
{
|
||||||
|
poco_assert (dataSet >= 0);
|
||||||
|
if (_extractors[dataSet].size() > 0)
|
||||||
|
return _extractors[dataSet][0]->numOfRowsHandled();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::formatSQL(std::vector<Any>& arguments)
|
void StatementImpl::formatSQL(std::vector<Any>& arguments)
|
||||||
{
|
{
|
||||||
std::string sql;
|
std::string sql;
|
||||||
|
Reference in New Issue
Block a user