Advanced Forms Features: Triggers, LOV

Download Report

Transcript Advanced Forms Features: Triggers, LOV

Chapter 5B-C:
Introduction to Forms Builder:
Tiggers, LOV
Lesson B Objectives
After completing this lesson, you should be able to:
• Create a data block form that is based on a
database view [Same as using single table]
• Create a master-detail form that contains multiple
data blocks [Done in Oracle Lab 7]
• Format form text items using format masks
Using Format Masks to Format
Character Strings
• Format mask
– Same as format model
– Set using Property Palette
– Proceeded by FM
999.99 :for numeric fields
MM/DD/YYYY : for dates
• Example of format mask for phone number:
FM “(”999“)”999“-”9999
• To set the format mask
Open the form in the Layout Editor
Select the text item you want to apply the format to
Right-click and select Property Palette
In the Data property node, type the mask in the Format Mask
text box
Lesson C Objectives
After completing this lesson, you should be able to:
• Use sequences to automatically generate primary
key values in a form
• Create lists of values (LOVs) to provide lists for
foreign key values
• Describe the different form items that you can use
to enter and modify data values
Using Sequences to Generate Primary
Key Values
• Users may make mistakes entering primary key
• Use sequence to generate key
– Create sequence in database
– Create a trigger (PL/SQL program)
• that you link to the text item object representing
the primary key value on a form
• that inserts the primary key value from the
sequence when a user takes action to create a new
Creating Form Triggers
• Form trigger
– Program unit in form that runs in response to event
– Associated with form object
• Event
– User action like clicking a button
– System action like loading or exiting a form
• Trigger firing means …
– The trigger runs.
Creating Form Triggers
• Built-in events that can be associated with form triggers
• The triggers to be written in PL/SQL editor will fire when
event occurs
Triggers dialog box
showing block events
that can be associated
with triggers
Creating Form Triggers (continued)
• Implicit cursor can be used to retrieve the next
sequence value into a form’s text item
• General syntax
SELECT field_name
INTO variable_name
FROM table_name
WHERE search condition;
• Syntax for retrieving next sequence value into the
form’s loc_id text item
SELECT loc_id_sequence.NEXTVAL
INTO :location.loc_id
FROM dual;
• loc_id_sequence must
be created in the database
• : must be added to refence a
form’s text item in PL/SQL
Create a trigger for inserting loc_id when a
new record is to be created using
Show how (p. 354-360)
Creating a List of Values (LOV)
• List of values (LOV)
– Pronounced ell-oh-vee
– Displays list of possible data values for text
• LOV display
– Dialog box displays possible choices for form
text item
• Record group
– Form object that represents data in tabular
– Provides values for LOV
Creating a List of Values (LOV)
Show how (p. 364-376)