Thanks alot. Can't move prepare outside the loop as i have to prepare for each value in the array. Why do you suggest to do it anyway? Thanks again bye Aman
----- Original Message ----- From: "Felix Geerinckx" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Thursday, May 02, 2002 11:40 AM Subject: Re: query about empty return value from SELECT > on Thu, 02 May 2002 18:29:08 GMT, Aman Raheja wrote: > > > My code looks like following > > > > foreach (@abc) > > { > > $sth = $dbh->prepare("select distinct X from Y where P='$_'"); > > $sth->execute; > > $reference = $sth->fetchall_arrayref(); > > > > if(@$reference eq '') > > { > > print "$_ in empty"; > > } > > > > } > > > > (untested) > > unless (@$reference) { > print "$_ in empty"; > } > > You also might want to move the prepare outside of the for-loop: > > $sth = $dbh->prepare("select distinct X from Y where P=?"); > foreach (@abc) { > $sth->execute($_); > # etc... > } > > > -- > felix -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]