Q:

Ruby dbi select statement returning BigDecimal?

I'm having trouble using ruby with dbi for some reason, I'm trying to do a select and put the results in an array but no luck.
require 'dbi'

db = DBI.connect('DBI:OCI8:database', XXXX, XXXX)

#Gets Consumer Id Number you want to create accounts for
numberOfAccounts = []
puts("Please enter a CID")
NewCID = gets.chomp()
numberOfAccounts << db.execute("select T_NBR from T_CBA where C_ID='#{NewCID}'").fetch

My array ends up like this:
[[<#BigDecimal:fc115f8,'0.8000169202 2E11',12(16)>]]

where I would like to have several different numbers like [222, 3232, 2323] etc.
I've searched online but to no avail.

A:

DBI has probably determined that the underlying column can contain integers too large to fit in a regular int type, based on the data field.  Or it may just use BigDecimal for all integer types to avoid worrying about it.  
If you know that your values are all small enough to fit into a regular integer, you can convert the array to integers after you've populated it, like so:
1.9.3-p194 :014 > numberOfAccounts
=> [[#<BigDecimal:119cd90,'0.123E3',9(36)>], [#<BigDecimal:119cd18,'0.456E3',9(36)>]] 
1.9.3-p194 :015 > numberOfAccounts.flatten!.collect!(&:to_i)
=> [123, 456] 
1.9.3-p194 :016 > numberOfAccounts
=> [123, 456] 

