Hey All,
I need to do some data-mashing w/non-rails data that lives on mssql & am trying to work out how to use activerecord to do it. I had thought to use either the .execute or .select methods of ActiveRecord::ConnectionAdapters::SQLServerAdapter, but the former is not acting as I'd hoped (returns just a Fixnum) and the latter throws a NoMethodError b/c .select is protected. Please see code below.
I'm running ruby 1.8.7 (2011-02-18 patchlevel 334) [i386-mingw32] on winxp, hitting an mssql 2005 db. Activerecord gem is v3.2.6 and activerecord-sqlserver-adapter is v3.2.9.
Am I just barking up the wrong tree, or should this be possible? If so--can anybody let me know how to e.g., loop through a result set & execute my own SELECT , DELETE & UPDATE statements?
Many thanks!
-Roy
P.S. Here's my script:
c = ab.establish_connection(
# This works w/out error, but x is a Fixnum w/value -1. How would I get at a resultset w/this?
x = c.execute("select count(*) as n from dbo.recruits")
# This gives the following error
# C:/Documents and Settings/pardre1/Desktop/deleteme.rb:17:
# protected method `select' called for #<ActiveRecord::ConnectionAdapters::SQLServerAdapter:0x2c1fc30> (NoMethodError)
# x = c.select("select count(*) as n from dbo.recruits")
# puts c.methods.sort.join("\n")