[ic] decrement inventory in an additional table

Andrei Gologan interchange-users@icdevgroup.org
Mon Aug 26 05:22:03 2002


----- Original Message -----
From: "Kevin Walsh" <kevin@cursor.biz>
To: <interchange-users@icdevgroup.org>
Sent: Monday, August 26, 2002 4:23 AM
Subject: RE: [ic] decrement inventory in an additional table


> >  I need to decrement the inventory  in an additional table besides
> > inventory. In log_transaction I copied the code:
> >
> > [if variable DECREMENT_INVENTORY]Inventory of [item-code] now:
> >         [data
> >                 table=menge
> >                 col=quantity
> >                 key="[item-code]"
> >                 increment=1
> >                 value="-[item-quantity]"
> >         ]
> > [/if]
> >
> > but it does not work ... it might be because my table "menge" has 2 keys
> > defined , i am not sure. In the log it only shows up with "-the number"
I
> > ordered but no change to the quantity column.
> >
> > How can I do this ? I tried directly with mysql but it just wrote the
code
> > to the log or it just didnīt do anything .....
> >
> > menge is a table with following columns: sku, username, quantity - here
the
> > quantity i supposed to be decreased on order, here and in the inventory
> > table. keys are sku and username (to eliminate duplicates)
> > I have IC 4.8
> >
> You didn't specify whether any error messages were reported in your
> error.log file(s).
>
> A couple of things to check:
>
>   1. Do you have a dbconf/mysql/menge.mysql file, or have you declared
>      your table to Interchange in some other way?

I did that, I acces the table from everywhere, I can edit it with the admin
interface. Using flex_select I can display and change the table.

>   2. At the top of your etc/log_transactions file, you should have code
>      that looks similar to the following:
>
>          [loop list="transactions orderline inventory userdb"]
>              [flag type=write table="[loop-code]"]
>          [/loop]

menge is in there

>
>      Have you added "menge" to the list of tables to be given write
>      permission?
>
> A quick look in your error.log will tell you whether Interchange
> was denied write permission, or whether it simply doesn't know about
> your "menge" table.

the error.log is empty, there is nothing in there ...... as far as I can see

> If rows in your "menge" table cannot be uniquely identified by the
> item code then you will not be able to use the [data] tag in the
> way you quoted above; Use [query] instead.
>

ok rows cannot be uniquely identified, one item_code comes more than once
... so i try this:

[if variable DECREMENT_INVENTORY]Inventory of [item-code] now:

[query sql="update menge set ( quantity='-[item-quantity]' ) where
sku='[item-code]' and username='[data session username]'  " ]
[/query]

[/if]

but that brings me back to checkuou.html

the error.log says:

[26/August/2002:11:04:40 +0200] dwshop /cgi-bin/dwshop/process.html
credit_limit=5e+18 total=0
xxx.xxx.xxx.xxx Tk2qDZsr:xxx.xxx.xxx.xxx - [26/August/2002:11:04:40 +0200]
dwshop /cgi-bin/dwshop/process.html Route log failed.
xxx.xxx.xxx.xxx Tk2qDZsr:xxx.xxx.xxx.xxx - [26/August/2002:11:04:40 +0200]
dwshop /cgi-bin/dwshop/process.html ERRORS on ORDER TEST0202:
> Error during creation of order routing log:
> Route log failed. at /usr/lib/interchange/lib/Vend/Order.pm line 1574.
>
xxx.xxx.xxx.xxx Tk2qDZsr:xxx.xxx.xxx.xxx - [26/August/2002:11:04:40 +0200]
dwshop /cgi-bin/dwshop/process.html Safe: syntax error at (eval 516) line 2,
at EOF
>
>  0 >

the logs/log file says:

#### begin TEST0202 #####
There was an error adding to the transaction log.
1
#### end TEST0202 #####


I know I am close ....... should I try an insert ? is the sql syntax right ?
Thank you !!