Algorithm to retrieve result sets

The pseudocode below illustrates a typical algorithm for retrieving result sets using a RecordSet object. getEmployeeDetails() is a method in the component that returns a single result set as a RecordSet object. The algorithm executes three nested loops, as follows:

Here is the algorithm:

Integer employee_id
RecordSet = proxycomponent.getEmployeeDetails(employee_id)

DO
    // Position the row pointer before the first row.
    RecordSet.MoveFirst()

    // Iterate through all the rows.
    WHILE RecordSet.EOF = FALSE
       
       // Fields object represents the current row.
       Fields = RecordSet.Fields

       // Iterate through columns.
       FOR i = 0 TO i = (Fields.Count - 1)

           Field = Fields.Item(i)

           ... retrieve Field  properties to process column 
               data as desired ...

       END FOR

       // Move to the next row.
       RecordSet.MoveNext()

    END WHILE

    // Move to the next result set, if any.
    RecordSet = RecordSet.NextRecordSet()

WHILE RecordSet.EOF = FALSE

The logic in this example executes correctly if a method has not returned result sets. In this case, the RecordSet.EOF property is always false.

Some scripting languages may allow or require variations on this algorithm, for example: