Module | Sequel::ODBC::MSSQL::DatabaseMethods
In: | lib/sequel/adapters/odbc/mssql.rb

### Methods

execute_insert

### Included Modules

Sequel::MSSQL::DatabaseMethods

### Constants

LAST_INSERT_ID_SQL | = | 'SELECT SCOPE_IDENTITY()'.freeze

### Public Instance methods

execute_insert(sql, opts={})

Return the last inserted identity value.

[Source]

        # File lib/sequel/adapters/odbc/mssql.rb, line 13
    13:         def execute_insert(sql, opts={})
    14:           synchronize(opts[:server]) do |conn|
    15:             begin
    16:               log_yield(sql){conn.do(sql)}
    17:               begin
    18:                 s = log_yield(LAST_INSERT_ID_SQL){conn.run(LAST_INSERT_ID_SQL)}
    19:                 if (rows = s.fetch_all) and (row = rows.first)
    20:                   Integer(row.first)
    21:                 end
    22:               ensure
    23:                 s.drop if s
    24:               end
    25:             rescue ::ODBC::Error => e
    26:               raise_error(e)
    27:             end
    28:           end
    29:         end

[Validate]