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;
}
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());
	}
}
Esempio n. 3
0
void ODBCStatementImpl::fillColumns()
{
	Poco::UInt32 colCount = columnsReturned();
	Poco::UInt32 curDataSet = currentDataSet();
	if (curDataSet >= _columnPtrs.size())
		_columnPtrs.resize(curDataSet + 1);

	for (int i = 0; i < colCount; ++i)
		_columnPtrs[curDataSet].push_back(new ODBCMetaColumn(_stmt, i));
}
Esempio n. 4
0
void ODBCStatementImpl::makeInternalExtractors()
{
	if (hasData() && !extractions().size()) 
	{
		try
		{
			fillColumns();
		} catch (DataFormatException&)
		{
			if (isStoredProcedure()) return;
			throw;
		}
		
		makeExtractors(columnsReturned());
		fixupExtraction();
	}
}