class OCI8::BindType::IntervalYM
.strftime(‘%Y-%m-%d’) # => 1970-03-19
cursor.exec
cursor.bind_param(:interval, 4, :interval_ym)
cursor.bind_param(:ts2, Date.parse(‘1969-11-19’))
cursor.bind_param(:ts1, nil, DateTime)
EOS
END;
:ts1 := :ts2 + :interval;
BEGIN
cursor = conn.parse(<<-EOS)
# input bind variable<br><br>cursor.close<br>cursor # => 4 (months)
cursor.exec
cursor.bind_param(:ts2, DateTime.parse(‘1969-07-20 20:17:40 00:00’))
cursor.bind_param(:ts1, DateTime.parse(‘1969-11-19 06:54:35 00:00’))
cursor.bind_param(:interval, nil, :interval_ym)
EOS
END;
:interval := (:ts1 - :ts2) YEAR TO MONTH;
BEGIN
cursor = conn.parse(<<-EOS)
# output bind variable
It must be bound explicitly by OCI8::Cursor#bind_param.
You cannot bind a bind variable as INTERVAL YEAR TO MONTH
implicitly.
== How to bind INTERVAL YEAR TO MONTH
end
puts “hired_months = #{hired_months}”
conn.exec(“select (current_timestamp - hiredate) year to month from emp”) do |hired_months|INTERVAL YEAR TO MONTH
is selected as an Integer.
=== How to select INTERVAL YEAR TO MONTH
been loaded.
It can be applied to Time#months_since if activisupport has
The value can be applied to DateTime#>> to shift months.
the number of months between two timestamps.INTERVAL YEAR TO MONTH
. The retrieved value is
This is a helper class to select or bind Oracle data type
++
OCI8::BindType::IntervalYM
–
def get() # :nodoc:
def get() # :nodoc: val = super() return nil if val.nil? year, month = val year * 12 + month end
def set(val) # :nodoc:
def set(val) # :nodoc: unless val.nil? val = [val / 12, val % 12] end super(val) end