Click to See Complete Forum and Search --> : Update a running total field in table 1 from column in table 2


sbr7770
04-06-2006, 10:03 AM
I have a table of Vendor invoices that has invoice number,po number and total invoice amount. I need to update another table that keeps a running total of the amount spent on the po from the vendor invoice table.
So I need to add field inv_tot_amount from table vn_inv to the running total field tot_1 in table ap_inv.

This is the statement I tried (along with many variations) and cannot seem to get it to work:

UPDATE ap_inv a SET tot_1= tot_1 + (select inv_tot_amount from vn_inv v (Select v.inv_num, v.po_num from vn_inv v where a.inv_num=v.inv_num AND a.po_num=v.po_num));
The message I get back is:
ERROR at line 1:
ORA-00907: missing right parenthesis

Is there a way to do this?

Thanks,
SBR

tamilselvan
04-06-2006, 11:03 AM
UPDATE ap_inv a SET tot_1= tot_1 + (select inv_tot_amount from vn_inv v (Select v.inv_num, v.po_num from vn_inv v where a.inv_num=v.inv_num AND a.po_num=v.po_num));





UPDATE ap_inv a
SET tot_1= tot_1 +
(select inv_tot_amount
from vn_inv v,
(Select v.inv_num, v.po_num
from vn_inv v
where a.inv_num=v.inv_num AND
a.po_num=v.po_num
)
);



Comma missing.

Tamil