Class: DBI::DBD::OCI8::BindType::DBIDate

Inherits:
OCI8::BindType::OraDate show all
Defined in:
lib/dbd/OCI8.rb

Overview

helper class to define/bind DBI::Date.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decorate(b) ⇒ Object



526
527
528
529
530
531
532
533
534
535
536
537
# File 'lib/dbd/OCI8.rb', line 526

def decorate(b)
  def b.set(val)
    # convert val to an OraDate,
    # then set it to the bind handle.
    super(val && OraDate.new(val.year, val.month, val.day))
  end
  def b.get()
    # get an Oradate from the bind handle,
    # then convert it to a DBI::Date.
    (val = super()) && DBI::Date.new(val.year, val.month, val.day)
  end
end

.fix_type(env, val, length, precision, scale) ⇒ Object



522
523
524
525
# File 'lib/dbd/OCI8.rb', line 522

def fix_type(env, val, length, precision, scale)
  # bind as an OraDate
  [::OCI8::SQLT_DAT, val, nil]
end

Instance Method Details

#getObject



434
435
436
437
438
439
440
# File 'lib/dbd/OCI8.rb', line 434

def get()
  # get an Oradate from the bind handle,
  # then convert it to a DBI::Date.
  val = super()
  return nil if val.nil?
  DBI::Date.new(val.year, val.month, val.day)
end

#set(val) ⇒ Object



429
430
431
432
433
# File 'lib/dbd/OCI8.rb', line 429

def set(val)
  # convert val to an OraDate,
  # then set it to the bind handle.
  super(val && OraDate.new(val.year, val.month, val.day))
end