Class | Sequel::IBMDB::Dataset
In: | lib/sequel/adapters/ibmdb.rb
Parent: | Sequel::Dataset

### Methods

call convert_smallint_to_bool fetch_rows prepare

### Included Modules

Sequel::DB2::DatasetMethods

### Classes and Modules

Module Sequel::IBMDB::Dataset::CallableStatementMethods
Module Sequel::IBMDB::Dataset::PreparedStatementMethods

### Constants

DatasetClass | = | self

### Attributes

convert_smallint_to_bool | [W] | Override the default 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.

[Source]

         # File lib/sequel/adapters/ibmdb.rb, line 389
    389:       def call(type, bind_arguments={}, *values, &block)
    390:         ps = to_prepared_statement(type, values)
    391:         ps.extend(CallableStatementMethods)
    392:         ps.call(bind_arguments, &block)
    393:       end

convert_smallint_to_bool()

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

[Source]

         # File lib/sequel/adapters/ibmdb.rb, line 397
    397:       def convert_smallint_to_bool
    398:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = IBMDB.convert_smallint_to_bool)
    399:       end

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

Fetch the rows from the database and yield plain hashes.

[Source]

         # File lib/sequel/adapters/ibmdb.rb, line 405
    405:       def fetch_rows(sql)
    406:         execute(sql) do |stmt|
    407:           offset = @opts[:offset]
    408:           columns = []
    409:           convert = convert_smallint_to_bool
    410:           cps = db.conversion_procs
    411:           stmt.num_fields.times do |i|
    412:             k = stmt.field_name i
    413:             key = output_identifier(k)
    414:             type = stmt.field_type(k).downcase.to_sym
    415:             # decide if it is a smallint from precision
    416:             type = :boolean  if type ==:int && convert && stmt.field_precision(k) < 8
    417:             columns << [key, cps[type]]
    418:           end
    419:           cols = columns.map{|c| c.at(0)}
    420:           cols.delete(row_number_column) if offset
    421:           @columns = cols
    422:
    423:           while res = stmt.fetch_array
    424:             row = {}
    425:             res.zip(columns).each do |v, (k, pr)|
    426:               row[k] = ((pr ? pr.call(v) : v) if v)
    427:             end
    428:             row.delete(row_number_column) if offset
    429:             yield row
    430:           end
    431:         end
    432:         self
    433:       end

prepare(type, name=nil, *values)

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

[Source]

         # File lib/sequel/adapters/ibmdb.rb, line 437
    437:       def prepare(type, name=nil, *values)
    438:         ps = to_prepared_statement(type, values)
    439:         ps.extend(PreparedStatementMethods)
    440:         if name
    441:           ps.prepared_statement_name = name
    442:           db.prepared_statements[name] = ps
    443:         end
    444:         ps
    445:       end

[Validate]