# DBI/unixODBC/FreeTDS weird problems on Linux

**URL:** <https://www.ruby-forum.com/t/dbi-unixodbc-freetds-weird-problems-on-linux/77119>\
**Category:** Rails\
**Created:** [November 24, 2006, 1:17pm UTC](https://www.ruby-forum.com/t/dbi-unixodbc-freetds-weird-problems-on-linux/77119 "2006-11-24T13:17:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [November 24, 2006, 1:17pm UTC](https://www.ruby-forum.com/t/dbi-unixodbc-freetds-weird-problems-on-linux/77119/1 "2006-11-24T13:17:33Z")

</div>

Hey 🙂

I’m trying to migrate my rails app that uses an MS SQL server to Linux.  
I’ve setup freetds and unixodbc, installed ruby-dbi and ruby-odbc. isql  
and tsql work fine with this query:

SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)

## This query is taken from the error html output of my app when hitting the page that executes that query. It fails stating that,

## ActiveRecord::StatementInvalid in ItemsController#show DBI::DatabaseError: INTERN (0) [RubyODBC]No data found: SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)

## Opening a console in RadRails and doing the same,

Loading development environment.

> > dbh = DBI.connect(‘dbi:ODBC:PolyBookDSN’, ‘sa’, ‘adminpassword’)  
> > dbh = DBI.connect(‘dbi:ODBC:PolyBookDSN’, ‘sa’, ‘adminpassword’)  
> > =\> #\<DBI::DatabaseHandle:0xb747063c @trace\_mode=2,  
> > @handle=#\<DBI::DBD::ODBC::Database:0xb7470434 @attr={},  
> > @handle=#ODBC::Database:0xb7470470\>, @trace\_output=#IO:0xb7cf0028\>
> 
> > dbh.execute(“SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)”)  
> > dbh.execute(“SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber =  
> > ‘9780444422286’)”)  
> > =\> #\<DBI::StatementHandle:0xb74542fc @cols=[“Itemnumber”, “ISBNP”,  
> > “ItemType”, “TitlePrefix”, “TitleMain”, “TitleVolumeNo”, “TitleVolume”,  
> > “TitleSub”, “TitleSeries”, “TitleSeriesVolumeNo”, “Edition”, “Imprint”,  
> > “ImprintID”, “PublisherID”, “PublisherType”, “DescrLong”, “DescrPoly”,  
> > “Contents”, “KeyWordsBG”, “KeyWordsTitle”, “BookFeatured”,  
> > “AvailStatusCode”, “PublicationDate”, “MarketCode”, “PriceBasis”,  
> > “PriceDiscounted”, “PostageFree”, “DataSourceID”, “ItemGroup”,  
> > “LineDiscGroup”, “Blocked”, “Popularity”, “TrashType”], @trace\_mode=2,  
> > @prepared=false, @handle=#\<DBI::DBD::ODBC::Statement:0xb7454248  
> > @arr=[], @params=[], @handle=#ODBC::Statement:0xb7454284\>,  
> > @fetchable=true, @row=[nil, nil, nil, nil, nil, nil, nil, nil, nil,  
> > nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,  
> > nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],  
> > @trace\_output=#IO:0xb7cf0028\>

* * *

So, there’s connectivity, the column names are there, but the data is  
empty. Doing the query in isql using the same DSN, I get data, too…

