Download Chapter5

Document related concepts

Clusterpoint wikipedia , lookup

Relational model wikipedia , lookup

Functional Database Model wikipedia , lookup

Extensible Storage Engine wikipedia , lookup

Database model wikipedia , lookup

Transcript
Enhanced Guide to Oracle 10g
Chapter 5:
Introduction To Form Builder
1
Forms


Why Do We Use Form Builder?
Why Don’t We Use SQL Only?!
2
Forms


Application with a graphical user
interface that looks like a paper
form
Used to insert, update, delete and
view database data
3
Primary Form Uses



Viewing/retrieving records
Inserting/updating/deleting
records
Counting the number of records a
query will retrieve
4
Data Block Forms
 Form associated with a specific
Oracle database table
 System automatically creates:
 Text fields associated with table
fields
 Programs for inserting, modifying,
deleting, and viewing data records
5
Data Block Forms
 ORACLE 10g forms are displayed
on web browser as a web page.
 They are displayed in Forms
Services Window.
 The form specification is
translated into Java Applet.
 They are Dynamic Web Pages.
6
Steps of running the form
 Design the form and write its code
(.fmb file)
 Compile the form (.fmx file)
When you run the form:
 OC4J Instance process converts
the compiled file into java applet
 Java applet form starts on the web
browser
7
Form Modes

Normal


You can view records and sequentially step
through records
Enter Query


You can enter search parameters in form
fields and then retrieve the associated
records
To place the form in Enter Query mode,
click the Enter Query button
8
Inserting New Records



In Normal mode, click the Insert Record
button
to insert a new blank record
Type the data values in the form fields
Click the Save button
to save the
values in the database
9
Retrieving Records



Click the Enter Query button
to
place the form in Enter Query mode
Type a search condition
Click the Execute Query button
to
retrieve selected records

If you click
, do not enter a search
condition, and then click
, all table
records will be retrieved
10
Form Search Types


Exact search: only retrieves records
that exactly match the entered search
condition
Restricted search: retrieves records
that fall within a range of values
11
Restricted Search Operators
 _: wildcard replacing a single character
 %: wildcard replacing multiple
characters
 >, <: greater than, less than
 >=, <=: greater than or equal to, less
than or equal to
 <> or !=: not equal to
12
Scrolling Through Retrieved
Records


To view the next record, click the Next
Record button
To view the previous record, click the
Previous Record button
13
Updating and Deleting
Records

Retrieve the record to be updated
or deleted


To update, change the data value and
click the Save button
To delete, click the Remove Record
button
14
Data Block Form File Types
 .fmb
 Form design file, used by form
programmer in Form Builder
 .fmx
 Form executable file, run by form
users
15
Form Components
 Form module: form application
 Form window
 Title bar on top
 Horizontal and vertical scrollbars
 Can be resized, maximized,
minimized
16
Form Components
 Canvas
 Surface that displays form items
 Block
 Object that contains form items
 Form items
 Command buttons, radio (option) buttons, text
items
 Items in the same block can appear on different
canvases
17
Form Components
Name
Cash
Window
Canvas
Block of items
Check
Credit Card
18
Object Navigator
 Forms Builder Toolbar.
 Form Module.
 Hierarchical Display.
19
Creating a Data Block Form
 Steps:
1. Create the data block using the
Data Block Wizard
2. Create the form layout using the
Layout Wizard
20
Data Block Wizard
 Welcome page
 Type page
 Select table or view on which to base the block
source
 Table page
 Select table associated with form
 Enforce Integrity Constraint Check Box
 Finish page
 Option to use the Layout Wizard to automate
creating the layout
21
Layout Wizard
 Canvas page
 Select the canvas where the block is displayed
 Data Block page
 Select the fields that are displayed on the layout
 Items page
 Specify the column labels, heights and widths
 Style page
 Specify to create a form- or tabular-style layout
22
Layout Styles
 Form style
 One record appears on the form at a
time
 Tabular style
 Multiple records display on the form in
a table
23
Form Builder Wizards
Are Re-entrant
 You can select a block or layout, then re-enter it
and modify its properties using the Wizard
 A Wizard is in re-entrant mode when its pages
appear as tabs
24
Form Builder
Object Navigator Window
 Shows form objects
 Allows developer to access form objects
 Object Navigator has 2 views
 Ownership view: shows form objects as a
flat list
 Visual view: hierarchical relationships
between objects
25
Guidelines For Configuring
Form Windows
1.
2.
3.
4.
5.
6.
Change the window title
Allow user to minimize the window
Do not allow the user to maximize the
window
Do not allow the user to resize the window
Include horizontal and vertical scrollbars if
items appear beyond window boundaries
Make the form window fill the Forms
Runtime window
26
Configuring Form Windows
Window
Title
Minimize/
Maximize buttons
Window
size
27
Creating a Form Based on a
Database View



View can be derived from one or more
database tables
Form based on a view allows you to
display data from table(s)
Form could be used to insert, update,
or delete data if the view is a simple
view only.
28
Modifying Form Properties

Property
Nodes
Every form object has a Property
Palette that allows you to configure
form properties
Property List
29
Intersection Property Palette

