Documentation Home
MySQL 5.6 Reference Manual
Related Documentation Download this Manual
PDF (US Ltr) - 31.0Mb
PDF (A4) - 31.0Mb
PDF (RPM) - 29.3Mb
HTML Download (TGZ) - 7.2Mb
HTML Download (Zip) - 7.2Mb
HTML Download (RPM) - 6.2Mb
Man Pages (TGZ) - 175.7Kb
Man Pages (Zip) - 286.0Kb
Info (Gzip) - 3.0Mb
Info (Zip) - 3.0Mb
Excerpts from this Manual mysql_row_tell()

MYSQL_ROW_OFFSET mysql_row_tell(MYSQL_RES *result)


Returns the current position of the row cursor for the last mysql_fetch_row(). This value can be used as an argument to mysql_row_seek().

Use mysql_row_tell() only after mysql_store_result(), not after mysql_use_result().

Return Values

The current offset of the row cursor.



User Comments
  Posted by Angus M on September 14, 2009
In case you are confused about what row the return value of mysql_row_tell() points to, it is the one that is returned by the *next* call to mysql_fetch_row(). Here's an example of what NOT to do:

for(MYSQL_ROW row; (row = mysql_fetch_row(result)) != NULL;) {
const char *pField = row[0];
MYSQL_ROW_OFFSET offset = mysql_row_tell(result);
AFieldFromTheSameRow(pField, offset);//Wrong!
If you do this, you'll be making the same mistake I just spent an hour on. In this case pField will not be from the same row as offset. Furthermore, offset will be undefined in the last iteration of the loop.

This is how you should do it:
for(MYSQL_ROW row; 1; ) {
MYSQL_ROW_OFFSET offset = mysql_row_tell(result);
if ((row = mysql_fetch_row(result)) == NULL) break;
const char *pField = row[0];
AFieldFromTheSameRow(pField, offset);

Sign Up Login You must be logged in to post a comment.