Module | Sequel::ADO::MSSQL::DatabaseMethods |
In: |
lib/sequel/adapters/ado/mssql.rb
|
ROWS_AFFECTED | = | "SELECT @@ROWCOUNT AS AffectedRows" | Query to use to get the number of rows affected by an update or delete query. |
Return instance of Sequel::ADO::MSSQL::Dataset with the given opts.
# File lib/sequel/adapters/ado/mssql.rb, line 15 15: def dataset(opts=nil) 16: Sequel::ADO::MSSQL::Dataset.new(self, opts) 17: end
Just execute so it doesn‘t attempt to return the number of rows modified.
# File lib/sequel/adapters/ado/mssql.rb, line 20 20: def execute_ddl(sql, opts={}) 21: execute(sql, opts) 22: end
Issue a separate query to get the rows modified. ADO appears to use pass by reference with an integer variable, which is obviously not supported directly in ruby, and I‘m not aware of a workaround.
# File lib/sequel/adapters/ado/mssql.rb, line 28 28: def execute_dui(sql, opts={}) 29: return super unless @opts[:provider] 30: synchronize(opts[:server]) do |conn| 31: begin 32: log_yield(sql){conn.Execute(sql)} 33: res = log_yield(ROWS_AFFECTED){conn.Execute(ROWS_AFFECTED)} 34: res.getRows.transpose.each{|r| return r.shift} 35: rescue ::WIN32OLERuntimeError => e 36: raise_error(e) 37: end 38: end 39: end