# Reducing Code (again)

**URL:** <https://www.ruby-forum.com/t/reducing-code-again/130794>\
**Category:** Ruby\
**Created:** [March 3, 2008, 12:33pm UTC](https://www.ruby-forum.com/t/reducing-code-again/130794 "2008-03-03T12:33:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cujigar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/2acd7d/32.png) [@cujigar](https://www.ruby-forum.com/u/cujigar)\
**Post date:** [March 3, 2008, 12:33pm UTC](https://www.ruby-forum.com/t/reducing-code-again/130794/1 "2008-03-03T12:33:49Z")

</div>

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
