Summing in Oracle

Posted on 2005-04-14
Last Modified: 2010-05-18
I have a form that is an invoice with lines some of which are taxable and some are nontaxable.  I
need to sum the lines and display the total of taxable lines and nontaxable lines.  Is there some way
to do this before committing the form to the database and then doing a query.  I would like this
to display on the screen for the user.
Question by:jeancwi
    LVL 10

    Expert Comment

    oracle forms ?

    Author Comment

    Yes - Oracle forms.

    Author Comment

    Oracle forms 9.02
    LVL 11

    Expert Comment

    For this add one more field (invisible and non-db item) to your block. Say SAL_OLD(NUMBER TYPE). Now write this code in PRE-TEXT-ITEM

          :emp.old_sal := :emp.sal;

    Also add WHEN-VALIDATE-ITEM and do this coding in this,

                if nvl(:emp.old_sal,0) <> nvl(:emp.sal,0) then
                      :ctrl.sum_sal := nvl(      :ctrl.sum_sal,0)
                            + nvl(:emp.sal,0)
                            - nvl(:emp.old_sal,0);
                end if;

    Now you can see the changed (or values) of Salary field is added in the SUM_SAL filed in the control block.

    LVL 1

    Accepted Solution

    YOu can place  a formula item (may be hidden) but an a new column with your equation that
    do calcs for taxable for the suitable lines
    you may use user defined function to decide wether this line should have a tax or not and use it in the formula item

    col1          col2           col3       ......      formula item
    ---------- ------------- --------- --------- ----------------
                                                                  .                                                                   .
                                                               summary item

    and then you add a summary item that sum the formula item
    Just ask if you miss any thing

    Good luck


    Author Comment

    Thanks - I didn't try to first approach as the second one seemed easier.

    Thanks for both of you for the help

    Featured Post

    Do You Know the 4 Main Threat Actor Types?

    Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

    Join & Write a Comment

    Suggested Solutions

    Database tuning – How to start and what to tune. This question is frequently asked by many people, both online and offline. There is no hard and fast rule-of-thumb for performance tuning, however, before beginning the tuning process one should a…
    CCModeler offers a way to enter basic information like entities, attributes and relationships and export them as yEd or erviz diagram. It also can import existing Access or SQL Server tables with relationships.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    731 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now