Errors on the interaction can be captured using mapi_error(), possibly followed by a request to dump a short errormessage explanation on a standard file location. It has been abstracted away in a function.
mapi
Download File: https://glutitxtagbu.blogspot.com/?download=2vEQaD
Provided we can establish a connection, the interaction proceeds as in many similar application development packages.Queries are shipped for execution using mapi_query() and an answer table can be consumed one row at a time.In many cases these functions suffice.
The Mapi interface provides caching of rows at the client side. mapi_query() will load tuples into the cache,after which they can be read repeatedly using mapi_fetch_row() or directly accessed (mapi_seek_row()).This facility is particularly handy when small, but stable query results are repeatedly used in the client program.
The interface assumes a cautious user, who understands and has experience with the query or programming language model.It should also be clear that references returned by the API point directly into the administrative structures of Mapi.This means that they are valid only for a short period, mostly between successive mapi_fetch_row() commands.It also means that it the values are to retained, they have to be copied. A defensive programming style is advised.
Upon an error, the routines mapi_explain() and mapi_explain_query() give information about the context of the failedcall, including the expression shipped and any response received. The side-effect is clearing the error status.
Almost every call can fail since the connection with the database server can fail at any time. Functions that return ahandle (either Mapi or MapiHdl) may return NULL on failure, or they may return the handle with the error flag set.If the function returns a non-NULL handle, always check for errors with mapi_error.
To check for error messages from the server, call mapi_result_error(). This function returns NULL if there was noerror, or the error message if there was. A user-friendly message can be printed using map_explain_result().Typical usage is:
Send the Command to the database server represented by mid. This function returns a query handle with which theresults of the query can be retrieved. The handle should be closed with mapi_close_handle().The command response is buffered for consumption, c.f. mapi_fetch_row().
Send the Command to the database server represented by hdl, reusing the handle from a previous query.If Command is zero it takes the last query string kept around. The command response is buffered for consumption,e.g. mapi_fetch_row().
Terminate a query. This routine is used in the rare cases that consumption of the tuple stream produced should beprematurely terminated. It is automatically called when a new query using the same query handle is shipped to thedatabase and when the query handle is closed with mapi_close_handle().
Retrieve a row from the server. The text retrieved is kept around in a buffer linked with the query handle fromwhich selective fields can be extracted. It returns the number of fields recognized. A zero is returned uponencountering end of sequence or error. This can be analyzed in using mapi_error().
Return the length of the C-string representation excluding trailing NULL byte of the value. Zero is returnedupon encountering an error, when the database value is NULL, of when the string is the empty string.This can be analyzed by using mapi_error() and mapi_fetch_field().
Bind a string variable with a field in the return table. Upon a successful subsequent mapi_fetch_row() theindicated field is stored in the space pointed to by val. Returns an error if the field identified does not exist.
Bind a variable to a field in the return table. Upon a successful subsequent mapi_fetch_row(), the indicatedfield is converted to the given type and stored in the space pointed to by val.The types recognized are ** MAPI_TINY, MAPI_UTINY, MAPI_SHORT, MAPI_USHORT, MAPI_INT, MAPI_UINT, MAPI_LONG, MAPI_ULONG, MAPI_LONGLONG, MAPI_ULONGLONG, MAPI_CHAR, MAPI_VARCHAR, MAPI_FLOAT, MAPI_DOUBLE, MAPI_DATE, MAPI_TIME, MAPI_DATETIME**.The binding operations should be performed after the mapi_execute command.Subsequently all rows being fetched also involve delivery of the field values in the C-variables using properconversion. For variable length strings a pointer is set into the cache.
Log the interaction between the client and server for offline inspection. Beware that the log file overwrites any previous log. For detailed interaction trace with the Mapi library itself use mapi_trace(). 2ff7e9595c
Comments