Class | Sequel::DBI::Dataset
In: | lib/sequel/adapters/dbi.rb
Parent: | Sequel::Dataset

### Methods

fetch_rows

### Constants

DatasetClass | = | self

### Public Instance methods

fetch_rows(sql) {|row| ...}

[Source]

         # File lib/sequel/adapters/dbi.rb, line 89
     89:       def fetch_rows(sql)
     90:         execute(sql) do |s|
     91:           begin
     92:             columns = cols = s.column_names.map{|c| output_identifier(c)}
     93:             if opts[:offset] && offset_returns_row_number_column?
     94:               rn = row_number_column
     95:               columns = columns.dup
     96:               columns.delete(rn)
     97:             end
     98:             @columns = columns
     99:             s.fetch do |r|
    100:               row = {}
    101:               cols.each{|c| row[c] = r.shift}
    102:               row.delete(rn) if rn
    103:               yield row
    104:             end
    105:           ensure
    106:             s.finish rescue nil
    107:           end
    108:         end
    109:         self
    110:       end

[Validate]