What am I missing?

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [February 15, 2007, 11:17pm UTC](https://www.ruby-forum.com/t/dbi-unixodbc-freetds-weird-problems-on-linux/77119/2 "2007-02-15T23:17:54Z")

</div>

I’m having the same class of problem on Solaris using  
FreeTDS/UnixODBC/RubyODBC. Doing something as simple as  
Roster.find(:all) will return the error:

ActiveRecord::StatementInvalid: DBI::DatabaseError: INTERN (0)  
[RubyODBC]No data found: SELECT \* FROM roster

BUT, if you do Roster.find(:first), it finds the first record, no  
problem. Also, doing “SELECT \* FROM roster” using the command line tool  
that froms with FreeTDS works fine as well.

I can’t determine if this is a RubyODBC problem or something with Rails.

The database table “roster” is fairly large, but not unreasonable at  
29926 rows.

Daniel Smedegaard B. wrote:

> Hey 🙂
> 
> I’m trying to migrate my rails app that uses an MS SQL server to Linux.  
> I’ve setup freetds and unixodbc, installed ruby-dbi and ruby-odbc. isql  
> and tsql work fine with this query:
> 
> SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)
> 
> ## This query is taken from the error html output of my app when hitting the page that executes that query. It fails stating that,
> 
> ## ActiveRecord::StatementInvalid in ItemsController#show DBI::DatabaseError: INTERN (0) [RubyODBC]No data found: SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)
> 
> ## Opening a console in RadRails and doing the same,
> 
> Loading development environment.
> 
> > > dbh = DBI.connect(‘dbi:ODBC:PolyBookDSN’, ‘sa’, ‘adminpassword’)  
> > > dbh = DBI.connect(‘dbi:ODBC:PolyBookDSN’, ‘sa’, ‘adminpassword’)  
> > > =\> #\<DBI::DatabaseHandle:0xb747063c @trace\_mode=2,  
> > > @handle=#\<DBI::DBD::ODBC::Database:0xb7470434 @attr={},  
> > > @handle=#ODBC::Database:0xb7470470\>, @trace\_output=#IO:0xb7cf0028\>
> > 
> > > dbh.execute(“SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber = ‘9780444422286’)”)  
> > > dbh.execute(“SELECT TOP 1 \* FROM Item WHERE (Item.Itemnumber =  
> > > ‘9780444422286’)”)  
> > > =\> #\<DBI::StatementHandle:0xb74542fc @cols=[“Itemnumber”, “ISBNP”,  
> > > “ItemType”, “TitlePrefix”, “TitleMain”, “TitleVolumeNo”, “TitleVolume”,  
> > > “TitleSub”, “TitleSeries”, “TitleSeriesVolumeNo”, “Edition”, “Imprint”,  
> > > “ImprintID”, “PublisherID”, “PublisherType”, “DescrLong”, “DescrPoly”,  
> > > “Contents”, “KeyWordsBG”, “KeyWordsTitle”, “BookFeatured”,  
> > > “AvailStatusCode”, “PublicationDate”, “MarketCode”, “PriceBasis”,  
> > > “PriceDiscounted”, “PostageFree”, “DataSourceID”, “ItemGroup”,  
> > > “LineDiscGroup”, “Blocked”, “Popularity”, “TrashType”], @trace\_mode=2,  
> > > @prepared=false, @handle=#\<DBI::DBD::ODBC::Statement:0xb7454248  
> > > @arr=[], @params=[], @handle=#ODBC::Statement:0xb7454284\>,  
> > > @fetchable=true, @row=[nil, nil, nil, nil, nil, nil, nil, nil, nil,  
> > > nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,  
> > > nil, nil, nil, nil, nil, nil, nil, nil, nil, nil],  
> > > @trace\_output=#IO:0xb7cf0028\>
> 
> * * *
> 
> So, there’s connectivity, the column names are there, but the data is  
> empty. Doing the query in isql using the same DSN, I get data, too…
> 
> What am I missing?

---

<div class="post-metadata">

**Author:** ![danielb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/c57346/32.png) [@danielb](https://www.ruby-forum.com/u/danielb)\
**Post date:** [February 21, 2007, 12:07am UTC](https://www.ruby-forum.com/t/dbi-unixodbc-freetds-weird-problems-on-linux/77119/3 "2007-02-21T00:07:22Z")

</div>

Hi, I was having the same problem and found a fix(so to speak) here:

[http://groups.google.com.au/group/rubyonrails-talk/browse\_thread/thread/82db43270d2a0d59/2aa97ff83907fdc3?lnk=st&q=DBI%3A%3ADatabaseError%3A+INTERN+(0)+[RubyODBC]+No+data+found&rnum=3&hl=en#2aa97ff83907fdc3](http://groups.google.com.au/group/rubyonrails-talk/browse_thread/thread/82db43270d2a0d59/2aa97ff83907fdc3?lnk=st&q=DBI%3A%3ADatabaseError%3A+INTERN+(0)+%5BRubyODBC%5D+No+data+found&rnum=3&hl=en#2aa97ff83907fdc3)

Brad

On Feb 16, 9:17 am, David M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
