module Sequel::ODBC::MSSQL::DatabaseMethods
Public Instance Methods
execute_insert(sql, opts=OPTS)
click to toggle source
# File lib/sequel/adapters/odbc/mssql.rb, line 18 def execute_insert(sql, opts=OPTS) synchronize(opts[:server]) do |conn| begin log_connection_yield(sql, conn){conn.do(sql)} begin last_insert_id_sql = 'SELECT SCOPE_IDENTITY()' s = log_connection_yield(last_insert_id_sql, conn){conn.run(last_insert_id_sql)} if (rows = s.fetch_all) and (row = rows.first) and (v = row.first) Integer(v) end ensure s.drop if s end rescue ::ODBC::Error => e raise_error(e) end end end