Home > Working with Application Pages > Understanding Page Computat... > Understanding Computation P...
Previous |
Next |
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:
Navigate to the appropriate Page Definition. See "Accessing the Page Definition".
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".
Access the Create Computation Wizard:
Tree view - Under the appropriate event, locate Computations. Right-click and select Create.
Component view - Under Computations, click the Create icon.
For Item Location, select Item on this Page and click Next.
For Computation, select P10_PHONE_NUMBER.
For Sequence, select the order of evaluation.
For Computation, you have the option of creating one of the following computation types:
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.
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.
SQL Query (return colon separated value):
For Computation Type, select SQL Query (return colon separated value) and click Next.
Enter the following computation:
SELECT '('||:P10_AREA_CODE||')'||:P10_PREFIX||'-'||:P10_LINE_NUMBER FROM DUAL
Click Next.
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.
Click Create.