Class: SqlServerBatchInsert

Inherits:
StandardBatchInsert show all
Defined in:
lib/dataload/batch_insert.rb

Instance Attribute Summary

Attributes inherited from StandardBatchInsert

#ar_class, #block_size, #rows, #table_name

Instance Method Summary collapse

Instance Method Details

#insert!Object



35
36
37
38
# File 'lib/dataload/batch_insert.rb', line 35

def insert!
  write_load_file!
  ActiveRecord::Base.connection.execute(insert_sql)
end

#insert_sqlObject



32
33
34
# File 'lib/dataload/batch_insert.rb', line 32

def insert_sql
  "BULK INSERT #{table_name} FROM '#{load_file_path}' WITH (FIELDTERMINATOR = '|', ROWTERMINATOR = '______', BATCHSIZE = #{block_size})"
end

#write_load_file!Object



28
29
30
31
# File 'lib/dataload/batch_insert.rb', line 28

def write_load_file!
  File.create(load_file_path,load_file_str)
  Dataload.log "Temp file for bulk insert created at #{load_file_path}"
end