Previous
Previous
 
Next
Next

Understanding Page Computations

Use page computations to assign a value to an identified item when a page is submitted or displayed. You can also use application-level computations to assign values to items. Most application-level computations are performed for every page in an application. In contrast, computations created at the page-level only execute when that page is rendered or processed.

Topics:

Creating a Page Computation

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.


See Also:

"Computations"

To create a page computation:

  1. Navigate to the appropriate Page Definition. See "Accessing a Page Definition".

  2. Under Computations, click the Create icon.

  3. For Item Location, select where the computation will execute and click Next. Location options include:

    • Item on this Page

    • Item on Another Page

    • Application Level Item

  4. For Item, select the item and computation point at which you would like to perform the computation:

    1. Compute Item - Select the item the computation will update.

    2. Sequence - Select the order of evaluation.

    3. Computation Point - Select the point at which the computation executes. The computation point On New Instance executes the computation when a new session (or instance) is generated.

    4. Computation Type - Select the method of computation you want to create.

    5. Click Next.

  5. In Computation, enter a computation that corresponds to the selected computation type and click Next.

  6. On Condition, you can choose to make the computation conditional. To make a computation conditional, make a selection from the Condition Type list and enter text in the expression fields.

  7. Click Create.

Understanding Computation Points and Computation Syntax

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 Definition. See "Accessing a Page Definition".

  2. Create a item named P10_PHONE_NUMBER to store the combined values of P10_AREA_CODE, P10_PREFIX, and P10_LINE_NUMBER. See "Differences Between Page Items and Application Items".

  3. Under Computations, click the Create icon.

  4. For Item Location, select Item on this Page and click Next.

  5. For Computation, select P10_PHONE_NUMBER.

  6. For Sequence, select the order of evaluation.

  7. For Computation, you have the option of creating one of the following computation types:

    1. Static Assignment:

      • For Computation Type, select Static Assignment and click Next.

      • Enter the following computation:

        (&P10_AREA_CODE.) &P10_PREFIX.-&P10_LINE_NUMBER.
        
      • Click Next.

    2. PL/SQL Function Body:

      • For Computation Type, select PL/SQL Function Body and click Next.

      • Enter the following 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;
        
      • Click Next.

    3. SQL Query:

      • For Computation Type, select SQL Query and click Next.

      • Enter the following computation:

        SELECT '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER FROM DUAL
        
      • Click Next.

    4. PLSQL Expression:

      • For Computation Type, select PLSQL Expression and click Next.

      • Enter the following computation:

        '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER
        
      • Click Next.

  8. Click Create.

Editing Page Computation Attributes

Once you create a computation, you can edit it on the Edit Page Computation page.

To edit a page computation:

  1. Navigate to the appropriate Page Definition. See "Accessing a Page Definition".

  2. Under Computations, select the computation name.

    The Edit Page Computation page appears.

  3. Edit the appropriate attributes.

  4. Click Apply Changes.

Editing the Computation Point and Source

You control when a computation executes under the Computation Point attributes by specifying a sequence and a computation point. The computation point On New Instance executes the computation when a new session (or instance) is generated.

Under Source, enter an expression or query to compute an item's value. In the event a computation fails, you can optionally define an error message in the Computation Error Message field.

Creating Conditional Computations

You can make a computation conditional by making a selection from the Condition Type list and entering text in the expression fields.