From 5f832d982a053f596426e3a2d2f6d152bbf4052c Mon Sep 17 00:00:00 2001 From: Aki Tuomi Date: Thu, 26 Nov 2015 10:36:56 +0200 Subject: [PATCH] Retrieve data only once --- modules/godbcbackend/sodbc.cc | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/modules/godbcbackend/sodbc.cc b/modules/godbcbackend/sodbc.cc index 6b03c5f099..e2af0d0dd8 100644 --- a/modules/godbcbackend/sodbc.cc +++ b/modules/godbcbackend/sodbc.cc @@ -270,23 +270,13 @@ SSqlStatement* SODBCStatement::nextRow(row_t& row) for ( int i = 0; i < m_columncount; i++ ) { SQLLEN len; - result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER)0, 0, &len ); - if ( len == SQL_NULL_DATA ) { - // Column is NULL, so we can skip the converting part. - row.push_back( "" ); - } else { - SQLCHAR coldata[128*1024]; - result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len); - std::string strres = std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); // do not use nil byte - while(result == SQL_SUCCESS_WITH_INFO && len > 0) { // all data is consumed if len < 1 - result = SQLGetData( d_statement, i + 1, SQL_C_CHAR, (SQLPOINTER) coldata, sizeof(coldata), &len ); - strres = strres + std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); - cerr<<"len="< SQL_NULL_DATA) + strres = std::string(reinterpret_cast(coldata), std::min(sizeof(coldata)-1,len)); // do not use nil byte + row.push_back(strres); } // Done! -- 2.47.2