Home » Developer & Programmer » Forms » calculation field(summary) (developer 6i second release)
calculation field(summary) [message #293493] Sun, 13 January 2008 07:41 Go to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear all

I have 2 datablock in one canvas and the relation between them is one to many I want a field in the master table called"total"
calculate for me a field in the foreign table called "sub_total"
so how can I use the "summary" for this calculation
best wishes

the master datablock name is "invoice"
the foreign datablock is called "details_invoice"

best wishes

Re: calculation field(summary) [message #293519 is a reply to message #293493] Sun, 13 January 2008 21:33 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
Search this forum for 'calculation' and 'calculate'.

David
Re: calculation field(summary) [message #293538 is a reply to message #293493] Mon, 14 January 2008 00:23 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear all
i found the summary for one block but I am looking for 2 blocks that have relation one to many i hope if u can help me
best wishes
Re: calculation field(summary) [message #293543 is a reply to message #293538] Mon, 14 January 2008 00:53 Go to previous messageGo to next message
djmartin
Messages: 10181
Registered: March 2005
Location: Surges Bay TAS Australia
Senior Member
Account Moderator
There is an example in this forum. You may have to go back 6-9 months. Add the criteria 'master detail' to your search.

David
Re: calculation field(summary) [message #293551 is a reply to message #293493] Mon, 14 January 2008 01:10 Go to previous messageGo to next message
ashraf_al_ani
Messages: 92
Registered: October 2007
Location: Iraq
Member
Dear David
I hope if u can write it here because i couldnt reach the example so i hope if u can explain it here
with my best wishes for u and all
best regards
Re: calculation field(summary) [message #293632 is a reply to message #293551] Mon, 14 January 2008 05:45 Go to previous messageGo to next message
Littlefoot
Messages: 21823
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
If I understood you correctly, this is what you currently have:
CREATE TABLE master
(id        NUMBER PRIMARY KEY,
 name      VARCHAR2(20),
 total     NUMBER
);

CREATE TABLE detail
(id_fk     NUMBER CONSTRAINT fk_dm  
                  REFERENCES master (id),
 sub_total NUMBER
);
A sample data might be this:
detail: id_fk  sub_total
        -----  ---------
        1      10
        1      20
        2      50

master: id     total
        --     -----
        1      30 (= 10 + 20)
        2      50

If that's really what you have, perhaps you should consider whether it is a good idea to keep the summary of all sub_totals per ID in the master table. Why would you do that? A simple query will return that value any time:
SELECT m.id, m.name, SUM(d.sub_total) total
FROM MASTER m, DETAIL d
WHERE m.id = d.id_fk
GROUP BY m.id, m.name;
In my opinion, there's really NO NEED to keep totals in the master table.

However, if I misunderstood the question, here's a sample form (created with Forms 10g) based on Scott's schema. It will only show you how to create a summary item for display purposes. Modify it in order to suit your real needs. Perhaps it'll help.
Re: calculation field(summary) [message #293808 is a reply to message #293493] Tue, 15 January 2008 02:35 Go to previous message
farooq112
Messages: 90
Registered: September 2006
Location: cairo
Member
i think the cod is netx
nvl(:blocname.item name,0)+nvl(:blocname.item name,0);

but if u do *
the code is next

nvl(:blocname.item name,1) * nvl(:blocname.item name,1);

farooq112@hotmail.com
Previous Topic: Search.Properties
Next Topic: Why after call app_multi.event('WHEN-MOUSE-CLICK') some field are not in highlight?
Goto Forum:
  


Current Time: Sat Dec 14 17:29:19 CST 2024