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

Inherits:
OCI8::BindType::OraDate
  • Object
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



510
511
512
513
514
515
516
517
518
519
520
521
# File 'lib/dbd/OCI8.rb', line 510

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



506
507
508
509
# File 'lib/dbd/OCI8.rb', line 506

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

Instance Method Details

#getObject



418
419
420
421
422
423
424
# File 'lib/dbd/OCI8.rb', line 418

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



413
414
415
416
417
# File 'lib/dbd/OCI8.rb', line 413

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