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

Jeff Carnahan jcarnahan@networq.com
Thu, 25 Jan 2001 13:38:03 -0800


>-----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