guide to oracle10g1 introduction to forms builder chapter 5

39
Guide to Oracle10G 1 Introduction To Forms Builder Chapter 5

Upload: kellie-little

Post on 19-Dec-2015

216 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 1

Introduction ToForms Builder

Chapter 5

Page 2: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 2

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

Page 3: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 3

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

Page 4: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 4

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

Page 5: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 5

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

Page 6: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 6

Forms Services Window

Page 7: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 7

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

Page 8: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 8

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

Page 9: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 9

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

Page 10: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 10

Viewing Information About Database Error

Page 11: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 11

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

Page 12: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 12

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

Page 13: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 13

The Object Navigator

Page 14: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 14

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

Page 15: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 15

Layout Editor

• Use to customize form display

• Can add images and static text to enhance form appearance

Page 16: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 16

Layout Editor

Page 17: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 17

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

Page 18: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 18

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

Page 19: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 19

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

Page 20: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 20

Creating a Form to Display Multiple Records

• Use tabular layout to edit multiple table records at the same time

Page 21: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 21

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

Page 22: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 22

Creating a Form Based on a Database View

• Similar to form based on table but read-only

Page 23: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 23

Modifying Form Properties

Page 24: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 24

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

Page 25: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 25

Property Palette

Page 26: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 26

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

Page 27: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 27

Modifying Text Item Properties Using the Property Palette

Page 28: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 28

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

Page 29: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 29

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

Page 30: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 30

Multiple Master-Detail Blocks

Page 31: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 31

Using Format Masks to Format Character Strings

Page 32: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 32

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

Page 33: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 33

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

Page 34: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 34

PL/SQL Editor

Page 35: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 35

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

Page 36: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 36

Syntax Error in PL/SQL Editor

Page 37: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 37

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– Specify initial value for radio group using Property Palette

Page 38: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 38

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)

Page 39: Guide to Oracle10G1 Introduction To Forms Builder Chapter 5

Guide to Oracle10G 39

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