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

Methods

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

Emulate support of bind arguments in called statements.

[Source]

     # File lib/sequel/adapters/ibmdb.rb, line 412
412:       def call(type, bind_arguments={}, *values, &block)
413:         ps = to_prepared_statement(type, values)
414:         ps.extend(CallableStatementMethods)
415:         ps.call(bind_arguments, &block)
416:       end

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

[Source]

     # File lib/sequel/adapters/ibmdb.rb, line 420
420:       def convert_smallint_to_bool
421:         defined?(@convert_smallint_to_bool) ? @convert_smallint_to_bool : (@convert_smallint_to_bool = IBMDB.convert_smallint_to_bool)
422:       end

Fetch the rows from the database and yield plain hashes.

[Source]

     # File lib/sequel/adapters/ibmdb.rb, line 428
428:       def fetch_rows(sql)
429:         execute(sql) do |stmt|
430:           columns = []
431:           convert = convert_smallint_to_bool
432:           cps = db.conversion_procs
433:           stmt.num_fields.times do |i|
434:             k = stmt.field_name i
435:             key = output_identifier(k)
436:             type = stmt.field_type(k).downcase.to_sym
437:             # decide if it is a smallint from precision
438:             type = :boolean  if type ==:int && convert && stmt.field_precision(k) < 8
439:             columns << [key, cps[type]]
440:           end
441:           cols = columns.map{|c| c.at(0)}
442:           @columns = cols
443: 
444:           while res = stmt.fetch_array
445:             row = {}
446:             res.zip(columns).each do |v, (k, pr)|
447:               row[k] = ((pr ? pr.call(v) : v) if v)
448:             end
449:             yield row
450:           end
451:         end
452:         self
453:       end

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

[Source]

     # File lib/sequel/adapters/ibmdb.rb, line 457
457:       def prepare(type, name=nil, *values)
458:         ps = to_prepared_statement(type, values)
459:         ps.extend(PreparedStatementMethods)
460:         if name
461:           ps.prepared_statement_name = name
462:           db.set_prepared_statement(name, ps)
463:         end
464:         ps
465:       end

[Validate]