How to totalize a field in a multi-line block from a multi line sub block in Oracle Forms.

I have two multiline blocks , A and B. Typicall master and detai relation. B is the detail block from A.
I want to put a sum item in A block, getting the total ammount from her childs in the A block.
but i get the error: the item must be in the same block or the block must be only 1 record.
If i do the master block  only 1 reg not problem, but i need this block multi reg too.
how can i put a sum item from detail block in the master block (multi line too)?
Who is Participating?
Dr_BillyConnect With a Mentor Commented:
Waht would solve your problem is to create a non-database item on the master block, in your post-Query trigger on the block level , do the following

  V_Sum Number  ;
    Select Nvl(Sum(Details_Column_name),0)
       into  V_Sum
      from  your_Details_Table
   Where  Your_Deails_Table.Master_Table_FK = :Master_Block.Primary_Key ;

     When others then
        V_Sum := 0 ;
  :Master_Block.tot.lin := V_Sum  ;
What you need to do is create a control block with a single record and only one item which is going to hold the summarized data from the detail block , you can display that item on the screen with the Master block , there is no harm in that.

set the summary item in that block to point to the item that you want find it's summation in the detail block , that will resolve your problem.
ColorkerAuthor Commented:
I have created another block (ej: A2) with the sum item with only a reg. it's ok, it displays the sum from block B regs, but i still can't display this summarized result in the multi-reg master block (A). I can't copy the value to the real item in A block, I can't set "coy value from..." or syncronize. If i set this item like sum of the fake item , i get the same error.
Sorry for my English....
Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Can you please post snapshots of the blocks , and set the item that you want to summarize so I can get a clear picture of what you want to do , am a bit confused.
ColorkerAuthor Commented:
Here is it.
ColorkerAuthor Commented:
Ok, I will do it in that way. It wanted to avoid that manual calculations, but it seems it is the only way. Thanks for all.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.