Module: Sequel::ADO::MSSQL::DatabaseMethods
- Includes:
- MSSQL::DatabaseMethods
- Defined in:
- lib/sequel/adapters/ado/mssql.rb
Constant Summary collapse
- ROWS_AFFECTED =
Query to use to get the number of rows affected by an update or delete query.
"SELECT @@ROWCOUNT AS AffectedRows"
Constants included from MSSQL::DatabaseMethods
MSSQL::DatabaseMethods::AUTO_INCREMENT, MSSQL::DatabaseMethods::DECIMAL_TYPE_RE, MSSQL::DatabaseMethods::SERVER_VERSION_RE, MSSQL::DatabaseMethods::SERVER_VERSION_SQL, MSSQL::DatabaseMethods::SQL_BEGIN, MSSQL::DatabaseMethods::SQL_COMMIT, MSSQL::DatabaseMethods::SQL_ROLLBACK, MSSQL::DatabaseMethods::SQL_ROLLBACK_TO_SAVEPOINT, MSSQL::DatabaseMethods::SQL_SAVEPOINT
Instance Method Summary collapse
-
#dataset(opts = nil) ⇒ Object
Return instance of Sequel::ADO::MSSQL::Dataset with the given opts.
-
#execute_ddl(sql, opts = {}) ⇒ Object
(also: #execute_insert)
Just execute so it doesn’t attempt to return the number of rows modified.
-
#execute_dui(sql, opts = {}) ⇒ Object
Issue a separate query to get the rows modified.
Methods included from MSSQL::DatabaseMethods
#database_type, #server_version, #supports_savepoints?, #supports_transaction_isolation_levels?, #tables
Instance Method Details
#dataset(opts = nil) ⇒ Object
Return instance of Sequel::ADO::MSSQL::Dataset with the given opts.
15 16 17 |
# File 'lib/sequel/adapters/ado/mssql.rb', line 15 def dataset(opts=nil) Sequel::ADO::MSSQL::Dataset.new(self, opts) end |
#execute_ddl(sql, opts = {}) ⇒ Object Also known as: execute_insert
Just execute so it doesn’t attempt to return the number of rows modified.
20 21 22 |
# File 'lib/sequel/adapters/ado/mssql.rb', line 20 def execute_ddl(sql, opts={}) execute(sql, opts) end |
#execute_dui(sql, opts = {}) ⇒ Object
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.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sequel/adapters/ado/mssql.rb', line 28 def execute_dui(sql, opts={}) return super unless @opts[:provider] synchronize(opts[:server]) do |conn| begin log_yield(sql){conn.Execute(sql)} res = log_yield(ROWS_AFFECTED){conn.Execute(ROWS_AFFECTED)} res.getRows.transpose.each{|r| return r.shift} rescue ::WIN32OLERuntimeError => e raise_error(e) end end end |