Name

Msql::Statement::dataseek

Synopsis

$statement_handle->dataseek($row_number);

Msql::Statement::dataseek takes the number of a row as its argument. The function resets the data so that the next call to Msql::Statement::fetchrow or Msql::Statement::fetchhash will return the information in that row. If a row number is supplied that is beyond the range of the table, the pointer is placed at the end of the table so that the next access will return an undefined value undef. The first row of the table is row number 0.

Example

use Msql;
my $db = Msql->connect;
$db->selectdb('mydata');
my $query = "SELECT name, date FROM myothertable";
my $myothertable_output = $db->query($query);

my @names = $myothertable_output->fetchcol(0);
my @dates = $myothertable_output->fetchcol(1);
# The pointer is now at the end of the table.

$myothertable_output->dataseek(0);
# The pointer is now reset to the beginning of the table.

print "This is the first row of data: ", $myothertable_output->fetchrow, "\n".

Get MySQL and mSQL now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.