A typical MySQL C API program involves three steps in query processing:
  Query construction
Depending upon your requirement you can construct a null terminated 
string or counted length string for the query: 
c
har *query;
  Execute the query
For executing the query you can use 
mysql_real_query()
 for a counted 
length query string or 
mysql_query() 
for a null terminated query string. 
Example 7 47 shows the processing of a query with both 
mysql_real_query()
 and 
mysql_query() 
method calls.
  Processing of the returned results
After executing the query, the final step is to process the results. All the 
statements except select, show, describe, and explain do not return any 
results; optionally in those query mysql provides 
mysql_affected_rows() 
for accessing the number of rows effected. 
If your query returns a result set, follow these steps for the result 
processing:
i. Generate the result set using 
mysql_store_result()
 or 
mysql_use_result()
.
ii. Fetch each row using 
mysql_fetch_row()
iii. Deallocate the result set using 
mysql_free_result()
Example 7 47shows an example for both MySQL query, which returns results 
as well as querys that do not return results.
Example 7 47   MySQL query processing
MYSQL_RES *result;
if (mysql_query(conn, "SELECT wk_id, user_id,status FROM warenkorb") != 0){
/* handle error */
return 1;
}
else
{
result = mysql_store_result (conn); /* generate result set */
if (result == NULL){
/* handle error */
return 1;
}else
{
/* process result set, then deallocate it */
MYSQL_ROW row;
MYSQL_FIELD* fd ;
204 
MySQL to DB2 UDB Conversion Guide






footer




 

 

 

 

 Home | About Us | Network | Services | Support | FAQ | Control Panel | Order Online | Sitemap | Contact

san diego web hosting

 

Our partners: PHP: Hypertext Preprocessor Cheap Web Hosting JSP Web Hosting Ontario Web Hosting  Jsp Web Hosting

Cheapest Web Hosting Java Hosting Cheapest Hosting

Visionwebhosting.net Business web hosting division of Vision Web Hosting Inc.. All rights reserved