class Sequel::IBMDB::Dataset

  1. lib/sequel/adapters/ibmdb.rb
Parent: IBMDB

Included modules

  1. Sequel::DB2::DatasetMethods

Constants

DatasetClass = self  

Attributes

convert_smallint_to_bool [W]

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

Public Instance methods

call (type, bind_arguments={}, *values, &block)

Emulate support of bind arguments in called statements.

[show source]
# File lib/sequel/adapters/ibmdb.rb, line 412
def call(type, bind_arguments={}, *values, &block)
  ps = to_prepared_statement(type, values)
  ps.extend(CallableStatementMethods)
  ps.call(bind_arguments, &block)
end
convert_smallint_to_bool ()

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

[show source]
# File lib/sequel/adapters/ibmdb.rb, line 420
def convert_smallint_to_bool
  defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = IBMDB.convert_smallint_to_bool)
end
fetch_rows (sql)

Fetch the rows from the database and yield plain hashes.

[show source]
# File lib/sequel/adapters/ibmdb.rb, line 428
def fetch_rows(sql)
  execute(sql) do |stmt|
    columns = []
    convert = convert_smallint_to_bool
    cps = db.conversion_procs
    stmt.num_fields.times do |i|
      k = stmt.field_name i
      key = output_identifier(k)
      type = stmt.field_type(k).downcase.to_sym
      # decide if it is a smallint from precision
      type = :boolean  if type ==:int && convert && stmt.field_precision(k) < 8
      columns << [key, cps[type]]
    end
    cols = columns.map{|c| c.at(0)}
    @columns = cols

    while res = stmt.fetch_array
      row = {}
      res.zip(columns).each do |v, (k, pr)|
        row[k] = ((pr ? pr.call(v) : v) if v)
      end
      yield row
    end
  end
  self
end
prepare (type, name=nil, *values)

Store the given type of prepared statement in the associated database with the given name.

[show source]
# File lib/sequel/adapters/ibmdb.rb, line 457
def prepare(type, name=nil, *values)
  ps = to_prepared_statement(type, values)
  ps.extend(PreparedStatementMethods)
  if name
    ps.prepared_statement_name = name
    db.set_prepared_statement(name, ps)
  end
  ps
end