diff options
author | randomdan <randomdan@localhost> | 2010-06-11 09:03:42 +0000 |
---|---|---|
committer | randomdan <randomdan@localhost> | 2010-06-11 09:03:42 +0000 |
commit | 1df33cc9d9a7804c78788d5717435ede44855ca0 (patch) | |
tree | b78e66de0a9f7d6bb39038d6f628cbc871ffa652 /libodbcpp/selectcommand.cpp | |
parent | Initial workings of project2 - renders gentoobrowse homepage (diff) | |
download | libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.tar.bz2 libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.tar.xz libdbpp-odbc-1df33cc9d9a7804c78788d5717435ede44855ca0.zip |
Use Glib::ustring in libodbcpp for data and std::string for non-data
Add support for parameters in SqlViews
Uses parameters to implement category browse and search
Diffstat (limited to 'libodbcpp/selectcommand.cpp')
-rw-r--r-- | libodbcpp/selectcommand.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp index 025141a..26b6b45 100644 --- a/libodbcpp/selectcommand.cpp +++ b/libodbcpp/selectcommand.cpp @@ -4,7 +4,7 @@ #include <sqlext.h> #include <stdio.h> -ODBC::SelectCommand::SelectCommand(const Connection& c, String s) : +ODBC::SelectCommand::SelectCommand(const Connection & c, const std::string & s) : Command(c, s) { } @@ -32,9 +32,6 @@ ODBC::SelectCommand::fetch() RETCODE rc = SQLFetch(hStmt); switch (rc) { case SQL_SUCCESS: - for (Columns::iterator col = columns.begin(); col != columns.end(); col++) { - (*col)->fresh = true; - } return true; case SQL_NO_DATA: return false; @@ -46,7 +43,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, unsigned int i) : Column(n, i) +ODBC::_Column<t>::_Column(const Glib::ustring & n, unsigned int i) : Column(n, i) { } @@ -68,16 +65,16 @@ ODBC::SelectCommand::execute() } columns.resize(colCount); for (int col = 0; col < colCount; col++) { - SQLCHAR colName[300]; + SQLCHAR _colName[300]; SQLSMALLINT nameLen, dp, nullable, bindType; SQLUINTEGER bindSize; int sqlcol = col + 1; - if ((rc = SQLDescribeCol(hStmt, sqlcol, colName, sizeof(colName), &nameLen, &bindType, + if ((rc = SQLDescribeCol(hStmt, sqlcol, _colName, sizeof(_colName), &nameLen, &bindType, &bindSize, &dp, &nullable)) != SQL_SUCCESS) { throw Error(rc, SQL_HANDLE_STMT, hStmt, "%s: SQLDescribeCol for %d", __FUNCTION__, col); } - colName[nameLen] = '\0'; + Glib::ustring colName((const char *)_colName, nameLen); switch (bindType) { case -9: case SQL_CHAR: @@ -125,7 +122,7 @@ ODBC::SelectCommand::execute() default: throw Error( "%s: Bad column type: idx=%d, name=%s, type=%d, size=%ld, dp=%d, null=%d", - __FUNCTION__, col, colName, bindType, bindSize, dp, nullable); + __FUNCTION__, col, _colName, bindType, bindSize, dp, nullable); break; }; } @@ -142,7 +139,7 @@ ODBC::SelectCommand::operator[](unsigned int col) const } const ODBC::Column& -ODBC::SelectCommand::operator[](const String & colName) const +ODBC::SelectCommand::operator[](const Glib::ustring & colName) const { for (Columns::const_iterator col = columns.begin(); col != columns.end(); col++) { if ((*col)->name == colName) { @@ -153,7 +150,7 @@ ODBC::SelectCommand::operator[](const String & colName) const } unsigned int -ODBC::SelectCommand::getOrdinal(const String & colName) const +ODBC::SelectCommand::getOrdinal(const Glib::ustring & colName) const { unsigned int n = 0; for (Columns::const_iterator col = columns.begin(); col != columns.end(); col++) { |