19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/sequel/adapters/odbc/mssql.rb', line 19
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
|