From: Jigar Gosar Date: 2008-03-03T20:33:40+09:00 Subject: Reducing Code (again) Following is some code that I came up with, for small db processing. I have a feeling that I could be further reduced to be more concise. Something feels off, I can't put my finger on it. Or maybe for such a small task its pretty decent. Le me know. thanks. module MSDB DELETE_RESPONSE_TIME_LOG_QUERY = "delete from responsetimelog" def copy_results suffix transaction do |con| con.do "select * into responsetimelog_#{suffix} from responsetimelog" con.do DELETE_RESPONSE_TIME_LOG_QUERY end end def clear_response_time_log transaction do |con| con.do DELETE_RESPONSE_TIME_LOG_QUERY end end private def transaction DBI.connect("...") do |con| yield con con.commit end end end -- Posted via http://www.ruby-forum.com/.