diff -r 428c278af4be -r c83119110c7b src/ResultSet.cpp --- a/src/ResultSet.cpp Thu Jun 04 00:46:00 2020 +0200 +++ b/src/ResultSet.cpp Thu Jun 04 13:24:17 2020 +0200 @@ -44,12 +44,18 @@ } relpipe::writer::boolean_t ResultSet::getBoolean(unsigned short columnNumber, bool* isNull) { - throw SqlException(L"not yet implemented: getBoolean()"); + relpipe::writer::string_t s = getString(columnNumber, isNull); + if (isNull && *isNull) return false; + else if (s == L"1" || s == L"true" || s == L"y" || s == L"yes" || s == L"TRUE" || s == L"Y" || s == L"YES") return true; + else if (s == L"0" || s == L"false" || s == L"n" || s == L"no" || s == L"FALSE" || s == L"N" || s == L"NO") return false; + else throw SqlException(L"Unable to parse „" + s + L"“ as boolean"); } relpipe::writer::integer_t ResultSet::getInteger(unsigned short columnNumber, bool* isNull) { - throw SqlException(L"not yet implemented: getInteger()"); - + // TODO: get integer directly from SQLGetData() without string conversion + relpipe::writer::string_t s = getString(columnNumber, isNull); + if (isNull && *isNull) return 0; + else return std::stol(s); } relpipe::writer::string_t ResultSet::getString(unsigned short columnNumber, bool* isNull) { @@ -85,10 +91,15 @@ SQLULEN columnSize; SQLSMALLINT decimalDigits; SQLSMALLINT nullable; + result = SQLDescribeCol(statement, columnNumber, (SQLCHAR*) nameBuffer.c_str(), nameBuffer.capacity(), &nameLength, &dataType, &columnSize, &decimalDigits, &nullable); if (OdbcCommon::isNotSuccessful(result)) throw SqlException(L"Unable describe column", result, SQL_HANDLE_STMT, statement); + columnDescriptor.name = convertor.from_bytes(nameBuffer.c_str()); - //columnDescriptor.type = … // FIXME: support also other types than string + + if (dataType == SQL_INTEGER || dataType == SQL_BIGINT) columnDescriptor.type = relpipe::writer::TypeId::INTEGER; + else if (dataType == SQL_BIT) columnDescriptor.type = relpipe::writer::TypeId::BOOLEAN; + columnDescriptors.emplace_back(columnDescriptor); }