Advertisement
Guest User

Untitled

a guest
May 25th, 2016
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. f = File.open("telephone_ids.txt", "r")
  2. soctypeid = "42"
  3.  
  4. delete_output = "delete from telephonesoctypeoverride
  5. where soctypeid=" + soctypeid + " and telephoneid in ("
  6.  
  7. insert_output = "insert into telephonesoctypeoverride
  8. (soctypeid, socoption, telephoneid) values "
  9.  
  10. sync_output = "update telephonecellular
  11. set syncneeded = \'1\' where telephoneid in ("
  12.  
  13. f.each_line do |line|
  14. delete_output << line.chomp + ","
  15. insert_output << "('" + soctypeid + "','Remove','" + line.chomp + "'),"
  16. sync_output << line.chomp + ","
  17. end
  18.  
  19. delete_output = delete_output.chop
  20. delete_output << ");\n"
  21.  
  22. insert_output = insert_output.chop
  23. insert_output << ";\n"
  24.  
  25. sync_output = sync_output.chop
  26. sync_output << ");\n"
  27.  
  28. f.close
  29.  
  30. File.open("sql.sql", 'w') { |file| file.write(delete_output + insert_output + sync_output) }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement