There is a column
as Price
in my oracle apex tabular form. I need to calculate sum
of all fields under this column and assign it to hidden field in Master form for validation.
Actually there is a filed as Total_Price
in master form. Value of this Total_Price
field must be equals to sum of Price
in detail form.
but i don't know how to calculate sum
of Price
column
in my oracle apex tabular form. how could i do this?
Asked
Active
Viewed 6,576 times
1

Bishan
- 15,211
- 52
- 164
- 258
-
At what point do you need to do this - as data is being entered, or once it has been entered and page is submitted? – Tony Andrews Jan 27 '12 at 10:43
-
@TonyAndrews at once it has been entered and click on Apply Changes Button. Before inserting to the database. – Bishan Jan 27 '12 at 10:49
-
@TonyAndrews how could i do this when data is being entered ? – Bishan Jan 22 '13 at 06:40
1 Answers
3
Since you want to do these when the Apply Changes button has been pressed, you can do it in a page process.
You need to identify which Apex array holds the data from that tabular form column - e.g. apex_application.g_f01, apex_application.g_f02, ... One way is to view the page source when running the page and look for the elements that make up the column. If they have the attribute name="f01"
then the array you need is apex_application.g_f01, and so on.
Then simply write this code in the page process (I have assumed the array required is g_f01):
declare
l_tot number := 0;
begin
for i in 1..apex_application.g_f01.count loop
l_tot := l_tot + nvl(to_number(apex_application.g_f01(i)),0);
end loop;
:p123_hidden_total := l_tot;
end;

Tony Andrews
- 129,880
- 21
- 220
- 259
-
Take a look at this answer of me here http://stackoverflow.com/a/8488091/814048 too: a mapping is also in the html source by which you can determine the arrays. Careful with apex_item usage though (because you assign an id manually). As for the sum, could you not also do a ´select sum() into´ after the MRU process? Result'd be the same though :) – Tom Jan 27 '12 at 13:00