From: "Daniel P. Zepeda" Date: 2002-04-19T00:53:52+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? > Try more whitespace in the predicate: if result.num_tuples == 0 then I know it is not supposed to matter, and I may be mistaken, but I've got the impression from experience that sometimes the whitespace does matter. This may be way off base, but it is something to try. -- Daniel P. Zepeda daniel@zepeda-zone.net