| 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. |
Just execute so it doesn‘t attempt to return the number of rows modified.
# File lib/sequel/adapters/ado/mssql.rb, line 15
15: def execute_ddl(sql, opts={})
16: execute(sql, opts)
17: 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 23
23: def execute_dui(sql, opts={})
24: return super unless @opts[:provider]
25: synchronize(opts[:server]) do |conn|
26: begin
27: log_yield(sql){conn.Execute(sql)}
28: res = log_yield(ROWS_AFFECTED){conn.Execute(ROWS_AFFECTED)}
29: res.getRows.transpose.each{|r| return r.shift}
30: rescue ::WIN32OLERuntimeError => e
31: raise_error(e)
32: end
33: end
34: end