# DBI Oracle error

**URL:** <https://rubytalk.org/t/dbi-oracle-error/18846>\
**Category:** ruby-talk\
**Created:** [7 June 2005 21:19 UTC](https://rubytalk.org/t/dbi-oracle-error/18846 "2005-06-07T21:19:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Berger\_Daniel1](https://avatars.discourse-cdn.com/v4/letter/b/ecc23a/32.png) [@Berger\_Daniel1](https://rubytalk.org/u/Berger_Daniel1)\
**Post date:** [7 June 2005 21:19 UTC](https://rubytalk.org/t/dbi-oracle-error/18846/1 "2005-06-07T21:19:47Z")

</div>

I'm not sure what to tell you Graham. One thing I would try is  
explicitly converting the floats to strings using sprintf (or  
whatever), so you can set the precision, then calling to\_number() on  
those values. See if that helps.

Regards,

Dan

> **···**
>
> > -----Original Message-----  
> > From: graham [mailto:fghfghfh@homr.vom]  
> > Sent: Tuesday, June 07, 2005 2:15 PM  
> > To: ruby-talk ML  
> > Subject: Re: DBI Oracle error
> > 
> > Berger, Daniel wrote:  
> > \> My (possibly wrong) initial guess would be a precision  
> > error of some  
> > \> sort in conjunction with Ruby's .to\_f. Double check the the column  
> > \> types (presumably a NUMBER) and see what the precision is  
> > set to. The  
> > \> column precision \*is\* set, right?  
> > Nope - not explicitly. The column is just defined as NUMBER.  
> > If this was  
> > the problem - how come  
> > a) almost identical data lines either side work correctly  
> > b) running the data thorough again will correctly insert the  
> > offending  
> > row into the database (other rows fail to insert due to filing a  
> > uniqueness constraint on the datetime column)
> > 
> > I'm perplexed. I don't have a real debugger for Ruby.. just  
> > the built in  
> > one (which is a bit painful to use).  
> > Graham

---

<div class="post-metadata">

**Author:** ![Graham1](https://avatars.discourse-cdn.com/v4/letter/g/8baadc/32.png) [@Graham1](https://rubytalk.org/u/Graham1)\
**Post date:** [10 June 2005 11:55 UTC](https://rubytalk.org/t/dbi-oracle-error/18846/2 "2005-06-10T11:55:28Z")

</div>

My first attempt at debugging adopts your idea, so for the  
parameterised insert of:  
sth = dbh.prepare("INSERT INTO EFFLUENT\_LOG (datetime, suspect, flow,  
temp, ph) VALUES(to\_date(?, 'DD/MM/YY HH24:MI:SS'), ?, ?, ?, ?)");

I now run on a row by row basis:-  
sth.execute((date + " " + time), val, sprintf("%3.1f",flow.to\_f).to\_f,  
sprintf("%4.2f", temp.to\_f).to\_f, sprintf("%5.2f",ph.to\_f).to\_f)  
whic smacks of paranoia in my book. However still get exactly the same  
failures. (BTW The suspect field is a single character 'Y' or 'N' )

I'm beginning to think DBI for Oracle is extremely buggy.

Any suggestions for an alternative interface to Oracle, or ideas what  
the problem might be?  
Regards  
Graham
