std::size_t TestStatementImpl::next()
{
	Poco::Data::AbstractExtractionVec::iterator it    = extractions().begin();
	Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
	std::size_t pos = 0; 
	for (; it != itEnd; ++it)
	{
		(*it)->extract(pos);
		pos += (*it)->numOfColumnsHandled();
	}

	return 1u;
}
コード例 #2
0
std::size_t SQLiteStatementImpl::next()
{
	if (SQLITE_ROW == _nextResponse)
	{
		poco_assert (columnsReturned() == sqlite3_column_count(_pStmt));

		Extractions& extracts = extractions();
		Extractions::iterator it    = extracts.begin();
		Extractions::iterator itEnd = extracts.end();
		std::size_t pos = 0; // sqlite starts with pos 0 for results!
		for (; it != itEnd; ++it)
		{
			(*it)->extract(pos);
			pos += (*it)->numOfColumnsHandled();
			_isExtracted = true;
		}
		_stepCalled = false;
		if (_affectedRowCount == POCO_SQLITE_INV_ROW_CNT) _affectedRowCount = 0;
		if (extracts.begin() != extracts.end())
		{
			_affectedRowCount += static_cast<int>((*extracts.begin())->numOfRowsHandled());
		}
	}
	else if (SQLITE_DONE == _nextResponse)
	{
		throw Poco::Data::DataException("No data received");
	}
	else
	{
		Utility::throwException(_pDB, _nextResponse, std::string("Iterator Error: trying to access the next value"));
	}
	
	return 1u;
}
コード例 #3
0
Poco::UInt32 ODBCStatementImpl::next()
{
	std::size_t count = 0;

	if (nextRowReady())
	{
		Extractions& extracts = extractions();
		Extractions::iterator it    = extracts.begin();
		Extractions::iterator itEnd = extracts.end();
		std::size_t prevCount = 0;
		for (std::size_t pos = 0; it != itEnd; ++it)
		{
			count = (*it)->extract(pos);
			if (prevCount && count != prevCount)
				throw IllegalStateException("Different extraction counts");
			prevCount = count;
			pos += (*it)->numOfColumnsHandled();
		}
		_stepCalled = false;
	}
	else
	{
		throw StatementException(_stmt,
			std::string("Iterator Error: trying to access the next value"));
	}

	return static_cast<Poco::UInt32>(count);

	return 0;
}
コード例 #4
0
bool ODBCStatementImpl::hasNext()
{
	if (hasData())
	{
		if (!extractions().size()) 
			makeInternalExtractors();

		if (!_prepared) doPrepare();

		if (_stepCalled) 
			return _stepCalled = nextRowReady();

		makeStep();

		if (!nextRowReady())
		{
			if (hasMoreDataSets()) activateNextDataSet();
			else return false;	

			if (SQL_NO_DATA == SQLMoreResults(_stmt)) 
				return false;

			addPreparation();
			doPrepare();
			fixupExtraction();
			makeStep();
		}
		else if (Utility::isError(_nextResponse))
			checkError(_nextResponse, "SQLFetch()");

		return true;
	}

	return false;
}
コード例 #5
0
void ODBCStatementImpl::doPrepare()
{
	if (session().getFeature("autoExtract") && hasData())
	{
		Poco::UInt32 curDataSet = currentDataSet();
		poco_check_ptr (_preparations[curDataSet]);

		Extractions& extracts = extractions();
		Extractions::iterator it    = extracts.begin();
		Extractions::iterator itEnd = extracts.end();

		if (it != itEnd && (*it)->isBulk())
		{
			Poco::UInt32 limit = getExtractionLimit();
			if (limit == Limit::LIMIT_UNLIMITED) 
				throw InvalidArgumentException("Bulk operation not allowed without limit.");
			checkError(SQLSetStmtAttr(_stmt, SQL_ATTR_ROW_ARRAY_SIZE, (SQLPOINTER) limit, 0),
					"SQLSetStmtAttr(SQL_ATTR_ROW_ARRAY_SIZE)");
		}

		for (std::size_t pos = 0; it != itEnd; ++it)
		{
			AbstractPrepare* pAP = (*it)->createPrepareObject(_preparations[curDataSet], pos);
			pAP->prepare();
			pos += (*it)->numOfColumnsHandled();
			delete pAP;
		}

		_prepared = true;
	}
}
コード例 #6
0
void SQLiteStatementImpl::next()
{
	if (SQLITE_ROW == _nextResponse)
	{
		poco_assert (columnsReturned() == sqlite3_column_count(_pStmt));

		Extractions& extracts = extractions();
		Extractions::iterator it    = extracts.begin();
		Extractions::iterator itEnd = extracts.end();
		std::size_t pos = 0; // sqlite starts with pos 0 for results!
		for (; it != itEnd; ++it)
		{
			(*it)->extract(pos);
			pos += (*it)->numOfColumnsHandled();
		}
		_stepCalled = false;
	}
	else if (SQLITE_DONE == _nextResponse)
	{
		throw Poco::Data::DataException("No data received");
	}
	else
	{
		int rc = _nextResponse;
		Utility::throwException(rc, std::string("Iterator Error: trying to access the next value: ") + toString());
	}
}
std::size_t MySQLStatementImpl::next()
{
	if (!hasNext())
		throw StatementException("No data received");	

	Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
	Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
	std::size_t pos = 0;

	for (; it != itEnd; ++it)
	{
		(*it)->extract(pos);
		pos += (*it)->numOfColumnsHandled();
	}

	_hasNext = NEXT_DONTKNOW;
	return 1;
}
コード例 #8
0
ファイル: RecordSet.cpp プロジェクト: RobertAcksel/poco
std::size_t RecordSet::rowCount() const
{
	poco_assert (extractions().size());
	std::size_t rc = subTotalRowCount();
	if (!isFiltered()) return rc;

	std::size_t counter = 0;
	for (int row = 0; row < rc; ++row)
	{
		if (isAllowed(row)) ++counter;
	}

	return counter;
}
コード例 #9
0
void ODBCStatementImpl::makeInternalExtractors()
{
	if (hasData() && !extractions().size()) 
	{
		try
		{
			fillColumns();
		} catch (DataFormatException&)
		{
			if (isStoredProcedure()) return;
			throw;
		}
		
		makeExtractors(columnsReturned());
		fixupExtraction();
	}
}