Forum: Ruby on Rails OCI/ODBC on Windows

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Nikhil K. (Guest)
on 2005-12-29 00:12
I have been trying to connect to an Oracle database on a windows
machine. I succesfully ran a test program using ODBC to connect to
Oracle, but I am out of luck on doing this with rails.
I am unable to install the OCI Adapter on Windows and am trying to
figure it out. Meanwhile, if anyone could provide me with some pointers
or references, I would be grateful. I am finding it a bit difficult in
locating the right information.

Thanks,
Nikhil
Wilson B. (Guest)
on 2005-12-29 17:06
(Received via mailing list)
On 12/28/05, nikhil kurup <removed_email_address@domain.invalid> wrote:
> I have been trying to connect to an Oracle database on a windows
> machine. I succesfully ran a test program using ODBC to connect to
> Oracle, but I am out of luck on doing this with rails.
> I am unable to install the OCI Adapter on Windows and am trying to
> figure it out. Meanwhile, if anyone could provide me with some pointers
> or references, I would be grateful. I am finding it a bit difficult in
> locating the right information.
>
If you install the regular Oracle client (I use the 9i client,
personally), and then this library:
http://www.jiubao.org/ruby-oci8/
..you should be able to access anything defined in your TNSNAMES.ORA
file.
Try this to make sure it works, changing the username, password, and
SID to match one of your Oracle systems.

require 'oci8'
conn = OCI8.new('user_name', 'secret_passw0rd',
'SID_name_from_tnsnames')
if conn.exec("select * from dual").fetch[0] == "X"
  puts "Whee!"
else
  puts "Database connection failed sanity check."
end

On systems that don't have the proper environment variables set, you
may also need to do:
ENV["TNS_ADMIN"]='directory_with_tnsnames_file' before trying to
connect to something.
If you use the Windows installer, you shouldn't have a problem.
BEWARE: Most of the Oracle installers don't select the "Windows
Interfaces" (ODBC) by default.  You almost certainly need to choose a
'custom' install if you want to make use of those as well.
Note that the method I've sketched out above using the 'native' Oracle
interface, not ODBC.
Mathieu C. (Guest)
on 2005-12-29 18:53
(Received via mailing list)
> I am unable to install the OCI Adapter on Windows and am trying to
> figure it out.

Install just this file (in the rubyforge project's page) ignore the
full archive provided for building.

ruby-oci8-0.1.13-mswin.rb

Works here with 8i and standard client, not yet tested with
InstantClient.
This topic is locked and can not be replied to.