We’re using Oracle at my current project. I wanted to run some reporting scripts on the database to do some nice graphs with Graphviz and yEd. “Well, that’s been done before, should be pretty easy to hook up ActiveRecord to Oracle”, I thought.
It turns out that’s nearly impossible to do on an Intel Mac running the x86 version of Ruby, since the Oracle Instant Client SDK only ships with PowerPC binaries so far (hence the title). Unless you recompile your whole Ruby install to PPC, something that to me sits somewhere between unspeakable and atrocious, you can’t link to its libraries, as far as I can tell.
But you can get SQLPlus to run on Rosetta. And you can get SQLPlus to spit out reasonably parseable HTML. And it’ll run slow – but for a quick-n-dirty report that you want to generate once every couple of months or so, it’s… ok.
def select_all(sql)
html = `echo "#{sql};" | sqlplus -r 3 -l -s -m "html on entmap on" #{@user}/#{@password}@#{@host}`
doc = Hpricot(html)
(doc/'tr').collect do |tr|
(tr/'td').collect do |td|
td.innerText.strip if td.innerText
end if (tr/'td').size == (doc/'tr/th').collect do |th|
th.innerText.strip if th.innerText
end.uniq.size
end.compact
end
Look what you made me do, Oracle. You should be ashamed. As you can see, though, I’m not that easily embarrassed. Some people wouldn’t ever show this code to anyone, and deny its existence at all possible cost. I think it’s worth the shock value, though. ![]()

C. S. | 23-Apr-07 at 3:45 pm | Permalink
Never tried on the MAC, but if you have sqlplus, ruby and OCI8 (http://rubyforge.org/projects/ruby-oci8/) you should be able to use Active Record. OCI8 serves as a translation layer that runs on top of the Oracle client.
Carlos Villela | 23-Apr-07 at 4:19 pm | Permalink
Thanks for the pointer to ruby-oci8. It’s the library I was trying to install when I noticed that it only works on PowerPC Macs (or Macs with the PowerPC version of Ruby running, in general).
bartocc | 23-Apr-07 at 5:47 pm | Permalink
Unfortunately, Carlos is right, OCI8 cannot be used with the Oracle PPC client on an intel Mac.
I really can’t believe Oracle integrates so badly with OS X. This makes activerecord, and hense Rails, almost unusable on a mac for an Oracle database.
I am about to do what Carlos mentioned above, use a PPC version Ruby through rosetta, but I really doubt I’ll be happy with this solution.
Thanks Oracle !
T | 23-Apr-07 at 6:43 pm | Permalink
Then you miss JDBC
Carlos Villela | 24-Apr-07 at 9:02 am | Permalink
Well, yeah – JDBC would be nice. In fact, you can use JDBC if you’re using JRuby:
https://rubyforge.org/projects/jruby-extras/
Mistaeks I Hav Made | 24-Apr-07 at 9:18 am | Permalink
Scrapheap Challenge at SPA2007, part 3: Name that Tune…
The second challenge in the SPA 2007 Scrapheap Challenge workshop was: A Christmas Quiz Game. I want a quiz game to play at Christmas. The most important feature is that I don’t want to have to prepare the quiz beforehand…….
Jon Tirsen | 29-Apr-07 at 9:33 pm | Permalink
As you pointed out yourself, you should really give JRuby a try. ActiveRecord-JDBC is damn close to being production ready. There are minor incompatibility issues being worked out with different databases but for something as basic as “select_all” it should just work. (The issues are mostly related to things not covered in the JDBC spec such as representation of booleans, DDL, typecasts and so forth.)
Raimonds | 29-Aug-07 at 5:38 pm | Permalink
I have published description how to setup Ruby with PowerPC Oracle Instant Client on Intel Mac at
http://rayapps.wordpress.com/2007/08/27/how-to-setup-ruby-and-oracle-client-on-intel-mac/
This solution works for me while I am waiting for new Oracle Instant Client for Intel Mac.