[ic] Table access problem

Ed LaFrance edl@newmediaems.com
Thu, 14 Dec 2000 14:54:26 -0800


At 05:45 PM 12/14/00 -0500, you wrote:
>Maybe someone a little more familiar with the
>IC internals could help here? Taking the inventory
>thing a bit farther with:
>
>[calc tables="inventory" arg="carts"]
>         my $item;
>         foreach my $item ( @{$Safe{'carts'}->{'main'}} )
>         {
>             my $in_stock = tag_data('inventory', 'quantity', $item->{code});
>             next if $in_instock >= $item->{quantity};
>             $item->{changed_it} = $item->{quantity};
>             $item->{quantity} = $in_stock;
>
>         return;
>         }
>[/calc]
>
>Generates an error:
>Safe: Can't locate object method "open_table" via package
>"Vend::Table::DBI" at /d01/inter/lib/Vend/Data.pm line 872.
>
>This IC 4.6 with CVS updates from a couple of days ago, linux
>and the IC:Bundle installed to perl, using MySql.
>
>Perhaps this needs to be a SQL call of some sort?
>
>replacing: my $in_stock = tag_data('inventory', 'quantity', $item->{code});
>with: my $in_stock = 5;
>for instance and the rest of it works as it should.
>Any help appreciated A LOT
>
>Jerry Uphoff

Jerry -

I think you may need to put [tag touch inventory][/tag] on the page which 
calls this calc routine, and did you try it as [perl] instead of [calc] 
(just for fun)?  Also, I think there is a typo in your code:

             next if $in_instock >= $item->{quantity};

...shouldn't that be $in_stock instead of $in_instock?

- Ed L.


 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
New Media E.M.S.               Software Solutions for Business
463 Main St., Suite D          edl@newmediaems.com
Placerville, CA  95667         http://www.newmediaems.com
(530) 622-9421                 (530) 622-9426 Fax
(866) 519-4680 Toll-Free
 >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>