ruby-on-railsoracle-databasedual-table

How to search oracle db timezone in Ruby on Rails


I want to connect to oracle database in my ruby on rails application and i need to get db timezone with sql "select dbtimezone from dual"

I have the code

class Bug < ActiveRecord::Base
  establish_connection :bug

  def self.get_db_timezone
    return self.find_by_sql("select dbtimezone from dual")[0]
  end
end

When i call

ap Bug.get_db_timezone

I got string printed in my console

#<Bug:0x0000002339df28> {}

Which means i got nothing.

I have no way to get dual information from oracle in my RoR application. Please help and thank you in advance.


Solution

  • Fixed by myself by using this-

    db_timezone = self.find_by_sql("SELECT DBTIMEZONE tz FROM DUAL")[0].tz