Used to share the code across the modules. These are stored in PLL files. When PLL file is compiled, PLX file is generated.
Pl/SQL Libraries generally contain procedures, functions and packages.
Creating PL/SQL Library
Open the form builder tool File Connect Provide User Name , password and database details to establish connection.
Select PL/SQL Libraries Click on Create
Select Program units Click on create Name -- add_num Types Select Function OK
Provide the following code and compile
function add_num ( a number, b number) return number is r number(12); begin select a+b into r from dual; return r; end;
Lets create another function
In the Object Navigator
Under Pl/SQL Libraries Under Program units Click on create button
Name -- mul_num Types Select Function OK
function mul_num ( x number, y number) return number is r number(12); begin select x*y into r from dual; return r; end;
Name -- sub_num Types Select Function OK
function sub_num ( n number, m number) return number is r number(12); begin
select n-m into r from dual; return r; end;
So, our library is having three functions.
Now, Go to File Save as TEST.pll Program Compile Module Observe PLX file is generated. Exit from the Form Builder tool.
Using Libraries in Forms
Open the from builder tool Build new form manually
In the Object Navigator select Attached Libraries Click on create Browse Select TEST.pll Attach
We get the following Alert
Click on No As we have attached, we can see the functions in our form.
Select Data Blocks Click on create button Select build a new Data Block manually OK Provide the following properties
General Name -- MY_BLOCK1 Database Database Data Block -- No
Note When we set the property Database Data Block to No, It is called as Control Block.
In Object Navigator Select Canvas Click on Create button Provide following properties
General Name -- MY_CANVAS1
Go to the Layout editor Place two text items , four buttons and a display item.
Name the two text items as T1 and T2
Name the buttons as B1 , B2, B3 and B4
Provide the following label respectively
For B1 label it as ADD For B2 label it as MULTIPLY For B3 label it as MINUS For B4 label it as CLEAR
Name the Display Item as D1, Prompt as Result
Create WHEN-BUTTON-PRESSED for the button B1 and provide the following code and compile.
:D1 := add_num (:T1, :T2);
Create WHEN-BUTTON-PRESSED for the button B2 and provide the following code and compile.
:D1 := mul_num (:T1, :T2);
Create WHEN-BUTTON-PRESSED for the button B3 and provide the following code and compile.
:D1 := sub_num (:T1, :T2); Create WHEN-BUTTON-PRESSED for the button B4 and provide the following code and compile.
clear_block; go_item('T1');
Save the form with the name CALCULATE.fmb
Compile the form. Run the form.
Check the functionality.
Advantage Provides security while sharing code between modules ( Code is hidden ). Reusability of the code. Faster in execution.