-
Copyrights 2010 - Online Training Oracle Applications. All Rights Reserved.
|
In the database, create a new table LOANS SQL> Create table loans ( cust_id number(3), Open the form builder tool. Save the form with the name LOANS.fmb In the Object navigator of LOANS.fmb, Select program units Click on create button Provide the following code and compile. FUNCTION simp_intr ( p number, n number, r number) Similarly create another program unit. Name -- comp_intr , Select type as function OK Provide the following code and compile.
FUNCTION comp_intr ( p number, n number, r number) Note We can see the two functions which we have created in Object Navigator. In the Layout editor, create a button and two display units. For button, provide the following properties. Functional For the first display item, provide the following properties For the second display item, provide the following properties Create WHEN-BUTTON-PRESSED trigger for the button B1, and provide the following code and compile. :D1 := simp_intr( :principal, :duration, :interest); :D2 := comp_intr (:principal, :duration, :interest);
In the above code, D1 and D2 are display items. Save the file. Provide the following values Cust Id -- 1 Click on Calculate button. Note We can create function at database level and invoke it in form. Let's look at that example. Create function calc_intr at database level create or replace function calc_intr ( p number, n number, r number, si out number) In the above code, function returns simple interest using OUT parameter and returns compound interest using return statement.
Open the form builder tool. Save the form with the name LOANS2.fmb In the Layout editor, create a button and two display units. For button, provide the following properties. Functional For the first display item, provide the following properties For the second display item, provide the following properties Create WHEN-BUTTON-PRESSED trigger for the button B1, and provide the following code and compile. :D2 := calc_intr (:principal , :duration, :interest, :D1); Save the file. Provide the following values Cust Id -- 1 Click on Calculate button. We can see that Simple Interest and compound Interest values are displayed.
Note The Function calc_intr is created at database level, not at form level. Let's have another example Create the following package at database level Create or replace package epack Create or replace package body epack function bonus_cal ( vjob varchar2 ) return number return ( bonus); end epack; Under INFO block , Create two display items. For the first display item, provide the following properties. General For the second display item, provide the following properties. General For both the display units as we have mentioned canvas property as CANVAS4, Under datablock EMPNINE, create POST-QUERY trigger. :D1 := epack.gross(:SAL); :D2 := epack.bonus_cal (:JOB);
Save the form.
|