Processing Data in a Result Set
The ODBC obtains data from the database and provides the data to the application program for processing. Functions of ODBC processing include but are not limited to: retrieving data, displaying data, processing data, transmitting data, and implementing service logic.
The ODBC provides APIs for processing data in a result set, as described in Table 1.
Function |
API |
---|---|
Bind a buffer to a column in the result set. |
|
Fetch the next row (or rows) from a result set. |
|
Return data in a column of a result set. |
|
Get the column information from a result set. |
|
Return the error message of the last operation. |
The following is an example (for details about the complete example, see Obtaining and Processing Data in a Database):
// After the SQL statement is executed, obtain the attributes of a column in the result set. SQLColAttribute(V_OD_hstmt,1,SQL_DESC_TYPE,typename,100,NULL,NULL); printf("SQLColAtrribute %s\n",typename); // Bind the result set. SQLBindCol(V_OD_hstmt,1,SQL_C_SLONG, (SQLPOINTER)&V_OD_buffer,150, (SQLLEN *)&V_OD_err); // Use SQLFetch to obtain data from the result set. V_OD_erg=SQLFetch(V_OD_hstmt); // Use SQLGetData to obtain and return data. while(V_OD_erg != SQL_NO_DATA) { SQLGetData(V_OD_hstmt,1,SQL_C_SLONG,(SQLPOINTER)&V_OD_id,0,NULL); printf("SQLGetData ----ID = %d\n",V_OD_id); V_OD_erg=SQLFetch(V_OD_hstmt); }; printf("Done !\n");
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.