mirror of
https://github.com/allankoechke/SQLiteCpp.git
synced 2026-12-02 01:11:35 +00:00
Add option to check if column is null by name
This commit is contained in:
@@ -336,13 +336,35 @@ Column Statement::getColumn(const char* apName)
|
||||
}
|
||||
|
||||
// Test if the column is NULL
|
||||
bool Statement::isColumnNull(const int aIndex) const
|
||||
bool Statement::isColumnNull(const int aIndex)
|
||||
{
|
||||
checkRow();
|
||||
checkIndex(aIndex);
|
||||
return (SQLITE_NULL == sqlite3_column_type(mStmtPtr, aIndex));
|
||||
}
|
||||
|
||||
bool Statement::isColumnNull(const char* apName)
|
||||
{
|
||||
checkRow();
|
||||
|
||||
if (mColumnNames.empty())
|
||||
{
|
||||
for (int i = 0; i < mColumnCount; ++i)
|
||||
{
|
||||
const char* pName = sqlite3_column_name(mStmtPtr, i);
|
||||
mColumnNames[pName] = i;
|
||||
}
|
||||
}
|
||||
|
||||
const TColumnNames::const_iterator iIndex = mColumnNames.find(apName);
|
||||
if (iIndex == mColumnNames.end())
|
||||
{
|
||||
throw SQLite::Exception("Unknown column name.");
|
||||
}
|
||||
|
||||
return (SQLITE_NULL == sqlite3_column_type(mStmtPtr, (*iIndex).second));
|
||||
}
|
||||
|
||||
// Return the named assigned to the specified result column (potentially aliased)
|
||||
const char* Statement::getColumnName(const int aIndex) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user