On Sun, 2002-10-06 at 23:06, doug.tillman / attbi.com wrote:
> Hi,
> I'm a Ruby new-bee and am working on a simple DBI
> example.  I just want to get sysdate back from my Oracle
> instance and print it to screen.
> 
> It seems like I'm connecting successfully but I don't
> know how to read the result back properly.  Below is the
> code I'm using - any help appreciated.

For this kind of SQL query, method select_one of class DatabaseHandle is
probably the best choice. 
See the example below:


require 'dbi'
 
class Dbitest

  attr :today_str

  def initialize
    DBI.connect('DBI:Oracle:fqa1', 'my_username', 'my_pwd') do |dbh|
      @today_str = dbh.select_one("select to_char(sysdate + 1,
                                   'MON-DD-YYYY') today_str from dual")
    end 
  end

end  # Dbitest

d = Dbitest.new
print "today: #{d.today_str}"



Regards,

  Michael