Arjan Scherpenisse wrote:
For SQL code, I check now with:
hdl = mapi_query(mid, "very wrong query."); while( mapi_next_result(hdl) ) { if (mapi_result_error(hdl)) { // error handling here
how to do this equivalent for mil queries? Or dont we need mil queries anymore?
My personal opinion is to keep doing it the old way for mil-type queries (if (mapi_error()) etc), but that does not seem to work...
This code is not correct. After mapi_query you're already at the first
result set, so you should start with calling mapi_result_error.
The suggested code is:
mapi_query(hdl, query);
do {
if ((error = mapi_result_error(hdl)) != NULL)
mapi_explain_result(hdl, stderr);
while ((line = mapi_fetch_line(hdl)) != NULL)
/* use output */;
} while (mapi_next_result(hdl) == 1);
Note the comparison with 1. MERROR is also != 0, but you shouldn't
continue after you got an error.
(Also note the use of traditional C comment markers ;-)
--
Sjoerd Mullender