[ic] Filling perl hashes with [query] and searching the hash for product display restriction

Annie Flippo aflippo@lunamedium.com
Thu, 22 Feb 2001 16:46:00 -0800


I'm running this example but my version is
 [perl tables=product_cat interpolate=1]
    my $db = $Db{product_cat};
   @set = $db->query("SELECT model_id, model_name FROM product_cat order by
model_name");
    $retstr = "";
    foreach $row (@$set)

        ($model_id, $model_name) = @$row;
        $retstr = $retstr . "model id: $model_id  -- model_name: $model_name

\n"; } return "$retstr"; [/perl] But I get this error message in my error.log file. 192.168.0.30 6ssmWYaM:192.168.0.30 - [22/February/2001:16:22:44 -0800] mystore/cgi-bin/mystore/test.html Safe: Can't call method "query" on an undefined value at (eval 317) line 6. My store is set up on Redhat 6.2 with MySQL 3.2.2.25. Any idea what I'm not doing right? Did I forget to configure something? Any suggestions are appreciated. Thanks. Annie Flippo aflippo@lunamedium.com >-----Original Message----- >Sent: Thursday, January 25, 2001 12:51 PM > >Here is how I'm trying to do it in Perl (please don't laugh). > > [perl tables=coverage] > my $db = $Db{coverage}; > @set = $db->query('select hcpcs,copay from coverage WHERE >carrier_idr = 11001'); > $Scratch->{covered_hcpcs} = \@set; > > $db = $Db{products}; > #loop through all of $Scratch->{covered_hcpcs} >here somehow, setting $i to hcpcs value. > @set = $db->query('select sku from >products WHERE hcpcs = $Scratch->{covered_hcpcs->{$i}}'); > #end loop. > $Scratch->{covered_skus} = \@set; > return; > [/perl] > Not to bad... Here's some more: [perl tables=coverage interpolate=1] my $db = $Db{coverage}; $set = $db->query("SELECT hcpcs, copay FROM coverage WHERE carrier_idr = '[scratch cust_carrier_idr]"); $Scratch->{covered_hcpcs} = $set; $Scratch->{covered_products} = []; $db = $Db{products}; foreach $row (@$set) { ($hcpcs, $copay) = @$row; $prod_set = $db->query("SELECT sku FROM products WHERE hcpcs = '$hcpcs'"); foreach $prod_row (@$prod_set) { ($sku) = @$prod_row; push(@{ $Scratch->{covered_products} }, $sku); } } # $Scratch->{covered_products} should now be an array # of product sku's that are covered. return; [/perl] -- Jeff Carnahan - jcarnahan@networq.com