To create a calculated item:
The following item properties are defaulted to No at compilation time:
The following item properties are ignored at compilation time:
Other restrictions to keep in mind when creating calculated items:
/* Example 1: Define a summary calculation to display the
** maximum salary of all employees. Create display item MAX_SAL
** in the EMP block, set its Calculation Mode property to
** Summary, set its Summary Function property to Max, set its
** Summarized Block property to EMP, and set its Summarized
** Item property to SAL.
**
** Example 2: Define a formula calculation to compute an
** employee's gross total compensation. Create display item
** TOTAL_COMP in the EMP block, set its Calculation Mode
** property to Formula, and set its Formula property to the
** following PL/SQL expression:
*/
:emp.sal + :emp.comm
/* Example 3: Define a Formula item to compute a different
** value for total compensation depending on the block where
** the cursor currently is positioned. Form has 3 blocks:
** 2 data blocks (EMP1 and EMP2), and one control block
** (COMP). Create a display item TOTAL_COMP in the COMP block
** that displays total compensation. Set the Formula property
** for COMP.TOTAL_COMP to an expression (a function call):
*/
total_comp_func
/* Function TOTAL_COMP_FUNC is defined as follows: */
FUNCTION total_comp_func RETURN number IS
BEGIN
IF :system.cursor_block = 'emp1' THEN
RETURN :emp1.sal + :emp1.comm;
END IF;
IF :system.cursor_block = 'emp2' THEN
RETURN :emp2.sal + :emp2.comm;
END IF;
RETURN null;
END;
/* Oracle Forms automatically recalculates COMP.TOTAL_COMP
** whenever a change occurs to the value of :EMP1.SAL,
** :EMP1.COMM, :EMP2.SAL, or :EMP2.COMM. Oracle Forms
** will not, however, recalculate COMP.TOTAL_COMP when an
** end user navigates between blocks, since changes to
** system variables don't automatically cause recalculation.
** To ensure that the correct value always is displayed,
** define a PRE-BLOCK trigger at the form level, containing
** the statement:
*/
RECALCULATE('comp.total_comp');