Sha256: 209f3cf1a1543a1198c923889a128e04c421f3d5ef5fb115be3f166d51c862bf

Contents?: true

Size: 1.19 KB

Versions: 21

Compression:

Stored size: 1.19 KB

Contents

Sequel.require 'adapters/shared/mssql'

module Sequel
  module ODBC
    # Database and Dataset instance methods for MSSQL specific
    # support via ODBC.
    module MSSQL
      module DatabaseMethods
        include Sequel::MSSQL::DatabaseMethods
        LAST_INSERT_ID_SQL='SELECT SCOPE_IDENTITY()'
        
        # Return an instance of Sequel::ODBC::MSSQL::Dataset with the given opts.
        def dataset(opts=nil)
          Sequel::ODBC::MSSQL::Dataset.new(self, opts)
        end
        
        # Return the last inserted identity value.
        def execute_insert(sql, opts={})
          synchronize(opts[:server]) do |conn|
            begin
              log_yield(sql){conn.do(sql)}
              begin
                s = log_yield(LAST_INSERT_ID_SQL){conn.run(LAST_INSERT_ID_SQL)}
                if (rows = s.fetch_all) and (row = rows.first)
                  Integer(row.first)
                end
              ensure
                s.drop if s
              end
            rescue ::ODBC::Error => e
              raise_error(e)
            end
          end
        end
      end
      
      class Dataset < ODBC::Dataset
        include Sequel::MSSQL::DatasetMethods
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
sequel-3.28.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.27.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.26.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.25.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.24.1 lib/sequel/adapters/odbc/mssql.rb
sequel-3.24.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.23.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.22.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.21.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.20.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.19.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.18.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.17.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.16.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.15.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.14.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.13.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.12.1 lib/sequel/adapters/odbc/mssql.rb
sequel-3.12.0 lib/sequel/adapters/odbc/mssql.rb
sequel-3.11.0 lib/sequel/adapters/odbc/mssql.rb