HomeOracle Page 4 - Adding Computations, Processes, and Validations
Creating Computations - Oracle
Validations, computations, and processes greatly increase the functionality of an HTML DB application. In this three-part series (of which this is the first part), you'll learn about the different types and where to use them. This article is excerpted from chapter 13 of the Oracle HTML DB Handbook, written by Lawrence Linnemeyer and Bradley Brown (McGraw-Hill, 2006; ISBN: 0072257687).
Computations are created in two places. Application-level computations are created from the Application Computations link in the Logic section of the application’s shared components. When creating an application-level computation, you are taken directly to the Edit Application Computation page. Page-level computations are created from the Add icon in either the Computation section at the bottom of the Page Rendering column or the Computation section at the top of the Page Processing column. Both of these will start the computation-creation wizard. This wizard can also be started through the Create link on the Developer’s Toolbar and selecting the Page Control on This Page option.
The first step in the process is to select whether you want to calculate the value for an item on the same page, an item on another page, or an application-level item. Next, you select the item on which you want to create the computation from a pick list based on your first selection. You also specify the sequence for the computation. If there are multiple computations at the same processing point, they will be processed in the order of the sequence number. You also specify the computation point and the type of computation.
The six different types of computations offer the developer great flexibility in how the value of an item may be determined. Each type, along with an example, is shown in the following table.
5 or completed
PL/SQL Function Body
This is a simple example but it can be as complex as any function you would otherwise write including a declaration section.
if instr(upper(:p5_lastname),'DAN')>0 then return :p5_notes||' it''s a Dan'; else
return :p5_notes; end if;
select code_value from code_table where code = :p45_user_value;
substr(:p5_name, instr(:p5_name, ',') + 1 )
The last step in the wizard allows you to specify a condition that must be met before the computation will be executed. All the normal 60-plus condition types are available.
To edit a page-level computation, click on the name of the computation to navigate to the Edit Page Computation page. In addition to the attributes entered in the wizard, you can specify an error message in case the computation fails. Additionally, the normal sections for Authentication, Configuration, and Comments are available.
When you click on the title of the Computations section, you will navigate to the Page Computations page, where you can edit the sequence and computation point of all your computations. You can also see the computation type, whether it is conditional, and when it was last updated.
To edit application-level computations, navigate to the specific computation through the Application Computations link in the Logic section of the application’s shared components.
Please check back next week for the continuation of this article.