Hello everyone,
I'm trying to run asynchronous queries with unixODBC + psqlodbcw.so in linux (RHEL5), but I can not do it.
The next code:
//-------
// Get the Async state
SQLINTEGER attrState;
SQLGetConnectAttr(hstmt, SQL_ATTR_ASYNC_ENABLE, &attrState, 0, NULL);
std::cout << "Async is set to: " << attrState << std::endl;
// Enable Async Operation - if ASYNC is not allowed, SQLSetStmtAttr
// will return an error
retcode = SQLSetStmtAttr (hstmt, SQL_ATTR_ASYNC_ENABLE,
(SQLPOINTER) SQL_ASYNC_ENABLE_ON, SQL_IS_INTEGER);
CHECK_ERROR(retcode, "SQLSetStmtAttr(SQL_ATTR_ASYNC_ENABLE)",
hstmt, SQL_HANDLE_STMT);
// Get the Async state again
SQLGetConnectAttr(hstmt, SQL_ATTR_ASYNC_ENABLE, &attrState, 0, NULL);
std::cout << "Async is set to: " << attrState << " now " << std::endl;
// Execute SELECT whilst status SQL_STILL_EXECUTING
//retcode = SQLExecDirect (hstmt, stmt, SQL_NTS);
while (SQLExecDirect (hstmt, stmt, SQL_NTS) == SQL_STILL_EXECUTING) {
printf ("\nStill executing ...");
printf ("\nSnooze ..");
sleep(1);
printf ("\nAwake ..");
retcode = SQLExecDirect (hstmt, stmt, SQL_NTS);
}