README.rdoc in tiny_tds-0.2.1 vs README.rdoc in tiny_tds-0.2.2

- old
+ new

@@ -110,10 +110,33 @@ Likewise for INSERT statements, the #insert method cancels any need for loading the result data and executes a SCOPE_IDENTITY() for the primary key. result = client.execute("INSERT INTO [datatypes] ([xml]) VALUES ('<html><br/></html>')") result.insert # => 420 +The result object can handle multiple result sets form batched SQL or stored procedures. It is critical to remember that when calling each with a block for the first time will return each "row" of each result set. Calling each a second time with a block will yield each "set". + + sql = ["SELECT TOP (1) [id] FROM [datatypes]", + "SELECT TOP (2) [bigint] FROM [datatypes] WHERE [bigint] IS NOT NULL"].join(' ') + + set1, set2 = client.execute(sql).each + set1 # => [{"id"=>11}] + set2 # => [{"bigint"=>-9223372036854775807}, {"bigint"=>9223372036854775806}] + + result = client.execute(sql) + + result.each do |rowset| + # First time data loading, yields each row from each set. + # 1st: {"id"=>11} + # 2nd: {"bigint"=>-9223372036854775807} + # 3rd: {"bigint"=>9223372036854775806} + end + + result.each do |rowset| + # Second time over (if columns cached), yields each set. + # 1st: [{"id"=>11}] + # 2nd: [{"bigint"=>-9223372036854775807}, {"bigint"=>9223372036854775806}] + end == Query Options Every TinyTds::Result object can pass query options to the #each method. The defaults are defined and configurable by setting options in the TinyTds::Client.default_query_options hash. The default values are: @@ -140,15 +163,17 @@ == Row Caching By default row caching is turned on because the SQL Server adapter for ActiveRecord would not work without it. I hope to find some time to create some performance patches for ActiveRecord that would allow it to take advantages of lazily created yielded rows from result objects. Currently only TinyTds and the Mysql2 gem allow such a performance gain. + == Using TinyTds With the ActiveRecord SQL Server adapter. -As of version 2.3.11 & 3.0.3 of the adapter, you can specify a :dblib mode in database.yml and use TinyTds as the low level connection mode. Make sure to add a :dataserver option to that matches the name in your freetds.conf file. The SQL Server adapter can be found here. +As of version 2.3.11 & 3.0.3 of the adapter, you can specify a :dblib mode in database.yml and use TinyTds as the low level connection mode. Make sure to add a :dataserver option to that matches the name in your freetds.conf file. The SQL Server adapter can be found using the link below. Also included is a direct link to the wiki article covering common questions when using TinyTds as the low level connection mode for the adapter. http://github.com/rails-sqlserver/activerecord-sqlserver-adapter +http://github.com/rails-sqlserver/activerecord-sqlserver-adapter/wiki/Using-TinyTds == Development & Testing @@ -158,9 +183,10 @@ For help and support. * Github Source: http://github.com/rails-sqlserver/tiny_tds * Github Issues: http://github.com/rails-sqlserver/tiny_tds/issues +* Google Group: http://groups.google.com/group/rails-sqlserver-adapter * IRC Room: #rails-sqlserver on irc.freenode.net Current to do list. * Test 0.83 development of FreeTDS.