sqldata/sqlifmxapi.cpp
// Execute the statement and get scalar result
Execute the statement and get scalar result
Execute the statement and get scalar result
int SqlIfmxApi::ExecuteScalar(const char *query, int *result, size_t *time_spent)
{
	SQLHANDLE stmt;
	int q_result = 0;
	size_t start = GetTickCount();
	int rc = _SQLAllocHandle(SQL_HANDLE_STMT, _hdbc, &stmt);
	rc = _SQLExecDirect(stmt, (SQLCHAR*)query, SQL_NTS);
	if(rc == -1)
	{
		SetError(SQL_HANDLE_STMT, stmt);
		_SQLFreeHandle(SQL_HANDLE_STMT, stmt);
		return rc;
	}
	rc = _SQLBindCol(stmt, 1, SQL_C_SLONG, &q_result, 4, NULL);
	rc = _SQLFetch(stmt);
	if(result)
		*result = q_result;
	_SQLFreeHandle(SQL_HANDLE_STMT, stmt);
	if(time_spent != NULL)
		*time_spent = GetTickCount() - start;
	return rc;
}
int SqlIfmxApi :: ExecuteScalar ( const char * query , int * result , size_t * time_spent ) { SQLHANDLE stmt ; int q_result = 0 ; size_t start = GetTickCount ( ) ; int rc = _SQLAllocHandle ( SQL_HANDLE_STMT , _hdbc , & stmt ) ; rc = _SQLExecDirect ( stmt , ( SQLCHAR * ) query , SQL_NTS ) ; if ( rc == -1 ) { SetError ( SQL_HANDLE_STMT , stmt ) ; _SQLFreeHandle ( SQL_HANDLE_STMT , stmt ) ; return rc ; } rc = _SQLBindCol ( stmt , 1 , SQL_C_SLONG , & q_result , 4 , NULL ) ; rc = _SQLFetch ( stmt ) ; if ( result ) * result = q_result ; _SQLFreeHandle ( SQL_HANDLE_STMT , stmt ) ; if ( time_spent != NULL ) * time_spent = GetTickCount ( ) - start ; return rc ; }
Execute the statement and get scalar result
Execute the statement and get scalar result
// Allocate a statement handle // Execute the query // Error raised // Bind the result // Fetch the result // Set the query result