module Sequel::ODBC::MSSQL::DatabaseMethods

  1. lib/sequel/adapters/odbc/mssql.rb

Methods

Public Instance

  1. execute_insert

Public Instance methods

execute_insert(sql, opts=OPTS)
[show source]
   # File lib/sequel/adapters/odbc/mssql.rb
19 def execute_insert(sql, opts=OPTS)
20   synchronize(opts[:server]) do |conn|
21     begin
22       log_connection_yield(sql, conn){conn.do(sql)}
23       begin
24         last_insert_id_sql = 'SELECT SCOPE_IDENTITY()'
25         s = log_connection_yield(last_insert_id_sql, conn){conn.run(last_insert_id_sql)}
26         if (rows = s.fetch_all) and (row = rows.first) and (v = row.first)
27           Integer(v)
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