Used to change property of several
items to the same value


Intersection/Union button appears as
Name appears as *****
30
Frame Properties

Update Layout

Automatically


Manually



Frame items are automatically repositioned based on
their order in the Data Blocks list when you move or
resize a frame, or modify the form layout using the
Layout Wizard in reentrant mode
Items are automatically when layout is modified in
Layout Wizard in reentrant mode
Items are not repositioned if you move or resize the
frame
Locked

Items are never automatically repositioned
31
Multiple-Table Forms
 Data block forms can display data from
multiple tables that have a master-detail
relationship
 Master record has multiple related detail
records
 Examples:
 One ITEM record has multiple related INVENTORY
records
 One CUSTOMER might have multiple CUST_ORDER
records
32
Master-Detail Forms
Master block
Detail block
33
Creating a Master-Detail Form


Create the
master block
first
Specify the
relationship
on the Data
Block Wizard
Master-Detail
page of the
detail block
34
Complex Master-Detail
Relationships
 A master block can have multiple detail blocks
 An item can be in multiple customer orders, and have
multiple shipment records
 A detail block can be a master block in a second
master-detail relationship
 A customer can have multiple CUST_ORDER records
 One CUST_ORDER record can have multiple
ORDER_LINE records
35
Complex Master-Detail
Relationship Example
Master
Detail
Detail
Master
36
Formatting Text Items

Specify desired format mask in text
item Format Mask property

If format mask makes value wider than
text item Data Width property, data
appears as #####

E.g: make the format mask for the empno field
in the form builder: 99”- - “ 99 and make the
data length for the field 4.
37
Formatting Character Text
Items

Place embedded characters in double
quotes
38
Format Mask Examples

Value
Format Mask
Result
7945
999
###
7945
9999$
7945$
7945
99”-”99
79-45
34.28
99.9
34.3
34.28
99.999
34.280
SYSDATE Day-MON-YY Friday-NOV-06
39
Form Triggers
 PL/SQL procedure that runs in response to a
user or system action
 Clicking a button
 Loading a form
 Exiting a form
 Triggers can be associated with:
 An entire form (form level)
 A block (block level)
 A specific form item (item level)
40
Using Form Triggers
 Creating a trigger:
 select the form or form item event
 type the trigger code
 Referencing a form item in PL/SQL code:
 :block_name.item_name
 Triggers are compiled before a form is run
41
Using Sequences in Forms
 Create a block-level WHEN-CREATERECORD trigger
 Trigger PL/SQL code:
SELECT sequence_name.NEXTVAL
INTO :block_name.item_name
FROM DUAL;
42
Form Lists of Values (LOVs)
 List of legal values that can be selected
for use in a form field
LOV
command
button
LOV
display
43
Creating an LOV Using the
LOV Wizard
1.
Use the LOV Wizard to:



2.
Specify the LOV display records using
a SQL query
Format the LOV display
Attach the LOV to a form text item
Change the LOV and record group
name in the Object Navigator
44
Opening the LOV Display


Place the insertion point in the text item
to which the LOV is attached
Press CTRL+L, or from Edit menu of the
form choose the option ‘Display List’
45
Creating a Command Button
to Open the LOV Display
 Create a command button on the
canvas
 Iconic button
 Displays an icon image from an .ico file
 Complete path to .ico file must be specified
in button’s ICON property
46
LOV Command Button Trigger
 Create a trigger for the button that
does the following:
1.
Places the form insertion point in the text
item to which the LOV is attached:
GO_ITEM(‘IN_VID’);
2.
Executes the LIST_VALUES command:
LIST_VALUES;
47
Alternate Form Input Items


Radio buttons
Check boxes
48
Radio Buttons
 Limits user to one of two or more
related, mutually exclusive choices
49
Radio Groups
 Related radio
buttons are part of
a radio group
Radio group
Individual related
radio buttons
50
Creating a Radio Group
1.
2.
3.
4.
5.
Create the form using the Data Block and
Layout Wizards
Open the item Property Palette, and change
the Item Type value to Radio Group
Draw and format the radio buttons on the
canvas
Modify the radio button properties
Modify the radio group properties
51
Important Radio Button
Properties
Name: how the
button is
referenced
within the form
Label: description that
appears next to the
button on the canvas
Radio Button Value:
associated data value
in the database
52
Important Radio Group
Properties
Name: how the
radio group is
referenced
within the form
Initial Value: data value
of the radio button
within the radio group
that is selected when
the form first appears
53
Check Boxes


Used to represent fields that can
have one of two values
Check box caption is interpreted as
TRUE or FALSE


If checked, caption is true
If cleared, caption is false
54
Check Box Example
55
Creating a Check Box
1.
2.
3.
Create the form using the Data Block
and Layout Wizards
Open the item Property Palette, and
change the Item Type value to Check
Box
Modify the item properties
56
Important Check Box
Properties
Label: description that
appears next to the check
box on the canvas
Value when Checked: data
value of the item when the
box is checked
Value when Unchecked:
data value of the item when
the box is checked
Check Box Mapping of
Other Values: check
box status when form
first opens, or when new
blank record is added
57