- Oracle APEX Cookbook(Second Edition)
- Marcel Van Der Plas Michel Van Zoest
- 421字
- 2021-07-23 15:34:39
Creating a computation>
Computations are events that will prepare items with data. As the name implies, computations can "compute" how data is to be shown on screen or how data is handled after submitting. Computations can be triggered during page rendering, but they can also be used in the After Submit process.
This example will show an implementation of a computation, but there are many more possible uses for computations.
How to do it...
Start by creating a normal text item on the form that was created in the second recipe of the first chapter. This is a normal form based on the EMP
table. Normally, a user would have to manually enter the commission. What we are going to do is to create a computation that will automatically enter an amount into this field, based on a percentage of the salary and a bonus for people that work in the Sales department.
First, identify the item that holds the commission column.
The next step is to find the moment when we want to execute the computation. In this case, before the page is submitted but after the Save button is pressed. So in this case we will create the computation After Submit.
- Right-click on the Computations under After Submit in the Page Processing component and click on Create:
- Choose Item on this page and press Next.
- Select P5_COMM from the Compute Item select list, select PL/SQL Function Body from the Computation Type select list and click on Next.
- The next step is to enter the PL/SQL code for this computation:
declare l_comm number; begin if :P5_DEPTNO = 30 then l_comm := :P5_SAL * 1.10; else l_comm := :P5_SAL * 1.05; end if; return l_comm; end; [9672_01_15.txt]
- Click on Create.
The computation is now done. It can be tested by selecting an existing record from the list of employees and altering its salary and then saving the data. Another option is to create a completely new employee. You will see that an employee under the Sales department with dept no. 30 will receive a 10 percent commission whilst employees from all other departments will receive 5 percent.
There's more...
Computations can be used for far more situations than preparing an item before saving it to the database.
An example of another implementation can be an item that will show the current date when the page loads, or an item that will show a total amount when certain other amount items are entered. Used with dynamic actions, computations can be very powerful.
- HTML5 Game development with ImpactJS
- 網(wǎng)絡(luò)安全技術(shù)與解決方案(修訂版)
- Socket.IO Real-time Web Application Development
- Working with Legacy Systems
- Echo Quick Start Guide
- Android UI Design
- 互聯(lián)網(wǎng)+思維與創(chuàng)新:通往未來的+號
- React Cookbook
- 網(wǎng)絡(luò)綜合布線(第2版)
- Building RESTful Web Services with .NET Core
- 網(wǎng)絡(luò)空間作戰(zhàn):機理與籌劃
- 互聯(lián)網(wǎng)安全的40個智慧洞見(2018)
- 學(xué)術(shù)虛擬社區(qū)用戶社會化交互行為研究
- 目標(biāo)跟蹤中的群智能優(yōu)化方法
- 天下一家:網(wǎng)絡(luò)聯(lián)通世界(科學(xué)新導(dǎo)向叢書)