equal
deleted
inserted
replaced
65 if (isNull) *isNull = stringLength == SQL_NULL_DATA; |
65 if (isNull) *isNull = stringLength == SQL_NULL_DATA; |
66 if (stringLength == SQL_NULL_DATA) { |
66 if (stringLength == SQL_NULL_DATA) { |
67 return L""; |
67 return L""; |
68 } else if (stringLength >= 0) { |
68 } else if (stringLength >= 0) { |
69 std::string value; |
69 std::string value; |
70 value.reserve(stringLength); |
70 value.resize(stringLength); |
71 result = SQLGetData(statement, columnNumber, SQL_C_CHAR, (SQLCHAR*) value.c_str(), value.capacity() + 1, &stringLength); // trailing null byte = + 1 |
71 result = SQLGetData(statement, columnNumber, SQL_C_CHAR, (SQLCHAR*) value.c_str(), value.capacity() + 1, &stringLength); // trailing null byte = + 1 |
72 if (OdbcCommon::isSuccessful(result)) return convertor.from_bytes(value.c_str()); |
72 if (OdbcCommon::isSuccessful(result)) return convertor.from_bytes(value); |
73 } |
73 } |
74 throw SqlException(L"Unable to get string value", result, SQL_HANDLE_STMT, statement); |
74 throw SqlException(L"Unable to get string value", result, SQL_HANDLE_STMT, statement); |
75 } |
75 } |
76 |
76 |
77 ResultSet::MetaData* ResultSet::getMetaData() { |
77 ResultSet::MetaData* ResultSet::getMetaData() { |
126 for (SQLUSMALLINT i = 0; i < columnDescriptors.size(); i++) { |
126 for (SQLUSMALLINT i = 0; i < columnDescriptors.size(); i++) { |
127 if (columnDescriptors[i].name == columnName) return i + 1; |
127 if (columnDescriptors[i].name == columnName) return i + 1; |
128 } |
128 } |
129 |
129 |
130 std::wstringstream errorMessage; |
130 std::wstringstream errorMessage; |
131 errorMessage << L"Unable to find column with name „" << columnName.c_str() << L"“ Availalable columns are: "; |
131 errorMessage << L"Unable to find column with name „" << columnName << L"“ Availalable columns are: "; |
132 for (MetaData::ColumnDescriptor cd : columnDescriptors) errorMessage << L"„" << cd.name.c_str() << L"“ "; |
132 for (MetaData::ColumnDescriptor cd : columnDescriptors) errorMessage << L"„" << cd.name << L"“ "; |
133 throw SqlException(errorMessage.str()); |
133 throw SqlException(errorMessage.str()); |
134 } |
134 } |
135 |
135 |
136 } |
136 } |
137 } |
137 } |