Calculating Totals using a "push button" [message #164059] |
Tue, 21 March 2006 09:44 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
sephina
Messages: 14 Registered: March 2006
|
Junior Member |
|
|
Hi. I have managed to produce the order form (please see attached file) but the "amount payable" button does not seem to work properly. It needs to calculate the total cost of all the individual dvd prices together. It generates a number that doesn't seem to relate to the specified values in the "dvd cost" boxes! The coding on the "amount payable" button is shown below. Could somebody please please help!! Thankyou!
begin
select sum(:order_details.cost)
into :payments.amount_payable
from order_details, dvd_details
where :payments.order_no = :order_details.order_no
and order_details.dvd_id = dvd_details.dvd_id;
end;
Sephina
|
|
|
Re: Calculating Totals using a "push button" [message #164086 is a reply to message #164059] |
Tue, 21 March 2006 13:42 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
M0nst3r
Messages: 38 Registered: February 2006 Location: Wherever the Money Is
|
Member |
|
|
There isn't enough information in your example to diagnose the problem or to verify that there is a problem, but I can offer an alternative solution.
Change the payments.amount_payable item by setting the following properties:
1. item type = display_item
2. justification = right
3. data type = number
4. format mask = fm999,999,990.00
5. calculation mode = summary
6. summary function = sum
7. summarized block = order_details
8. summarized item = cost
EDITED to add: Your query is flawed -- comparing two literals is useless in a query unless you're using it as a "toggle switch". I don't think you can use a group function on a block item like that either.
EDITED again to add: Your query is basically being sent to the database as something like this...
select sum(20)
from order_details, dvd_details
where 1 = 1
and order_details.dvd_id = dvd_details.dvd_id;
[Updated on: Tue, 21 March 2006 14:02] Report message to a moderator
|
|
|