Method: Sequel::ADO::MSSQL::Dataset#insert

Defined in:
lib/sequel/adapters/ado/mssql.rb

#insert(*values) ⇒ Object

Use a nasty hack of multiple SQL statements in the same call and having the last one return the most recently inserted id. This is necessary as ADO’s default :provider uses a separate native connection for each query.



49
50
51
52
# File 'lib/sequel/adapters/ado/mssql.rb', line 49

def insert(*values)
  return super if (@opts[:sql] && !@opts[:prepared_sql]) || @opts[:returning]
  with_sql("SET NOCOUNT ON; #{insert_sql(*values)}; SELECT CAST(SCOPE_IDENTITY() AS INTEGER)").single_value
end