You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
<strong>Oracle</strong> Forms Builder<br />
<strong>Oracle</strong> Schema Builder<br />
Generate the following two tables :<br />
Employee<br />
EmployeeNo - Primary Key, Number, required, constraint<br />
500 (Between 100 .. 500)<br />
EmployeeTitle - Var Character of length 5, constraint Mr,<br />
Mrs, etc, default value 'Mrs' (In ‘Miss’, ‘Ms’…)<br />
EmployeeName - Var Character of length 30<br />
EmployeeAddress - Var Character of length 30<br />
EmployeeTelephoneNo - Number, optional<br />
Salary - Number, constraint >2000,
<strong>Oracle</strong> Forms Builder<br />
100 Miss Mary<br />
Kelly<br />
101 Mr John<br />
Smith<br />
103 Mrs Mary<br />
Dow<br />
Galway 55555 2500 5/1/91<br />
Galway 66666 300 15/10/90<br />
Tuam 11111 2000 5/5/86<br />
10 Research 100<br />
10 Finance 101<br />
20 Accounts 103<br />
Insert Into Employee Values (100,’Miss’, ‘Mary Kelly’,<br />
‘Galway’, 5555, 2500, ‘5-Jan-1991’);<br />
Page 2 of 24
<strong>Oracle</strong> Forms Builder<br />
Forms Builder<br />
Record Insert,<br />
Action Save<br />
Query Enter, Query Execute<br />
Query Count Hit<br />
Name field: =Mary Kelly - returns all records where Mary<br />
Kelly is the name<br />
Name field: =% S% - returns all records where employee<br />
surname begins with S<br />
Salary field: >=2000 - returns all records where salary is<br />
greater than or equal to 2000<br />
Generate query to return records for all employees living in<br />
Galway or Tuam, :aid=’Tuam’ or :aid=’Galway’<br />
Query/Where used to enter more complex queries,<br />
:variable, e.g. :tid = ‘Miss’ and :aid = ‘Galway’<br />
Deleting record from table Record Remove<br />
:bind variable, binding to attribute in table<br />
File : Emp1.fmb or EmpForm1.fmb<br />
Page 3 of 24
<strong>Oracle</strong> Forms Builder<br />
Form designed by creating / editing objects using various<br />
Tools<br />
Layout Editor (F2), Canvas View<br />
Object Navigator (F3) uses icons to indicate object that has<br />
properties<br />
Property Palette (F4)<br />
Canvas visual surface on which items placed<br />
Form can be run within <strong>Oracle</strong> Forms Designer using Run<br />
Form icon<br />
Forms stored on local machine as .FMB files<br />
(ForM Binary)<br />
Compiled <strong>forms</strong> stored on local machine as .FMX files<br />
(ForM eXecutable)<br />
Tables stored on remote machine, Galvia<br />
Page 4 of 24
<strong>Oracle</strong> Forms Builder<br />
Triggers<br />
Block of PL/SQL code to customise application<br />
Trigger attached to specific object and executes in response<br />
to certain event<br />
Triggers associated with form, item, block, etc<br />
80 different triggers in <strong>Oracle</strong><br />
Trigger code may include calls to custom PL/SQL code<br />
called Built-Ins, e.g. message, open_form, commit,etc<br />
5 classifications of triggers: Key, On, Post, Pre, When<br />
Possible to utilise ‘Built-In’ procedures, i.e. code already<br />
written and tested<br />
250 various built-in’s:<br />
• Forms Builtins<br />
• Query Builtins<br />
• Record Builtins<br />
• Application Builtins<br />
• Misc Builtins<br />
Page 5 of 24
<strong>Oracle</strong> Forms Builder<br />
Record Built-ins<br />
CHECK_RECORD_UNIQUENESS<br />
CLEAR_RECORD<br />
CREATE_QUERIED_RECORD<br />
CREATE_RECORD<br />
DELETE_RECORD<br />
DOWN<br />
DUPLICATE_RECORD<br />
FIRST_RECORD<br />
GENERATE_SEQUENCE_NUMBER<br />
GET_RECORD_PROPERTY<br />
GO_RECORD<br />
INSERT_RECORD<br />
LAST_RECORD<br />
LOCK_RECORD<br />
NEXT_RECORD<br />
NEXT_SET<br />
PREVIOUS_RECORD<br />
SCROLL_DOWN<br />
SCROLL_UP<br />
SELECT_RECORDS<br />
SET_RECORD_PROPERTY<br />
UP<br />
UPDATE_RECORD<br />
Page 6 of 24
<strong>Oracle</strong> Forms Builder<br />
Add nine buttons to navigate through the records:<br />
First, Last, Prev, Next, Insert, Delete and Close<br />
Change Name and Label in properties window for each<br />
button<br />
Trigger is When-Button-Pressed<br />
Use following built-ins:<br />
Last_Record; Next_Record, Previous_Record,<br />
First_Record, Commit, Close_Form(‘ nameofform’),<br />
Enter_Query, Execute_Query<br />
Insert Record code:<br />
declare<br />
commit_alert Number;<br />
begin<br />
commit_alert:= show_alert('Commit');<br />
if commit_alert = alert_button1 then<br />
commit;<br />
end if;<br />
if commit_alert = alert_button2 then<br />
rollback;<br />
end if;<br />
end;<br />
Page 7 of 24
<strong>Oracle</strong> Forms Builder<br />
Delete Record code:<br />
Declare<br />
Delete_Alert Number;<br />
Begin<br />
Delete_Alert:= Show_Alert('Delete');<br />
If Delete_Alert = Alert_Button1 Then<br />
Delete_Record;<br />
Commit;<br />
End if;<br />
If Delete_Alert = Alert_Button2 Then<br />
Rollback;<br />
End if;<br />
End;<br />
Next Record Code:<br />
Begin<br />
Next_Record;<br />
If :Employeeno = Null Then<br />
message('null data encountered');<br />
message(' ');<br />
Previous_Record;<br />
Else<br />
message('not null');<br />
message(' ');<br />
End If;<br />
End;<br />
Close Form code:<br />
Page 8 of 24
<strong>Oracle</strong> Forms Builder<br />
Close_Form('**Employee');<br />
Page 9 of 24
<strong>Oracle</strong> Forms Builder<br />
Page 10 of 24
<strong>Oracle</strong> Forms Builder<br />
Need to modify the 'Requirement' value for employee number, we set this requirement in<br />
the Schema Builder<br />
Can do this manually by changing the defer_requirement_enforcement property for the<br />
Form OR we can change this requirement property by writing a program that calls the<br />
Set_Form_Property builtin to change the value of some property of a form…<br />
Create a When-New-Form-Instance trigger at the Form level<br />
Declare<br />
Form_Id formModule;<br />
Begin<br />
Form_Id := Find_Form(:System.Current_form);<br />
Set_Form_Property(Form_Id, Defer_Required_Enforcement, Property_True);<br />
message(' Welcome to Developer / 2000');<br />
message(' ');<br />
End;<br />
Page 11 of 24
<strong>Oracle</strong> Forms Builder<br />
Modify the employee form to add a bonus field. If the<br />
employee salary is greater than 3000, the employee gets a<br />
commission of 10% otherwise the employee gets a bonus<br />
of 5%<br />
Post_Change trigger associated with Salary Text Item<br />
Modify<br />
Name property for each new item, (i.e. Bonus, Total)<br />
Database item property = No<br />
Datatype = Number<br />
Display the Salary, Bonus and Total for each record.<br />
Begin<br />
Message('Salary value after changing');<br />
If :Salary > 3000 then<br />
:Bonus := :Salary * 0.10;<br />
Else<br />
:Bonus := :Salary * 0.05;<br />
End If;<br />
:Total := :Salary +:Bonus;<br />
End;<br />
Page 12 of 24
<strong>Oracle</strong> Forms Builder<br />
Add When-Validate-Item trigger to employee address field<br />
so that only values accepted are Galway, Sligo, Mayo,<br />
Roscommon and Leitrim.<br />
If a wrong value is entered, the employee address field<br />
should turn red<br />
When correct value entered, field will return to white.<br />
Use Set_Item_Property Builtin to modify the<br />
Visual_Attribute property of the Employee Address field<br />
Create an alert called Wrong_Address, set the title,<br />
message, number of buttons, button labels and default<br />
button properties of this alert.<br />
Create 2 new Visual_Attribute objects, one called<br />
White_Back and the other called Red_Back<br />
The White_Back will have the background colour set to<br />
white. The Red_Back will have the background colour set<br />
to red.<br />
Add exception code so that record will not be committed to<br />
database until the correct value in entered into the<br />
employee address field<br />
Page 13 of 24
<strong>Oracle</strong> Forms Builder<br />
Declare<br />
Item_Id Item;<br />
Alert_Button Number;<br />
Begin<br />
Item_Id:=Find_Item('Employeeaddress');<br />
If Id_Null(Item_Id) Then<br />
message('Item not found');<br />
End If;<br />
If lower(:Employeeaddress) not in ('galway','mayo','sligo', 'roscommon', 'leitrim') Then<br />
Alert_Button := Show_Alert('Wrong_Address');<br />
Set_Item_Property(Item_Id, Visual_Attribute,'Red_Back');<br />
Raise Form_Trigger_Failure;<br />
Else<br />
Set_Item_Property(Item_Id, Visual_Attribute,'White_Back');<br />
End If;<br />
End;<br />
Page 15 of 24
<strong>Oracle</strong> Forms Builder<br />
Add a command button to the canvas:<br />
Name = Hide_Btn,<br />
Label = Hide<br />
Add another command button to the canvas:<br />
Name = Other_Btn,<br />
Label = Other<br />
Create a When-Button-Pressed trigger associated with the<br />
Hide button.<br />
Set_Item_Property('Other_Btn', Visible, Property_False);<br />
Set_Item_Property(‘Last_Btn', Label, 'Final');<br />
Page 16 of 24
<strong>Oracle</strong> Forms Builder<br />
Open the Employee Form<br />
Add a new text item (name = Relocation) and new prompt<br />
(= Relocation)<br />
Set the Calculation Mode for this text item = Formula, in<br />
the Formula field enter<br />
:Total*1.1<br />
Go to the Data - > Data Type, make sure it is Number<br />
Get help on Format Mask Field - F1<br />
Go to the Data - > Format Mask and set it to "e"9,999.99<br />
Notice format for output values<br />
Go to Birthdate text item<br />
Go to the Data - > Format Mask and set it to<br />
DY DD-MONTH-YYYY BC<br />
Page 17 of 24
<strong>Oracle</strong> Forms Builder<br />
Master Detail Relationship<br />
Using the datablock wizard, create data block for Employee<br />
table<br />
In the object Navigator, highlight the data block item and<br />
select new – will create another Data Block<br />
Create a second datablock using the Department table,<br />
display all fields<br />
Notice extra tab on Data Block Wizard<br />
On Master-detail window, select Create Relationship<br />
Uncheck AUTO-JOIN check box<br />
Foreign key relationship should automatically get<br />
displayed.<br />
Run form, place cursor in employee no field and run a<br />
query<br />
Include Go_Block built-in as part of When-New-Form-<br />
Instance in order to place the cursor in the top block.<br />
Page 18 of 24
<strong>Oracle</strong> Forms Builder<br />
Notice Relations Item created under Datablocks<br />
Look at Delete Record Behavior property<br />
• Non-Isolated: Default setting. Prevents deletion of a<br />
master record when associated detail records exist in<br />
database.<br />
• Isolated: Allows master record to be deleted and does<br />
not affect associated detail records in database.<br />
• Cascading: Allows master record to be deleted and<br />
automatically deletes any associated detail records in<br />
detail block's base table at commit time.<br />
Include scroll bar on employee layout that will display 5<br />
records at a time.<br />
Run form, place cursor in dept no field and run a query<br />
Include GO_BLOCK built-in as part of When-New-Form-<br />
Instance in order to place the cursor in the top block.<br />
Page 19 of 24
<strong>Oracle</strong> Forms Builder<br />
Create a WHEN NEW FORM INSTANCE trigger for the<br />
form<br />
Each form runs / executes using same Master Document<br />
Interface (MDI)<br />
Concept of individual <strong>forms</strong> and MDI (common) form<br />
Possible to set title of MDI and individual <strong>forms</strong> by setting<br />
properties directly or by writing a PL/SQL program!!<br />
Set the CASE INSENSITIVE PROPERTY for each data<br />
item that may be queried<br />
Page 20 of 24
<strong>Oracle</strong> Forms Builder<br />
Declare<br />
Fm_Id FormModule;<br />
Begin<br />
Fm_Id :=Find_Form(:System.Current_Form);<br />
Set_Form_Property(Fm_Id,Defer_Required_Enforcement,<br />
Property_True);<br />
Set_Window_Property(Forms_Mdi_Window,Window_State,Maximize);<br />
Set_Window_Property(Forms_Mdi_Window,Title,'MDI Title' );<br />
Set_Window_Property('Window1', Window_State, Maximize);<br />
Set_Window_Property('Window1', Title, 'Form Title');<br />
End;<br />
Page 21 of 24
<strong>Oracle</strong> Forms Builder<br />
Possible to generate primary key value automatically<br />
Use Sequence – database object created by user, possible<br />
for multiple users to share access to sequence<br />
Sequences stored and generated independently of tables<br />
SQL> Create sequence name Increment by n<br />
Start with n Minvalue n Maxvalue n ;<br />
Notice no , between parameters…<br />
SQL> Select Sequence_Name, Min_Value, Last_Number<br />
From User_Sequences;<br />
SQL> Alter Sequence name increment by 10;<br />
NextVal, CurrVal<br />
SQL> Select name.NEXTVAL From Dual;<br />
SQL> Select name.CURRVAL From Dual;<br />
SQL> Insert into EMP values (name.Nextval, xxx…..);<br />
SQL> Drop Sequence name;<br />
Initial Value for Employee No property set =><br />
:Sequence.my_seq.Nextval<br />
Page 22 of 24
<strong>Oracle</strong> Forms Builder<br />
Creating Menu<br />
File -> New -> Menu<br />
Set name property = Menu<br />
Tools -> Menu Editor<br />
Page 23 of 24
<strong>Oracle</strong> Forms Builder<br />
Page 24 of 24