Module: Sequel::ODBC::MSSQL::DatabaseMethods
- Includes:
- MSSQL::DatabaseMethods
- Defined in:
- lib/sequel/adapters/odbc/mssql.rb
Constant Summary collapse
- LAST_INSERT_ID_SQL =
'SELECT SCOPE_IDENTITY()'
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 an instance of Sequel::ODBC::MSSQL::Dataset with the given opts.
-
#execute_insert(sql, opts = {}) ⇒ Object
Return the last inserted identity value.
Methods included from MSSQL::DatabaseMethods
#database_type, #server_version, #supports_savepoints?, #supports_transaction_isolation_levels?, #tables
Instance Method Details
#dataset(opts = nil) ⇒ Object
Return an instance of Sequel::ODBC::MSSQL::Dataset with the given opts.
13 14 15 |
# File 'lib/sequel/adapters/odbc/mssql.rb', line 13 def dataset(opts=nil) Sequel::ODBC::MSSQL::Dataset.new(self, opts) end |
#execute_insert(sql, opts = {}) ⇒ Object
Return the last inserted identity value.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sequel/adapters/odbc/mssql.rb', line 18 def execute_insert(sql, opts={}) synchronize(opts[:server]) do |conn| begin log_yield(sql){conn.do(sql)} begin s = log_yield(LAST_INSERT_ID_SQL){conn.run(LAST_INSERT_ID_SQL)} if (rows = s.fetch_all) and (row = rows.first) Integer(row.first) end ensure s.drop if s end rescue ::ODBC::Error => e raise_error(e) end end end |