Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef WIN32
- int odbc_db_query(SQLHDBC hDbc, struct QUERY_RESULTS_STRUCT *result_info, volatile const char *sql, const unsigned long lengt)
- {
- int ret = QUERY_OKAY;
- SQLHSTMT hStmt = NULL;
- RETCODE rc;
- // SQLSMALLINT sNumResults;
- rc = SQLAllocHandle(SQL_HANDLE_STMT, hDbc, &hStmt);
- if (SQL_SUCCESS != rc)
- {
- odbc_db_error_status(hDbc, SQL_HANDLE_DBC, NULL, true);
- return QUERY_ERROR;
- }
- rc = SQLExecDirect(hStmt, (SQLCHAR*)sql, lengt);
- switch (rc)
- {
- case SQL_NO_DATA:
- {
- ret = QUERY_OKAY;
- break;
- }
- case SQL_SUCCESS_WITH_INFO:
- {
- ret = QUERY_OKAY;
- odbc_db_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- // fall through
- }
- case SQL_SUCCESS:
- {
- ret = QUERY_OKAY;
- /*rc = SQLNumResultCols(hStmt, &sNumResults);
- if (SQL_ERROR == rc)
- {
- fetch_odbc_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- break;
- }
- if (sNumResults > 0)
- {
- //DisplayResults(hStmt, sNumResults);
- }
- else
- {
- SQLLEN cRowCount;
- rc = SQLRowCount(hStmt, &cRowCount);
- if (SQL_ERROR == rc)
- {
- fetch_odbc_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- break;
- }
- }
- */
- break;
- }
- case SQL_ERROR:
- {
- ret = QUERY_ERROR;
- odbc_db_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- break;
- }
- default:
- {
- ret = QUERY_ERROR;
- odbc_db_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- }
- break;
- }
- if (hStmt)
- {
- rc = SQLFreeHandle(SQL_HANDLE_STMT, hStmt);
- if (SQL_ERROR == rc)
- {
- ret = QUERY_ERROR;//didn't really fail - the free failed, but still...
- //fetch_odbc_error_status(hStmt, SQL_HANDLE_STMT, result_info, false);
- }
- }
- return ret;
- }
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement