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

Methods

Included Modules

Sequel::MSSQL::DatabaseMethods

Constants

LAST_INSERT_ID_SQL = 'SELECT SCOPE_IDENTITY()'

Public Instance methods

Return an instance of Sequel::ODBC::MSSQL::Dataset with the given opts.

[Source]

    # File lib/sequel/adapters/odbc/mssql.rb, line 13
13:         def dataset(opts=nil)
14:           Sequel::ODBC::MSSQL::Dataset.new(self, opts)
15:         end

Return the last inserted identity value.

[Source]

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

[Validate]