null bindings and RecordSet::isNull (SQLite done and tested, ODBC todo)

This commit is contained in:
Aleksandar Fabijanic
2007-06-19 23:24:16 +00:00
parent 6a5afde278
commit 7fac905b65
21 changed files with 402 additions and 44 deletions

View File

@@ -110,6 +110,12 @@ void Binder::bind(std::size_t pos, const DateTime& val, Direction dir)
}
void Binder::bind(std::size_t pos, const NullData&, Direction)
{
sqlite3_bind_null(_pStmt, pos);
}
void Binder::checkReturn(int rc)
{
if (rc != SQLITE_OK)

View File

@@ -313,7 +313,16 @@ bool Extractor::extract(std::size_t pos, Poco::Any& val)
bool Extractor::isNull(std::size_t pos)
{
return sqlite3_column_type(_pStmt, (int) pos) == SQLITE_NULL;
if (pos >= _nulls.size())
_nulls.resize(pos + 1);
if (!_nulls[pos].first)
{
_nulls[pos].first = true;
_nulls[pos].second = (SQLITE_NULL == sqlite3_column_type(_pStmt, pos));
}
return _nulls[pos].second;
}

View File

@@ -185,6 +185,8 @@ bool SQLiteStatementImpl::hasNext()
_stepCalled = true;
_nextResponse = sqlite3_step(_pStmt);
_pExtractor->reset();//to clear the cached null indicators
if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE)
{
Utility::throwException(_nextResponse);