From: "Daniel P. Zepeda" Date: 2002-04-19T01:56:42+09:00 Subject: Re: ruby/postgres problem On Fri, 19 Apr 2002 00:27:07 +0900 "Steve Cranford" wrote: > I'm trying to determine if a resultset is empty. if it is, I want to > perform other actions. I tried this code and it didn't work: > > result=conn.exec(sql) > msg="testing" > > if result.num_tuples==0 > # run an insert > msg="new action" > end > > msg<< result.num_tuples.to_s #or a variation, I see the number. > > the number of tuples correctly reports on the screen but the if block > never executes. I've had similar problems with numeric values in a case > statement. I've tried using variables in place of the values in the if > statement as well as a (!result), but nothing seems to work. what am I > doing wrong? I don't have ruby postgres to check, but another thought to cross my mind: Are you sure result.num_tuples is returning a Fixnum? Daniel P. Zepeda daniel@z,e,p,e,d,a,-,z,o,n,e.net. (Remove the commas for the address)