Вы находитесь на странице: 1из 73

Enhanced Guide to Oracle 10g

Chapter 5:
Introduction To Form Builder

 Why Do We Use Form Builder?
 Why Don’t We Use SQL Only?!

 Application with a graphical user
interface that looks like a paper
 Used to insert, update, delete and
view database data

Primary Form Uses

 Viewing/retrieving records
 Inserting/updating/deleting
 Counting the number of records a
query will retrieve

Data Block Form
 Is a form associated with a
specific Oracle database table
 System automatically creates:
 Text fields associated with table
 Programs for inserting, modifying,
deleting, and viewing data records

Data Block Forms
 ORACLE 10g forms are displayed in a web
browser as a web page.
 They appear in the Forms Services Window
within the browser window.
 The form specification is translated into Java
Applet (those are displayed in web browsers)
using a Web server process called OC4J
Instant (details: page 264, next slide too).
 They are Dynamic Web Pages.

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
Using a Data Block Form

 A block is a group of related form items (text

fields, option buttons,…).
 A data block is a specific DB table, and contains
objects (text fields, option buttons) that display
values from the table’s data fields.
 A single-block form: is the form that displays data
from only one table.
 A multiple-block form: is the form that displays
data from multiple DB tables.

Using a Data Block Form

 To start Form Builder:

 Start, All programs, Oracle Developer Suit-OraHome, Forms
Developer, Forms Builder
 Open an existing for (.fmb) or design yours and save it (the
path name or the form name should not contain spaces).
 To run the form, click Program on the menu bar, Run Form.

 If you are asked to install the Jinitiator, click yes and accept
all default values.
 Jinitiator application iniitializes the Java applet in the web

Expected Errors

 If the error “FRM-90928” appears, it means that

the path name or the form name contains space.

 If the web page does not appear and the browser

diplays the characters http://%%20 or similar.
Then the form builder should be configured
correctly to use your web browser. (see page 266
to know how to configure it).

Form Modes
 When the form is running in the Forms Services window
in the web browser it can be one of two modes:
 Normal Mode
 You can view records and sequentially step through records and
change data.
 Enter Query Mode
 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 on the toolbar.
 Execute the query or cancel it to return to Normal mode.

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

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
Form Search Types
 Exact search: only retrieves records
that exactly match the entered search
 Restricted search: retrieves records
that fall within a range of values

Restricted Search Operators
 _: wildcard replacing a single character
 %: wildcard replacing multiple
 >, <: greater than, less than
 >=, <=: greater than or equal to, less
than or equal to
 <> or !=: not equal to

Scrolling Through Retrieved
 To view the next record, click the Next
Record button
 To view the previous record, click the
Previous Record button

Updating and Deleting
 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

Data Block Form File Types
 .fmb
 Form design file, used by form
programmer in Form Builder
 .fmx
 Form executable file, run by form

Form Components
 Form module: form application
 Form window
 Title bar on top
 Horizontal and vertical scrollbars
 Can be resized, maximized,

Form Components
 Canvas
 Surface that displays form items
 Block
 Object that contains form items
 Form items
 Command buttons, radio (option) buttons, text
 Items in the same block can appear on different

Form Components
Name Canvas

Cash Block of items

Credit Card

Object Navigator
 Forms Builder Toolbar.
 Form Module. See Page 276, next
 Hierarchical Display.

To create a new
Form module or
Data block..

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

Data Block Wizard
 Welcome page
 Type page
 Select table or view on which to base the block
 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
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

Layout Styles
 Form style
 One record appears on the form at a
 Tabular style
 Multiple records display on the form in
a table

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

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 (the form
is presented as a top-level object, and then lists all form
object nodes on the next level) . (fig. 5-8, slide 23)

 Visual view: hierarchical relationships between objects (

form objects contain other objects: a form contains
windows, a window contains canvases and a canvas
contains data blocks).(fig. 5-27, next slide)
 Details about ownership and visual views is in page 300.

Guidelines For Configuring
Form Windows
1. Change the window title
2. Allow user to minimize the window
3. Do not allow the user to maximize the
4. Do not allow the user to resize the window
5. Include horizontal and vertical scrollbars if
items appear beyond window boundaries
6. Make the form window fill the Forms
Runtime window
Configuring Form Windows

Window Minimize/ Window

Title Maximize buttons size
Example: create a Data Block using

1. Click on the Data Block node under the MODULE form node.
2. Click the + sign or choose create from Edit on the menu bar.
3. The following window appears:
4. Choose the first option, now
5. Then the Ok 
6. A Welcome page might appear,
if so click next
7. The wizard window appears
as shown next slide:

Example: create a Data Block using

8. Make sure the table or view is selected, now. Then NEXT

9. The tables window appears so as to choose the table from your
schema, which the data block is based on.
10. You might need to connect to the DB, if you
are not doing yet.
Choose the connect button
or connect from file on the menu bar.
11. Select the table, pay attention to the user.
12. After that choose the field you want to show.
13. Type the data block name.
14. Then choose “create the data block, and
then call the layout wizard, then FINISH.

