# Ruby DBI class

**URL:** <https://www.ruby-forum.com/t/ruby-dbi-class/139979>\
**Category:** Ruby\
**Created:** [June 9, 2008, 7:40pm UTC](https://www.ruby-forum.com/t/ruby-dbi-class/139979 "2008-06-09T19:40:14Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 9, 2008, 7:40pm UTC](https://www.ruby-forum.com/t/ruby-dbi-class/139979/1 "2008-06-09T19:40:14Z")

</div>

Hi all!

I’m using the Ruby DBI class to create connections to both a MSSQL and  
an Oracle database to verify the data migration between them is  
successful. My test works fine on XP, but on Vista (currently with  
SP1, but my problem has always happened on Vista), I get a  
segmentation fault when I perform my first select statement on the  
Oracle database. Select statements are performed against the MSSQL  
database prior to the Oracle database and work fine. I’m running the  
test from a command prompt that has administrator privileges.

- Here’s my Oracle connection:

@ora\_connect = DBI.connect(“DBI:ADO:Provider=OraOLEDB.Oracle;Data  
Source=devserver;User Id=read\_all;Password=password”)

- Here is my method for running a select statement:

def getDBValue(connection, query, id1, \*id2)  
dbi\_query = connection.prepare(query)  
dbi\_query.execute(id1, \*id2)  
#fetch the result  
return dbi\_query.fetch  
end

- Here is the first Oracle select statement:

createDateTime = getDBValue(@ora\_connect, “SELECT CREATED\_TIME FROM  
ORATEST.POLICY WHERE POLICYNUM = ?”, policyNumber)

- Here is the error message I get:

c:/ruby/lib/ruby/site\_ruby/1.8/DBD/ADO/ADO.rb:94: [BUG] Segmentation  
fault ruby 1.8.6 (2007-03-13) [i386-mswin32]

Has anyone else seen this? Does anyone have any ideas on workarounds  
or how to fix it?

Thanks in advance for your help!

-Tiffany

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 9, 2008, 10:15pm UTC](https://www.ruby-forum.com/t/ruby-dbi-class/139979/2 "2008-06-09T22:15:11Z")

</div>

On Jun 9, 11:33 am, removed\_email\_address@domain.invalid wrote:

> ```
> #fetch the result
> 
> ```
> 
> c:/ruby/lib/ruby/site\_ruby/1.8/DBD/ADO/ADO.rb:94: [BUG] Segmentation  
> fault ruby 1.8.6 (2007-03-13) [i386-mswin32]
> 
> Has anyone else seen this? Does anyone have any ideas on workarounds  
> or how to fix it?
> 
> Thanks in advance for your help!

What version of Ruby and DBI are you using? Line 94 of my ADO.rb file  
is just a comment. Can you paste that line at least?

Thanks,

Dan

---

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [June 10, 2008, 1:12am UTC](https://www.ruby-forum.com/t/ruby-dbi-class/139979/3 "2008-06-10T01:12:24Z")

</div>

On Jun 9, 1:35 pm, Daniel B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> > segmentation fault when I perform my first select statement on the
> 
> > ORATEST.POLICY WHERE POLICYNUM = ?", policyNumber)
> 
> What version of Ruby and DBI are you using? Line 94 of my ADO.rb file  
> is just a comment. Can you paste that line at least?
> 
> Thanks,
> 
> Dan

Sorry about that - I’m using Ruby version 1.8.6 and DBI version 0.1.1

Here’s the code around line 94:

90 def execute  
91 # TODO: use Command and Parameter  
92 # TODO: substitute all ? by the parametes  
93 sql = bind(self, @statement, @params)  
94 @res\_handle = @handle.Execute(sql)  
95  
96 # TODO: SELECT and AutoCommit finishes the result-set  
97 # what to do?  
98 if @db[‘AutoCommit’] == true and not SQL.query?(@statement)  
then  
99 @db.commit  
100 end

101 rescue RuntimeError =\> err  
102 raise DBI::DatabaseError.new(err.message)  
103 end

Thanks for taking at look at this!

-Tiffany
