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?