INTRODUCTION TO FORMS BUILDER

advertisement
Introduction To
Forms Builder
Chapter 5
Guide to Oracle10G
1
Lesson A Objectives
• Use a data block form to view, insert, update, and
delete database data
• Create a data block form that displays a single record
at a time
• Become familiar with the Object Navigator, and use
the Object Navigator to change form object names
• Use the Data Block and Layout Wizards to modify
form properties
• Create a tabular-style data block form that displays
multiple records
Guide to Oracle10G
2
Forms
• Application with a graphical user interface that looks
like a paper form
• Used to insert, update, delete and view database
data
• Count the number of records a query will retrieve
Guide to Oracle10G
3
Using A Data Block Form —
Definitions
• Block: group of related form items, such as text fields
and option buttons
• Data block: corresponds to a specific database
table, and contains objects, such as text fields or
option buttons, that display values from the table’s
data fields
• Data block form: one or more data blocks
• Text items: display text input fields
Guide to Oracle10G
4
Forms Services Window
• Form menu contains selections that allow you to
manipulate the form
• Has a toolbar with buttons to insert, view, modify, and
delete records
• At bottom of the window are lines that display
information about form status
• Query button group allows you to query data, has two
modes:
– Normal mode - can view data records, insert new records,
sequentially step through the records, and change data
values
– Enter Query mode - can enter a search expression in one of
the form fields, and then retrieve the associated records
Guide to Oracle10G
5
Forms Services Window
Guide to Oracle10G
6
Using a Form to View Table Records
• Retrieve specific table records:
– Click the Enter Query button
– Type a search expression in one or more of the form text
items
– Click the Execute Query button
• Retrieve all of the records in a table
– Place form in Enter Query mode and do not type search
condition
Guide to Oracle10G
7
Using a Form to Insert,
Update, and Delete Records
• To insert:
– Use blank record that appears when opening a form or as
last line of query results
– In normal mode, click the insert record button, type data
values and click the Save button
• To update:
– Retrieve record with a query, modify field and save
• To delete:
– Retrieve record with a query, use Remove Record button to
delete
Guide to Oracle10G
8
Viewing and Interpreting Form Errors
• Some errors are detected, or trapped, within the form
and form issues the error message
• Other errors are not detected until the form sends the
data values to the database and Oracle DBMS issues
the error message
• To view information on database errors:
– Click Help menu, Display Error
– Dialog box displays error information
Guide to Oracle10G
9
Viewing Information
About Database Error
Guide to Oracle10G
10
Closing a Form and Committing
Changes
• To close a form:
– Click Exit button
– Click Action on the form menu and then click Exit
– Close browser window
• If unsaved changes exist, dialog box will prompt to
save changes
Guide to Oracle10G
11
Creating a Data Block Form
• When creating a form for a table, Forms
Builder automatically creates:
– Labels
– Text entry fields
– Insert, update and delete and select
queries
Guide to Oracle10G
12
The Object Navigator
Guide to Oracle10G
13
Creating a New Data Block Form
• Create a new form module
• Create a new data block using:
– Data block wizard
– Manual process
• Using Data Block Wizard:
– Select table name
– Move editable fields from Available Columns list to Database
Items list
• Use Layout Wizard to create form layout
Guide to Oracle10G
14
Layout Editor
• Use to customize form display
• Can add images and static text to
enhance form appearance
Guide to Oracle10G
15
Layout Editor
Guide to Oracle10G
16
Running a Form
• Click Run Form button
• Form is compiled into a .fmx file for execution
• A text file with same name as form and .err
extension holds errors that occur when
running form
Guide to Oracle10G
17
Form Components
and the Object Navigator
• Use Object Navigator to view information
about form components
• Use buttons to expand and collapse form
items
• Use Ownership View to group logically
associated components together
• Use Visual View to group visually associated
components
• Can rename objects
Guide to Oracle10G
18
Modifying Forms Using the
Data Block Wizard and Layout
Wizard
• Wizards can be used to modify existing
forms and layouts in reentrant mode
• Start wizard when component is
selected to modify component
Guide to Oracle10G
19
Creating a Form to
Display Multiple Records
• Use tabular layout to edit multiple table records at the
same time
Guide to Oracle10G
20
Lesson B Objectives
• Create a data block form that is based on a database
view
• Learn how to modify form properties to improve form
appearance and function
• Create a master-detail form that contains multiple
data blocks
• Format form text items using format masks
Guide to Oracle10G
21
Creating a Form Based on
a Database View
• Similar to form based on table but read-only
Guide to Oracle10G
22
Modifying Form Properties
Guide to Oracle10G
23
Modifying Form Properties
• Use Property Palette of form object to modify
desired properties
– To access: right click object, select Property
Palette from menu
– Intersection mode modifies properties for multiple
objects at the same time
– To open in intersection mode, select multiple
objects before opening Property Palette
Guide to Oracle10G
24
Property Palette
Guide to Oracle10G
25
Modifying Form Prompts and Prompt
Properties Using the Layout Editor
• Edit prompts by changing text in layout editor
• Resize frame to realign items and view
changes
• Use layout editor to modify font and point size
of prompts
Guide to Oracle10G
26
Modifying Text Item Properties
Using the Property Palette
Guide to Oracle10G
27
Creating a Data Block Form that
Displays Data from Multiple Tables
• Can create data block forms that display data from
multiple database tables which have master-detail
relationships
• Master-detail relationship: one database record has
multiple related records through foreign key
relationships
• Use data block wizard to create master block (for
master table) first
Guide to Oracle10G
28
Creating a Data Block Form that
Displays Data from Multiple Tables
• Create detail blocks next and specify relationship on
master-detail tab
– Use auto-join to allow Forms Builder to decide on join
condition
– Use manual join to specify join fields
• Code is added to link form blocks together so that
when new master is selected, new detail appears
Guide to Oracle10G
29
Multiple Master-Detail Blocks
Guide to Oracle10G
30
Using Format Masks
to Format Character Strings
Guide to Oracle10G
31
Lesson C Objectives
• Use sequences to automatically generate primary
key values in a form
• Become familiar with different form items that you
can use to enter and modify data values
Guide to Oracle10G
32
Using Sequences to Generate
Primary Key Values
• Form can be set up to automatically retrieve next
sequence number and populate primary key field
• Form triggers respond to user events or system
actions
• To create a trigger, specify:
– Trigger’s object (i.e. specific button)
– Trigger event (i.e. button press)
– Code that executes
• Use PRE-FORM event to perform action when form
loads
• Use Triggers dialog box to create triggers for objects
Guide to Oracle10G
33
PL/SQL Editor
Guide to Oracle10G
34
Using PL/SQL to Create Form
Trigger
• Type code to select next sequence value
• Refer to form item (ID text entry field) as
:block_name.item_name
• Compile code before use to check for syntax
errors
• Must connect to database before compiling
code
• PL/SQL editor displays syntax errors
Guide to Oracle10G
35
Syntax Error in PL/SQL Editor
Guide to Oracle10G
36
Representing Data Values
Using Other Item Types
• Use radio buttons and checkboxes instead of text
fields for data entry
• Radio buttons represent small list of mutually
exclusive values. Limits user to one of two or more
related, mutually exclusive choices
• To use radio buttons:
– Create a radio group containing mutually exclusive radio
buttons
– Specify radio buttons rather than text for item type when
creating form layout
– Create individual radio buttons on canvas using radio button
tool
Guide
to Oracle10G
– Specify initial value for
radio
group using Property Palette 37
Creating Checkboxes
• Use to represent choice of two opposing
values (i.e. On/Off)
• Use label to indicate what checked value
represents
• Configure “Value when Checked” and “Value
when Unchecked” to specify actual database
values
• Can specify a third value that checkbox has
when unmodified (such as NULL)
Guide to Oracle10G
38
Summary
• Forms Builder is used to provide users with graphical
user interface for manipulating database objects
• Form can represent one or more tables
• Form can be used to view, create, update and delete
table data
• Form can be used to view data based on database
views
• Use wizards to create and modify form information
• Use PL/SQL editor to edit, compile and debug code
• Actions can be associated with form objects and
events via Form Triggers
Guide to Oracle10G
39
Download