From 7297648c278903589beebf6fbc7511e5c1ff421d Mon Sep 17 00:00:00 2001 From: randomdan Date: Thu, 16 Sep 2010 00:01:56 +0000 Subject: 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 --- libodbcpp/selectcommand.cpp | 27 ++++++--------------------- 1 file changed, 6 insertions(+), 21 deletions(-) (limited to 'libodbcpp/selectcommand.cpp') 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 -ODBC::_Column::_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* d = new _Column(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* i = new _Column(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* t = new _Column(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(); } } -- cgit v1.2.3