Begin forwarded message:

> From: drieux <[EMAIL PROTECTED]>
> Date: Thu May 02, 2002  11:51:35  US/Pacific
> To: cgi <[EMAIL PROTECTED]>
> Subject: Re: query about empty return value from SELECT
> Reply-To: cgi <[EMAIL PROTECTED]>
>
>
> On Thursday, May 2, 2002, at 11:29 , 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";
>>   }
>>
>> }
>>
>> For some values of $_ the $reference has some value and is empty for 
>> others. How do I check ?
>
>
> plan A:
>
>       foreach my $pVal (@abc) { # this way one has the 'item' in $pVal
>                                                         # and it is not vulnerable 
>to others leaving
>                                                         # $_ in an alternative state
>       }
>
> plan B:
>
>       foreach (@abc) {
>               next if (/\s+/);        # get the next value if this is empty
>               my $pVal = $_;          #now we have it for subsequent use
>
>       }
>
> if you are trying to make sure that you have packed up the
> message correctly before pushing it into the mess - then
> you might want to do something like
>
>       my $msg = "select distinct X from Y where P=\'$pVal\'";
>
> so that we can verify that the SQL is 'kosher' and would be
> what we would type in to get ....
>
> at which point I am not all sure what this
>
>       fetchall_arrayref()
>
> method is all about - and shall presume that it is returning
> a reference to an array - hence the the @$reference is the
> actual 'list' of things.... and it is your @array that you
> are concerned about - vice the $_ last match...
>
> it is also possible that there is no Distinct X from Y....

ciao
drieux

---
>
>
> -- To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to