# File SQLRelay.rb, line 266
  def fetch_scroll(direction, offset=1)

    # decide which row to fetch, take into account that the standard behavior
    # of a fetch command is to fetch the row and then skip to the next row
    # of the result set afterward
    fetch_row = case direction
      when DBI::SQL_FETCH_NEXT     then @row_index
      when DBI::SQL_FETCH_PRIOR    then @row_index-2
      when DBI::SQL_FETCH_FIRST    then 0
      when DBI::SQL_FETCH_LAST     then @row_count-1
      when DBI::SQL_FETCH_ABSOLUTE then offset
      when DBI::SQL_FETCH_RELATIVE then @row_index+offset-1
    end
    
    # fetch the row
    row = nil
    if fetch_row > -1 and fetch_row < @row_count
      row = @handle.getRow(fetch_row)
    end

    # set the current row, avoid running past 
    # the end or beginning of the result set
    @row_index = fetch_row + 1
    if @row_index < 0 then
      @row_index = 0
    elsif @row_index > @row_count
      @row_index = @row_count
    end

    return row
  end