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

Inherits:
OCI8::BindType::OraDate
  • Object
show all
Defined in:
lib/DBD/OCI8/OCI8.rb

Overview

helper class to define/bind DBI::Date.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.decorate(b) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
495
# File 'lib/DBD/OCI8/OCI8.rb', line 484

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



480
481
482
483
# File 'lib/DBD/OCI8/OCI8.rb', line 480

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

Instance Method Details

#getObject



392
393
394
395
396
397
398
# File 'lib/DBD/OCI8/OCI8.rb', line 392

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



387
388
389
390
391
# File 'lib/DBD/OCI8/OCI8.rb', line 387

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