Move the Cursor to the Next Row

The result set maintains a cursor (that is, a reference) on the current row, initially positioned just before the first row so that you can perform operations on the table. The only way to do operations on the table is through the cursor.

You can move the cursor to the next row, using the following function:

boolean Query.ResultSet.next(String ResultsetName)

The function returns false when the cursor moves after the last row (or when there is no row).

To get the value of a column in the row referenced by the cursor, pass the index of that column to the following function:

Object Query.ResultSet.get(String ResultsetName, int ZeroBasedColumnIndex)

The following example shows how you can get the value of column 1 in each row of the result set and simply display it on the console:

while(Query.ResultSet.next("rset")) {
    System.debugOut(Query.ResultSet.get("rset",1));
}

Where "rset" is the name of the result set.