Icon Navigating Tables, Views, and Query Result Sets

Navigation of tables, views, and query result sets is accomplished through several methods of the TEDBTable, TEDBQuery, TEDBScript, and TEDBStoredProc components. The basic navigational methods include the First, Next, Prior, Last, and MoveBy methods. The Bof and Eof properties indicate whether the row pointer is at the beginning or at the end of the table, view, or query result set, respectively. These methods and properties are used together to navigate a table, view, or query result set.

Moving to the First or Last Row
The First method moves to the first row in the table, view, or query result set based upon the current index order. The Last method moves to the last row in the table, view, or query result set based upon the current index order. The following example shows how to move to the first and last rows in a table:

{
   MyTable->First();
   //  do something to the first row
   MyTable->Last();
   // do something to the last row
}

Skipping Rows
The Next method moves to the next row in the table, view, or query result set based upon the current index order. If the current row pointer is at the last row in the table, view, or query result set, then calling the Next method will set the Eof property to True and the row pointer will stay on the last row. The Prior method moves to the previous row in the table, view, or query result set based upon the current index order. If the current row pointer is at the first row in the table, view, or query result set, then calling the Prior method will set the Bof property to True and the row pointer will stay on the first row. The following example shows how to use the First and Next methods along with the Eof property to loop through an entire table:

{
   MyTable->First();
   while (!MyTable->Eof)
      {
      MyTable->Next();
      }
}

The following example shows how to use the Last and Prior methods along with the Bof property to loop backwards through an entire table:

{
   MyTable->Last();
   while (!MyTable->Bof)
      {
      MyTable->Prior();
      }
}

Skipping Multiple Rows
The MoveBy method accepts a positive or negative integer that represents the number of rows to move by within the table, view, or query result set. A positive integer indicates that the movement will be forward while a negative integer indicates that the movement will be backward. The return value of the MoveBy method is the number of rows actually visited during the execution of the MoveBy method. If the row pointer hits the beginning of file or hits the end of file then the return value of the MoveBy method will be less than the desired number of rows. The following example shows how to use the MoveBy method to loop through an entire table 10 rows at a time:

{
   MyTable->First();
   while (!MyTable->Eof)
      {
      MyTable->MoveBy(10);
      }
}
Image