[ic] nuttyness with database select

John Allman interchange-users@icdevgroup.org
Mon Sep 9 06:07:04 2002


John Allman wrote:

> mike@perusion.com wrote:

> Oh, wait a minute. Where is your:
>
>>
>> my $ary = $Tmp->{myref};
>>
>> ??
>>
>>
>>
> oh dear god no!:(
> there is a genuine error somewhere but apparently in my stripping down 
> of the code i left that very neccessary bit out. that's what you get 
> for doing this stuff tired. i will try and produce the real error. 
> making that correction solved my problem and my sanity is restored.
>
> you are a god among men mike
>
>
> _______________________________________________
> interchange-users mailing list
> interchange-users@icdevgroup.org
> http://www.icdevgroup.org/mailman/listinfo/interchange-users


right - knew there was something funny going on. after much testing i've 
finally isolated the problem. i am attempting to use a sql query string 
with multiple matches using 'or'. As far as i understood this is ok to 
do in interchange...

the following peice of code demonstrates my problem:

[query arrayref=myref base=cattable sql="select code,descrip,template 
from cattable where code=401 or code=252"]
<!--body not used... -->
[/query]
[perl ]
# Get the query results, has multiple fields
my $ary = $Tmp->{myref};
$Scratch->{foundstuff}="no";
foreach $line (@$ary) {
($code,$descrip,$template) = @$line;
$Scratch->{foundstuff}="yes";
}
[/perl]
did i find stuff? [scratch foundstuff]

this says "did i find stuff? no" whereas if i change the sql to "select 
code,descrip,template from cattable where code=401" or "select 
code,descrip,template from cattable where code=252" i get "did i find 
stuff? yes".

Is my code wrong? it generates no errors...

please help!

John