Module | Sequel::ODBC::MSSQL::DatabaseMethods |
In: |
lib/sequel/adapters/odbc/mssql.rb
|
LAST_INSERT_ID_SQL | = | 'SELECT SCOPE_IDENTITY()' |
Return an instance of Sequel::ODBC::MSSQL::Dataset with the given opts.
# File lib/sequel/adapters/odbc/mssql.rb, line 13 13: def dataset(opts=nil) 14: Sequel::ODBC::MSSQL::Dataset.new(self, opts) 15: end
Return the last inserted identity value.
# File lib/sequel/adapters/odbc/mssql.rb, line 18 18: def execute_insert(sql, opts={}) 19: log_info(sql) 20: synchronize(opts[:server]) do |conn| 21: begin 22: conn.do(sql) 23: log_info(LAST_INSERT_ID_SQL) 24: begin 25: s = conn.run(LAST_INSERT_ID_SQL) 26: if (rows = s.fetch_all) and (row = rows.first) 27: Integer(row.first) 28: end 29: ensure 30: s.drop if s 31: end 32: rescue ::ODBC::Error => e 33: raise_error(e) 34: end 35: end 36: end