dcsimg
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2006
    Posts
    1

    Update a running total field in table 1 from column in table 2

    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

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,135
    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));

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width




×
By using this site, you agree to the Privacy Policy