summaryrefslogtreecommitdiff
path: root/libodbcpp/selectcommand.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2008-11-13 14:45:11 +0000
committerrandomdan <randomdan@localhost>2008-11-13 14:45:11 +0000
commitefd292508070835781a0d92448a3661279dfd307 (patch)
tree0d2592bacfdb0cd159ebc5780dd69f86cc893af0 /libodbcpp/selectcommand.cpp
parentFix the C++ template errors (diff)
downloadlibdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.tar.bz2
libdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.tar.xz
libdbpp-odbc-efd292508070835781a0d92448a3661279dfd307.zip
Lots of little fixes
Diffstat (limited to 'libodbcpp/selectcommand.cpp')
-rw-r--r--libodbcpp/selectcommand.cpp24
1 files changed, 23 insertions, 1 deletions
diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp
index e097865..9d385b9 100644
--- a/libodbcpp/selectcommand.cpp
+++ b/libodbcpp/selectcommand.cpp
@@ -45,7 +45,7 @@ ODBC::SelectCommand::fetch()
// This is here cos it needs to be referenced by (and only by) execute
template <class t>
-ODBC::_Column<t>::_Column(String n, u_int i) : Column(n, i)
+ODBC::_Column<t>::_Column(String n, unsigned int i) : Column(n, i)
{
}
@@ -78,6 +78,7 @@ ODBC::SelectCommand::execute()
}
colName[nameLen] = '\0';
switch (bindType) {
+ case -9:
case SQL_CHAR:
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
@@ -109,6 +110,7 @@ ODBC::SelectCommand::execute()
columns[col] = i;
break;
}
+ case 11:
case SQL_DATETIME:
case SQL_TYPE_TIME:
case SQL_TYPE_DATE:
@@ -133,7 +135,27 @@ ODBC::SelectCommand::execute()
const ODBC::Column&
ODBC::SelectCommand::operator[](unsigned int col) const
{
+ if (col > columns.size()) {
+ throw ODBC::Error("Column index (%u) out of range", col);
+ }
return *columns[col];
}
+const ODBC::Column&
+ODBC::SelectCommand::operator[](const String & colName) const
+{
+ for (Columns::const_iterator col = columns.begin(); col != columns.end(); col++) {
+ if ((*col)->name == colName) {
+ return **col;
+ }
+ }
+ throw ODBC::Error("Column (%s) does not exist", colName.c_str());
+}
+
+unsigned int
+ODBC::SelectCommand::columnCount() const
+{
+ return columns.size();
+}
+