15.1 Understanding Page Computations

Use computations to assign a value to an identified item when a page is submitted or displayed.

15.1.1 About Page Computations

A page computation assigns a value to an identified item when a page is displayed or submitted (rendered and processed).

You create a page computation by running the Create Page Computation Wizard. For each computation, specify the item for which you are creating the computation and a computation type.

You can also use application-level computations to assign values to items. Most page-level computations populate page items. In contrast, most application-level computations populate application items.

15.1.2 Creating a Page Computation

Create a Page Computation in Page Designer.

To create a page computation:

  1. Navigate to the appropriate page in Page Designer.
  2. In the Rendering tab, expand the Pre-Rendering or Post-Rendering node and locate where the computation should be.
  3. Right-click the location and select Create Computation.

    Page Designer appears.

    In the Property Editor, attributes are organized into groups. To find a group or attribute, enter keywords in the Filter Properties field. The Property Editor displays the group or attributes. Or, you can click Go to Group and select the group.

    Tip:

    To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the central pane.

  4. Edit the following attributes:
    1. Identification, Item Name - Enter the page or application item populated by this computation.
    2. Execution Options, Sequence - Specify the sequence for this computation. The sequence determines the order of execution.
    3. Execution Options, Point - Select at what point in page rendering or processing this computation is executed. The most typical computation point is After Submit.
    4. Computation, Type - Select a computation type. To view a list of options, see Help.
  5. Click Save.

15.1.3 Editing Page Computation Attributes

Edit a page computation in Page Designer.

To edit a page computation:

  1. View the page in Page Designer.
  2. In the Rendering tab, expand the Pre-Rendering or Post-Rendering node and select the computation.

    Page Designer appears.

    In the Property Editor, attributes are organized into groups. To find a group or attribute, enter keywords in the Filter Properties field. The Property Editor displays the group or attributes. Or, you can click Go to Group and select the group.

  3. In the Property Editor, edit the appropriate attributes.

    Tip:

    To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the center pane.

  4. Click Save.

15.1.4 Editing the Computation Point and Source

Control when a computation executes by editing the Sequence and Point attributes.

You control when a computation executes by editing the Sequence and Point attributes. The Sequence attribute determines the order of evaluation. The Point attribute determines the point in page rendering or processing at which the computation executes. The most typical computation point is After Submit.

To edit a computation point and source:

  1. View the page in Page Designer.
  2. In the Rendering tab, expand the Pre-Rendering or Post-Rendering node and select the computation.

    Page Designer appears.

    In the Property Editor, attributes are organized into groups. To find a group or attribute, enter keywords in the Filter Properties field. The Property Editor displays the group or attributes. Or, you can click Go to Group and select the group.

  3. In the Property Editor, edit the following attributes.
    1. Execution Options, Sequence - Specify the sequence for this component. The sequence determines the order of execution. If two components have the same sequence value, then they may be executed in a different order when the application is exported and imported into another environment.
    2. Execution Options, Point - Select at what point in page rendering or processing this computation is executed.
      For example, selecting On New Instance executes the computation when a new session (or instance) is generated. The most typical computation point is After Submit.
    3. Computation - Define expression or query to compute an item's value.
    4. Error, Error Message - Enter an error message that displays if this computation fails.

    Tip:

    To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the center pane.

  4. Click Save.

15.1.5 Example: Computation Points and Computation Syntax

View computation points and computation syntax example.

A good example of using computations can be illustrated by a page containing form fields for entering phone numbers. In this example, the phone number is stored in one database column; however, the data entry form breaks the phone number into three components: area code, prefix, and line number. In this example, the page items are called P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER.

Next, suppose you need to combine the values stored in these items into a single string. You could accomplish this by using an After Submit computation and store the combined values in an item called P10_PHONE_NUMBER.

To create a computation to store the combined values of P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER in new items:

  1. Navigate to the appropriate page.
  2. Create an item named P10_PHONE_NUMBER to store the combined values of P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER.
  3. Create the computation:
    1. In the Rendering tab, expand the Pre-Rendering.
    2. Select a location, and then right-click and select Create Computation.

      Page Designer appears.

      In the Property Editor, attributes are organized into groups. To find a group or attribute, enter keywords in the Filter Properties field. The Property Editor displays the group or attributes. Or, you can click Go to Group and select the group.

      Tip:

      To learn more about an attribute, select the attribute in the Property Editor and click the Help tab in the central pane.

  4. In the Property Editor, edit the following attributes:
    1. Identification, Item Name - Select P10_PHONE_NUMBER.
    2. Execution Options, Sequence - Specify the sequence for this computation. The sequence determines the order of execution.
    3. Execution Options, Point - Select at what point in page rendering or processing this computation is executed. The most typical computation point is After Submit.
  5. For Computation Type, you can create the following computation types:
    1. Static Value:
      • Computation, Type - Select Static Value .

      • Computation, Static Value - Enter the following computation:

        (&P10_AREA_CODE.) &P10_PREFIX.-&P10_LINE_NUMBER.
        
    2. PL/SQL Function Body:
      • Computation, Type - Select PL/SQL Function Body .

      • Computation, PL/SQL Function Body - Enter the computation:

        DECLARE
        l_return_value  VARCHAR2(300) DEFAULT NULL;
        BEGIN
            l_return_value :=
        '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER;
        RETURN l_return_value;
        END;
    3. SQL Query (return colon separated value):
      • Computation, Type - Select SQL Query (return colon separated value) .

      • Computation Type, SQL Query - Enter the computation:

        SELECT '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER FROM DUAL
        
    4. PLSQL Expression:
      • Computation, Type - Select PLSQL Expression .

      • Computation Type, PLSQL Expression - Enter the computation:

        '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER
        
  6. Click Save.