Method: Myreplicator::SqlCommands.export_sql

Defined in:
lib/exporter/sql_commands.rb

.export_sql(*args) ⇒ Object

Builds SQL needed for incremental exports



274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/exporter/sql_commands.rb', line 274

def self.export_sql *args
  options = args.extract_options!
  sql = "SELECT * FROM #{options[:db]}.#{options[:table]} " 
  
  if options[:incremental_col] && !options[:incremental_val].blank?
    if options[:incremental_col_type] == "datetime"
      sql += "WHERE #{options[:incremental_col]} >= '#{options[:incremental_val]}'"
    else
      sql += "WHERE #{options[:incremental_col]} >= #{options[:incremental_val]}"
    end
  end

  return sql
end