Master-detail [message #78129] |
Sun, 20 January 2002 21:41 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
chandrakanth
Messages: 16 Registered: October 2001
|
Junior Member |
|
|
hi
There are two tables.(Master-Detail)
1. Purchase_order
Order No
Order Dt
Party
Basic Amount (Sum of Total in item details)
Sales Tax
Excise Amount
Net Amount
2. Item Details
Item Desc
Quantity
Rate
Total (Quantity * Rate)
There are 2 blocks. One for Order and second for (multirow) order details. Now my question is how to calculate Purchase_order.basic_amount from the first block as soon as user enters qty and rate. In Detail block total can be calculated as calculated items. But how to sum the total from detail to Purchase_order.Basic_amount.
Pls.Reply
|
|
|
Re: Master-detail [message #78134 is a reply to message #78129] |
Mon, 21 January 2002 04:32 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
Shilpa
Messages: 59 Registered: November 2001
|
Member |
|
|
The following code works even if the changes are not committed to the table and you still want to see the computed basic amount.
Create a post change trigger of Total. Write the following code:
DECLARE
TOTALOFTOTAL NUMBER(12,2);
BEGIN
GO_BLOCK('ORDERDETAILS');
FIRST_RECORD;
WHILE (:SYSTEM.LAST_RECORD <> 'TRUE') LOOP
TOTALOFTOTAL := NVL(TOTALOFTOTAL,0) + NVL(:ORDERDETAILS.TOTAL,0);
NEXT_RECORD;
END LOOP;
--The above code will give you the total of total field.
--Assign the total of total to the basicamount field in the orders table.
:ORDERS.BASICAMOUNT := TOTALOFTOTAL;
END;
Hope this helps!!!
|
|
|
Re: Master-detail [message #78175 is a reply to message #78134] |
Wed, 23 January 2002 20:04 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
chandrakanth
Messages: 16 Registered: October 2001
|
Junior Member |
|
|
Reg the above, its not calculating properly,hence i created 2 trigger each at qty level and rate level which calculates the total amount each time when ever i insert or modify a record and calculates the total amount. But after calculating the basic amount sales tax(%), excise amount(%) is to be calculated on the basic amount. and the final total will be basic+excise+salestax. Everything is get calculated automatically by the trigger. But when ever i made any modification on rate or qty after calculating the final total salestax, excise will intialised to zero and prompt appears as WANT TO SAVE/CANCEL THE RECORD ? i dont want this prompt to be appeared on my screen.
Pls.help
|
|
|