I have a code:
class StatementPtr {
Connection* connection_;
Statement *statement_;
public:
StatementPtr(Connection* connection, const string& sql): connection_(connection) {
statement_ = connection->createStatement(sql);
}
Statement* operator->() {
return statement_;
}
~StatementPtr() {
connection_->terminateStatement(statement_);
}
};
const string kShowTables = "SELECT table_name FROM user_tables";
unordered_set<string> fetchAllTables(Connection* connection) {
StatementPtr stmt(connection, kShowTables);
ResultSet *result_set = stmt->executeQuery();
unordered_set<string> tables;
while (result_set->next()) {
string table = result_set->getString(1);
cout << "Found user table: " << table << endl;
tables.insert(table);
}
return tables;
}
I was able to create environment and connection. However the first next() call causes segmentation call. Status of the call stmt->executeQuery() shows that the data is available.
Stack trace:
kpudfn2() at 0x7f3226a56590
OCIDefineByPos2() at 0x7f3226a16f8b
oracle::occi::ResultSetImpl::doOCIDefine() at 0x7f321eb02cdf
oracle::occi::ResultSetImpl::allocDefineDataBuffer() at 0x7f321eb01777
oracle::occi::ResultSetImpl::next() at 0x7f321eafde06
fetchAllTables() at oracle_utils.cpp:21 0x7f322d874c93
Does anyone veha an idea why it happens?
I use oracle instant client 12.1 to connect to oracle database 12c.