简体   繁体   中英

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.

我自己通过使用此方法修复了-

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM