require sum value of one table to be inserted into another table column
725345Mar 22 2011 — edited Mar 24 2011Hi
I have a table which contains a list of parts and their prices required for an assembly.
I am trying to calculate the total from this part lists and put into the total price column for the assembly (another table column).
My method was to calculate the total in a page process ( eg, once all parts in the assembly have been entered the page process calculates the total price (the sum of the part prices at that time) and puts the result (total) in the assembly total column)
In the process I capture the total using either
SELECT SUM(TOTAL_COST) Total INTO B from CC_REQ_BOM WHERE RID = :P5_RID;
or
SELECT SUM(TOTAL_COST) INTO B from CC_REQ_BOM WHERE RID = :P5_RID;
Both the above sql statements are allowed ( one with alias and one without alais) by the page process but they dont seem to be working as no total is returned to the table when the page process is run.
to insert the calculation(variable B) into the required table I have used
INSERT INTO CC_REQ(TOTAL_COST)
VALUES(B);
I have used this method a few times with no problems for standard sql statements but this is the first time I have used it with the sum SQL function. For some reason it doesn't seem to like the SUM function even though the code below works in SQL Command window.
SELECT SUM(TOTAL_COST) from CC_REQ_BOM WHERE RID = :P5_RID;
Any help welcome.
PGJ