summaryrefslogtreecommitdiff
path: root/libodbcpp/selectcommand.cpp
diff options
context:
space:
mode:
authorrandomdan <randomdan@localhost>2010-09-16 00:01:56 +0000
committerrandomdan <randomdan@localhost>2010-09-16 00:01:56 +0000
commit7297648c278903589beebf6fbc7511e5c1ff421d (patch)
treea2686c7d458aad2c32bcb1ae61cb4e04702fd9d4 /libodbcpp/selectcommand.cpp
parentRemove duplication in ODBC::Connection constructors (diff)
downloadlibdbpp-odbc-7297648c278903589beebf6fbc7511e5c1ff421d.tar.bz2
libdbpp-odbc-7297648c278903589beebf6fbc7511e5c1ff421d.tar.xz
libdbpp-odbc-7297648c278903589beebf6fbc7511e5c1ff421d.zip
Rewrite the whole of parameter and column binding almost from scratch
No more template rubbish, no more messy partial specialisation Add copyless rebind of column to parameter Changes in project2 to suit
Diffstat (limited to 'libodbcpp/selectcommand.cpp')
-rw-r--r--libodbcpp/selectcommand.cpp27
1 files changed, 6 insertions, 21 deletions
diff --git a/libodbcpp/selectcommand.cpp b/libodbcpp/selectcommand.cpp
index 3b903d6..77e22f4 100644
--- a/libodbcpp/selectcommand.cpp
+++ b/libodbcpp/selectcommand.cpp
@@ -36,8 +36,7 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset)
switch (rc) {
case SQL_SUCCESS:
for (Columns::iterator i = columns.begin(); i != columns.end(); i++) {
- delete (*i)->composeCache;
- (*i)->composeCache = NULL;
+ (*i)->onScroll();
}
return true;
case SQL_NO_DATA:
@@ -60,12 +59,6 @@ ODBC::SelectCommand::fetch(SQLSMALLINT orientation, SQLLEN offset)
}
}
-// This is here cos it needs to be referenced by (and only by) execute
-template <class t>
-ODBC::_Column<t>::_Column(const Glib::ustring & n, unsigned int i) : Column(n, i)
-{
-}
-
void
ODBC::SelectCommand::execute()
{
@@ -100,10 +93,7 @@ ODBC::SelectCommand::execute()
case SQL_VARCHAR:
case SQL_LONGVARCHAR:
{
- StringColumn* s = new StringColumn(colName, col);
- s->value.resize(bindSize + 1);
- s->bind(hStmt, sqlcol, SQL_C_CHAR, &s->value[0], bindSize + 1);
- columns[col] = s;
+ columns[col] = new CharArrayColumn(this, colName, col);
break;
}
case SQL_DECIMAL:
@@ -112,9 +102,7 @@ ODBC::SelectCommand::execute()
case SQL_FLOAT:
case SQL_DOUBLE:
{
- _Column<SQLDOUBLE>* d = new _Column<SQLDOUBLE>(colName, col);
- d->bind(hStmt, sqlcol, SQL_C_DOUBLE, &d->value, sizeof(double));
- columns[col] = d;
+ columns[col] = new FloatingPointColumn(this, colName, col);
break;
}
case SQL_SMALLINT:
@@ -122,9 +110,7 @@ ODBC::SelectCommand::execute()
case SQL_TINYINT:
case SQL_BIGINT:
{
- _Column<SQLINTEGER>* i = new _Column<SQLINTEGER>(colName, col);
- i->bind(hStmt, sqlcol, SQL_C_LONG, &i->value, sizeof(int));
- columns[col] = i;
+ columns[col] = new SignedIntegerColumn(this, colName, col);
break;
}
case SQL_TIMESTAMP:
@@ -133,9 +119,7 @@ ODBC::SelectCommand::execute()
case SQL_TYPE_DATE:
case SQL_TYPE_TIMESTAMP:
{
- _Column<SQL_TIMESTAMP_STRUCT>* t = new _Column<SQL_TIMESTAMP_STRUCT>(colName, col);
- t->bind(hStmt, sqlcol, SQL_C_TIMESTAMP, &t->value, sizeof(SQL_TIMESTAMP_STRUCT));
- columns[col] = t;
+ columns[col] = new TimeStampColumn(this, colName, col);
break;
}
default:
@@ -144,6 +128,7 @@ ODBC::SelectCommand::execute()
__FUNCTION__, col, _colName, bindType, bindSize, dp, nullable);
break;
};
+ columns[col]->bind();
}
}