Oracle 5.0 Reference Manual page 2171

Table of Contents

Advertisement

Example
The following example shows how you might use mysql_eof():
mysql_query(&mysql,"SELECT * FROM some_table");
result = mysql_use_result(&mysql);
while((row = mysql_fetch_row(result)))
{
// do something with data
}
if(!mysql_eof(result))
{
fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
}
However, you can achieve the same effect with the standard MySQL error functions:
mysql_query(&mysql,"SELECT * FROM some_table");
result = mysql_use_result(&mysql);
while((row = mysql_fetch_row(result)))
{
// do something with data
}
if(mysql_errno(&mysql))
{
fprintf(stderr, "Error: %s\n", mysql_error(&mysql));
}
20.6.6.14.
mysql_errno()
unsigned int mysql_errno(MYSQL *mysql)
Description
For the connection specified by mysql,
invoked API function that can succeed or fail. A return value of zero means that no error occurred.
Client error message numbers are listed in the MySQL
numbers are listed in mysqld_error.h. Errors also are listed at
Common
Problems.
Note that some functions like
A rule of thumb is that all functions that have to ask the server for information reset
they succeed.
MySQL-specific error numbers returned by
returned by mysql_sqlstate(). For example, the
the following format, where
mysql_sqlstate()
shell>
SELECT * FROM no_such_table;
ERROR 1146 (42S02): Table 'test.no_such_table' doesn't exist
Return Values
An error code value for the last
Errors
None.
20.6.6.15.
mysql_error()
const char *mysql_error(MYSQL *mysql)
C API Function Descriptions
// mysql_fetch_row() failed due to an error
// mysql_fetch_row() failed due to an error
mysql_errno()
mysql_fetch_row()
mysql_errno()
is the
1146
mysql_errno()
value:
mysql_xxx()
2151
returns the error code for the most recently
header file. Server error message
errmsg.h
Appendix C, Errors, Error Codes, and
don't set
mysql_errno()
differ from SQLSTATE values
client program displays errors using
mysql
value and
'42S02'
call, if it failed. zero means no error occurred.
if they succeed.
mysql_errno()
is the corresponding
if

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents