Tuesday, August 7, 2012

using oci8 with rhoConnect

require 'rubygems'
require 'oci8'

Must remember to use 32 bit oracle client.

Manual install the ruby gem buy using

http://help.rubygems.org/kb/rubygems/installing-gems-with-no-network

I'm using a Windows 2010 64 bit server.

I got my technical staff to install the Oracle Client.  But that was the 64 bit client and is not compatible with the oci8 package.  So had to install the 32bit client.  Make sure is on the path.

Start irb

irb: require 'rubygems'
irb: require 'oci8'

then run:

OCI8.new( 'username', 'password','database-name').exec( 'select * from user_tables' ) {|r| puts r.join }

to test it.  Setting the environment variable oracle_sid is not required.   Database-name will be found using the oracle tnsnames.ora file ( I think).

That works in the irb.  Rhoconenct requires a few more steps.

To get it to work in RhoConnect


  1. open your Gemfile in your application root.
  2. Just under the top line add: gem 'ruby-oci8'
  3. goto to a cmd prompt in your application root.
  4. run bundle install
  5. oracle will now connect!

No comments:

Post a Comment