------ art_7813_22391793.1231186022340 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Mon, Jan 5, 2009 at 11:02 AM, Darin Ginther < darin.ginther / allwebleads.com> wrote: > So I'm able to exercise creating my own class and returning an object > from that class. I'm having trouble treating the return as an integer > (for the purpose of a < or > compare).. Yet another noob syntax > question. > > > compare.rb: > myinitialdbcount butil.new(mydb, dbuser, dbpw, counttable, > leadtype) > puts "Initial Count:" > initialcount yinitialdbcount.count_table{ |data| p data } > > This returns: > Initial Count: > 213912 > > If I try to simply print (put) it: > puts myinitialdbcount.count_table{ |data| p data } > > This returns: > nill > > I think I need to "to_int" this object or get it into a state where I > can assign it to a local variable... There is something I dont > understand here. > > dbutil.rb: > def count_table > dbh BI.connect(@mydb, @dbuser, @dbpw) > sth bh.execute("SELECT count(*) FROM #@table where type_code > #@type_code") > row th.fetch > yield row[0] > sth.finish > dbh.disconnect > end > I don't know anything about DBI, but what do you get as output from the "p data" statement? Also, I noticed a problem with your dbh.execute statement: "SELECT ... #@table ..." probably isn't doing what you were hoping it was doing. You most likely meant "SELECT ... #{@table} ...", also with "#{@type_code". hth --wpd ------ art_7813_22391793.1231186022340--