# Ruby with Oracle problem

**URL:** <https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474>\
**Category:** Rails\
**Created:** [February 7, 2008, 11:48pm UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474 "2008-02-07T23:48:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![lxp149](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@lxp149](https://www.ruby-forum.com/u/lxp149)\
**Post date:** [February 7, 2008, 11:48pm UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474/1 "2008-02-07T23:48:21Z")

</div>

I installed Ruby with Oracle 10g and ran the ruby …mswin.rb for  
oracle following the Oracle Ruby FAQ. But then when I try to test the  
connection using the following command

ruby -r oci8 -e “OCI8.new(‘cm’,‘pass’,‘databasename’).exec(‘SELECT \*  
FROM PLATFORMS’);” it returns nothing from the database. I’m not  
getting any TNSListner errors. Not error messages what so ever, but no  
data either. HELP!!!

---

<div class="post-metadata">

**Author:** ![lxp149](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@lxp149](https://www.ruby-forum.com/u/lxp149)\
**Post date:** [February 8, 2008, 12:31am UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474/2 "2008-02-08T00:31:14Z")

</div>

I had problems with the connection at first too. Here is what I am  
using:

development:  
adapter: oci  
host: 192.168.2.1/SID\_NAME.world  
username: userId1  
password: password1

The host included not just the SID, but the entire oracle service  
name (that .world thing).

---

<div class="post-metadata">

**Author:** ![lxp149](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@lxp149](https://www.ruby-forum.com/u/lxp149)\
**Post date:** [February 8, 2008, 6:11am UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474/3 "2008-02-08T06:11:25Z")

</div>

Thanks for the reply. I’ll try it, but I don’t think database.rb would  
make a difference if I’m running ruby from command line just to test  
the database connection. Any other ideas?

---

<div class="post-metadata">

**Author:** ![lxp149](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@lxp149](https://www.ruby-forum.com/u/lxp149)\
**Post date:** [February 18, 2008, 10:46am UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474/4 "2008-02-18T10:46:19Z")

</div>

Hi,

No error message means you have connected to Oracle db successfully.  
The following command will show the data you want:  
ruby -r oci8 -e “OCI8.new(‘cm’,‘pass’,‘databasename’).exec(‘SELECT \*  
FROM PLATFORMS’) _do |r| puts r.join(‘,’); end_”

2008/2/8, lxp149 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> > development:
> > 
> > - Show quoted text -

–  
Best regards,  
Jesse

---

<div class="post-metadata">

**Author:** ![lxp149](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@lxp149](https://www.ruby-forum.com/u/lxp149)\
**Post date:** [February 23, 2008, 7:11am UTC](https://www.ruby-forum.com/t/ruby-with-oracle-problem/128474/5 "2008-02-23T07:11:33Z")

</div>

Wow this was confusing. i figured out that not only do you have to run  
the mswin.rb oracle adapter, but you also have to manually copy the  
oracle\_adapter.rb to the proper activerecord directory (where all the  
other database adapters are located). Only with both of those things  
in place, can you run a ruby application over oracle. if you only  
install the mswin oracle adapter, you can only execute sql queries  
from ruby from command line without errors, but you won’t be able to  
successfully run the generate script.

Anyway thanks for the reply. This problem was even sillier because I  
didn’t understand the ruby language at the time and had no idea that  
“puts” was the same as printf, so I wasn’t actually printing anything  
out 😃
