Copy Occi::ResultSet before closing Occi::Connection Copy Occi::ResultSet before closing Occi::Connection oracle oracle

Copy Occi::ResultSet before closing Occi::Connection


It is not possible to close the connection to the database and save the result set (occi::ResultSet) for later use. One reason is that occi::ResultSet::next retrieves data from the database. Instead you may use array fetch and a user allocated data buffer to store the results.

Example of use of occi::ResultSet::setDataBuffer:

oracle::occi::ResultSet* rs=nullptr;//.....// query//.....static const size_t max_numrows=5000;char var_buf[max_numrows][7];char sym_buf[max_numrows][9];rs->setDataBuffer(1,var_buf,oracle::occi::OCCI_SQLT_STR,sizeof(var_buf[0]),(ub2*)0);rs->setDataBuffer(2,sym_buf,oracle::occi::OCCI_SQLT_STR,sizeof(sym_buf[0]),(ub2*)0);size_t fetch_count=0;while(rs->next(max_numrows)==ResultSet::DATA_AVAILABLE){    /* This would probably be an error as you would like       the whole result to fit in the data buffer.*/}stmt->closeResultSet (rs);conn->terminateStatement (stmt);compute(var_buf,sym_buf);

Note that array fetch acts like prefetch in that

Status next(   unsigned int numRows =1);

fetches up to numRows per call.


Execute query does not retrieve data. You read data from server using rset->next ().So, if you terminate connection - you cannot read data