class Sequel::DB2::Dataset

  1. lib/sequel/adapters/db2.rb
Parent: DB2

Included modules

  1. DatasetMethods

Constants

DatasetClass = self  
MAX_COL_SIZE = 256  

Attributes

convert_smallint_to_bool [W]

Override the default Sequel::DB2.convert_smallint_to_bool setting for this dataset.

Public Instance methods

convert_smallint_to_bool ()

Whether to convert smallint to boolean arguments for this dataset. Defaults to the DB2 module setting.

[show source]
# File lib/sequel/adapters/db2.rb, line 174
def convert_smallint_to_bool
  defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = DB2.convert_smallint_to_bool)
end
fetch_rows (sql)
[show source]
# File lib/sequel/adapters/db2.rb, line 181
def fetch_rows(sql)
  execute(sql) do |sth|
    db = @db
    i = 1
    column_info = get_column_info(sth)
    cols = column_info.map{|c| c.at(1)}
    @columns = cols
    errors = [DB2CLI::SQL_NO_DATA_FOUND, DB2CLI::SQL_ERROR]
    until errors.include?(rc = DB2CLI.SQLFetch(sth))
      db.check_error(rc, "Could not fetch row")
      row = {}
      column_info.each do |i, c, t, s, pr|
        v, _ = db.checked_error("Could not get data"){DB2CLI.SQLGetData(sth, i, t, s)}
        row[c] = if v == DB2CLI::Null
          nil
        elsif pr
          pr.call(v)
        else
          v
        end
      end
      yield row
    end
  end
  self
end