diff -r 7f668a5a435b -r 7f396cdb9628 src/ResultSet.cpp --- a/src/ResultSet.cpp Tue Jun 02 18:40:20 2020 +0200 +++ b/src/ResultSet.cpp Tue Jun 02 20:57:12 2020 +0200 @@ -15,6 +15,9 @@ * along with this program. If not, see . */ +#include +#include + #include #include @@ -107,7 +110,17 @@ else throw SqlException(L"Unable to describe column " + std::to_wstring(columnNumber) + L", out of bounds, column count is " + std::to_wstring(columnCount)); } +SQLUSMALLINT ResultSet::MetaData::getColumnNumber(relpipe::writer::string_t columnName) { + // TODO: also case insensitive mode + for (SQLUSMALLINT i = 0; i < columnDescriptors.size(); i++) { + if (columnDescriptors[i].name == columnName) return i + 1; + } + std::wstringstream errorMessage; + errorMessage << L"Unable to find column with name „" << columnName.c_str() << L"“ Availalable columns are: "; + for (MetaData::ColumnDescriptor cd : columnDescriptors) errorMessage << L"„" << cd.name.c_str() << L"“ "; + throw SqlException(errorMessage.str()); +} } }