summaryrefslogtreecommitdiff
path: root/libodbcpp/selectcommand.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2011-02-09 01:33:33 +0000
committerrandomdan <randomdan@localhost>2011-02-09 01:33:33 +0000
commit6d7c18f1119de8941c7055910e55c13c411eeb92 (patch)
tree9468662e07280c26e29de53f7fdfa228eb62ecde /libodbcpp/selectcommand.cpp
parentAdd missing conversion in generic visitor (diff)
downloadlibdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.tar.bz2
libdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.tar.xz
libdbpp-odbc-6d7c18f1119de8941c7055910e55c13c411eeb92.zip
Fix the build system to do dependencies properly
Break down libodbcpp into a set of base classes; libdbpp Add a native PostgreSQL implementation of libdbpp; libpqpp Extend project2 rdbms stuff to work with generic connectors Update datasources to specify connector type Build libmisc as .so
Diffstat (limited to 'libodbcpp/selectcommand.cpp')
-rw-r--r--libodbcpp/selectcommand.cpp37
1 files changed, 20 insertions, 17 deletions
diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp
index a297f75..2153862 100644
--- a/libodbcpp/selectcommand.cpp
+++ b/libodbcpp/selectcommand.cpp
@@ -6,7 +6,9 @@
#include <string.h>
ODBC::SelectCommand::SelectCommand(const Connection & c, const std::string & s) :
- Command(c, s)
+ DB::Command(s),
+ ODBC::Command(c, s),
+ DB::SelectCommand(s)
{
}
@@ -20,13 +22,18 @@ ODBC::SelectCommand::~SelectCommand()
if (columns.size()) {
RETCODE rc = SQLCloseCursor(hStmt);
if (!SQL_SUCCEEDED(rc)) {
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLCloseCursor",
- __FUNCTION__);
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::~SelectCommand SQLCloseCursor");
}
}
}
bool
+ODBC::SelectCommand::fetch()
+{
+ return fetch(SQL_FETCH_NEXT, 0);
+}
+
+bool
ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset)
{
if (columns.size() == 0) {
@@ -55,8 +62,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset)
}
}
}
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLFetch",
- __FUNCTION__);
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::fetch SQLFetch");
}
}
@@ -65,16 +71,14 @@ ODBC::SelectCommand::execute()
{
RETCODE rc = SQLExecute(hStmt);
if (!SQL_SUCCEEDED(rc)) {
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLExecute",
- __FUNCTION__);
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::execute SQLExecute");
}
SQLSMALLINT colCount;
if (!SQL_SUCCEEDED(rc = SQLNumResultCols(hStmt, &colCount))) {
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLNumResultCols",
- __FUNCTION__);
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::execute SQLNumResultCols");
}
if (colCount < 1) {
- throw Error("%s: No result columns", __FUNCTION__);
+ throw Error("ODBC::SelectCommand::execute No result columns");
}
columns.resize(colCount);
for (int col = 0; col < colCount; col++) {
@@ -84,8 +88,7 @@ ODBC::SelectCommand::execute()
int sqlcol = col + 1;
if (!SQL_SUCCEEDED(rc = SQLDescribeCol(hStmt, sqlcol, _colName, sizeof(_colName), &nameLen, &bindType,
&bindSize, &dp, &nullable))) {
- throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLDescribeCol for %d",
- __FUNCTION__, col);
+ throw Error(rc, SQL_HANDLE_STMT, hStmt, "ODBC::SelectCommand::execute SQLDescribeCol for %d");
}
Glib::ustring colName((const char *)_colName, nameLen);
switch (bindType) {
@@ -118,16 +121,16 @@ ODBC::SelectCommand::execute()
}
-const ODBC::Column&
+const DB::Column&
ODBC::SelectCommand::operator[](unsigned int col) const
{
if (col > columns.size()) {
- throw ODBC::Error("Column index (%u) out of range", col);
+ throw ODBC::Error("Column index out of range");
}
return *columns[col];
}
-const ODBC::Column&
+const DB::Column&
ODBC::SelectCommand::operator[](const Glib::ustring & colName) const
{
for (Columns::const_iterator col = columns.begin(); col != columns.end(); col++) {
@@ -135,7 +138,7 @@ ODBC::SelectCommand::operator[](const Glib::ustring & colName) const
return **col;
}
}
- throw ODBC::Error("Column (%s) does not exist", colName.c_str());
+ throw ODBC::Error("Column does not exist");
}
unsigned int
@@ -148,7 +151,7 @@ ODBC::SelectCommand::getOrdinal(const Glib::ustring & colName) const
}
n += 1;
}
- throw ODBC::Error("Column (%s) does not exist", colName.c_str());
+ throw ODBC::Error("Column does not exist");
}
unsigned int