Example: create a Data Block using
15. The form layout specifies how a given form looks to the user. So a
welcome window might appear, click next.
16. Then a Canvas (the area where the form objects are located)
window appear, choose the canvas and its type. For details about the
types refer to page 285.
17. The Data block page appear
so you can choose the fields
that will be displayed in
the form. Fig. 5-18.
18. Then the items page appears,
where the specifications and
labels (prompts) can be
Example: create a Data Block using
19. You can change the prompts (labels that appears next to each field).
20. Then choose whether the layout style is FORM or Tabular.
21. If form is chosen, then determine the title that appears on the frame
of the data block, the number of rows that appear in the form style
is always one row at a time. If the tabular is chosen, then number
can be more. The distance between record is determined in a tabular
case. Choose whether to display the scroll bar.
22. Finish.
23. The window should appear as in next slide:

Example: create a Data Block using
24. You can import a static image to make your form looks better:
1. Click on the layout editor window shown in the previous slide.
2. From EDIT choose import  image.
3. Select the image you like.
4. Adjust its place on the window.
25. To run the form so as to see the data of the table:
1. Run the form using the button
or from Program on the menu bar choose run form.
If the “FRM-10142” error appears, then run the OC4J instant of the form
If the HTML code appears instead of the form on your browser then do the
from IE chose tools  Internet Options  Advanced  Look for Security
value then Check the “allow active controls to run in files on my computer”.

Lesson B

Creating a Form Based on a
Database View
 View can be derived from one or more database
 Form based on a view only 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.
 How to do that ? Select Views from Figure 5-12,
see slide 35 when you create the form using the
Modifying Form Properties
 Every form object has a Property Palette that allows you to configure
form and its objects properties (page 322)
 How to open the property palette? From the Object navigator chose
windows node, select your window and right click the mouse, choose
property palette. OR:
 On the layout editor, right click and then select property palette. OR:
 See page 323 for other two ways.

Context bar
Nodes Property List
Intersection Property Palette
 Used to change property of several items to the same value (page 328)
 Select the objects together and open the property palette.
 Intersection/Union button on the tool bar appears as

 When the objects have different values, it appears as *****, and

the property node appears with a ? Before it.

Frame Properties
 The frame is that encloses a data block’s items.
 Its update Layout can be:
 Automatically

 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
 Manually
 Items are automatically when layout is
modified in Layout Wizard in reentrant frame
 Items are not repositioned if you move or
resize the frame
 Locked
 Items are never automatically repositioned
Multiple-Table Forms
 Data block forms can display data from multiple tables that have a
master-detail relationship in which
 Master record can have multiple related (detail) records through
foreign key relationship.
 Examples:
 One FACULTY record can have multiple related STUDENT
records. The FACUTLY record is the master record, because a
faculty member can have many student records, but a
student can have only one related faculty record.

 One CUSTOMER might have multiple CUST_ORDER records

Multiple-Table Forms
1. When creating a form that contains a master-detail relationship,
you always use the Data Block Wizard to create the master
block, which is the block that displays the master records first.
2. Then start the wizard a second time, and create the detail block,
which displays the detail records.
 When creating the detail block, the master-detail relationship
should be specified in the wizard on a page called Master_Detail
 That page appears only when you create a data block that already
contains one or more data blocks.

Master-Detail Forms

Master block

Detail block

Creating a Master-Detail Form
 Create the
master block
 Specify the
on the Data
Block Wizard
page of the
detail block

Complex Master-Detail
 A master block can have multiple detail blocks
 An item can be in multiple customer orders, and have
multiple shipment records
 A student has an advisor and also enrolled in courses. page 342.
 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
 A faculty member can have many students and a student can be
enrolled in many classes. Page 342.
Complex Master-Detail
Relationship Example

Detail Master

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.

Formatting Character Text
 Place embedded characters in double

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

Lesson C

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)

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

Using Sequences in Forms
 Create a block-level WHEN-CREATE-
RECORD trigger

 Trigger PL/SQL code:

SELECT sequence_name.NEXTVAL
INTO :block_name.item_name

Form Lists of Values (LOVs)
 List of legal values that can be selected
for use in a form field


Creating an LOV Using the
LOV Wizard
1. Use the LOV Wizard to:
 Specify the LOV display records using
a SQL query
 Format the LOV display
 Attach the LOV to a form text item
2. Change the LOV and record group
name in the Object Navigator

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’

Creating a Command Button
to Open the LOV Display
 Create a command button on the
 Iconic button
 Displays an icon image from an .ico file
 Complete path to .ico file must be specified
in button’s ICON property

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:

2. Executes the LIST_VALUES command:


Alternate Form Input Items
 Radio buttons
 Check boxes

Radio Buttons
 Limits user to one of two or more
related, mutually exclusive choices

Radio Groups
 Related radio
buttons are part of
a radio group

Radio group

Individual related
radio buttons

Creating a Radio Group
1. Create the form using the Data Block and
Layout Wizards
2. Open the item Property Palette, and change
the Item Type value to Radio Group
3. Draw and format the radio buttons on the
4. Modify the radio button properties
5. Modify the radio group properties

Important Radio Button
Name: how the
button is
within the form

Label: description that

appears next to the
button on the canvas

Radio Button Value:

associated data value
in the database

Important Radio Group

Name: how the

radio group is
within the form

Initial Value: data value

of the radio button
within the radio group
that is selected when
the form first appears

Check Boxes
 Used to represent fields that can
have one of two values
 Check box caption is interpreted as
 If checked, caption is true
 If cleared, caption is false

Check Box Example

Creating a Check Box
1. Create the form using the Data Block
and Layout Wizards
2. Open the item Property Palette, and
change the Item Type value to Check
3. Modify the item properties

Important Check Box
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
Thank you.