Você está na página 1de 209

Date :

Presenter :
The only thing more powerful than a great idea,
is a great idea powerfully executed.
- William Blake

Copyright 2003 Wipro Technologies

Oracle Forms 6i

Objectives
After you complete this lesson, you should be able to Describe the following :

Oracle Developer : Features and Benefits


Project Builder
Form Builder
Graphics Builder
Report Builder
Procedure Builder
Query Builder
Schema Builder
Translation Builder

Developer Features & Benefits


Oracle Developer offers the following features and benefits:

Productivity enhancements
Web deployment of applications
Scalability
Openness

Productivity
Oracle Developer employs :
Rapid application design (RAD) techniques.
Object orientation.
Built-in computer-based training.
A unified client-server architecture.

Web Deployment
Oracle Developer takes advantage of the ease and accessibility of the Web.

Scalability
Oracle Developer's flexible multi-tier architecture supports :
Oracle7 and Oracle8 application servers or
Third-party application servers

Openness
Oracle Developer offers integration with :
Oracle databases.
Rdb, SQL Server, Informix, Sybase, and DB/2.
Database access is provided through:
ODBC database drivers.
Oracle Gateways.

Project Builder
It helps you to :
Organize and maintain the many different files that make up an application.

Form Builder
It is a development tool for :
Building applications that accesses information stored in a database.
can also call reports and graphics.

They

Graphics Builder
It enables you to :
Produce interactive graphical displays .

Report Builder
It enables you to :
Develop production-quality reports in a Client/Server and Web environment.
To deploying reports on the Web use :
Reports Server
Reports Web CGI or Reports Cartridge.

Procedure Builder
It is a unified environment for :
Developing and maintaining C/S application code.

Query Builder
Displays :
Your tables graphically. Providing visual assistance as you use the point-and-click
interface to create a single query.

Schema Builder
Schema Builder is a graphical tool that enables you to :

Create,

Copy,

Modify,

Remove database objects and their relationships.

Oracle Translation Builder


Oracle Translation Builder supports and manages translations of text extracted
from both :
Oracle resource files, such as Oracle Developer applications,
Non-Oracle resource files, such as Microsoft Windows (.rc) and HTML files.

Recap

Oracle Developer: Features and Benefits


Project Builder
Form Builder and Graphics Builder
Report Builder
Procedure Builder
Query Builder
Schema Builder
Translation Builder

Review Questions

Understanding the People


Your success is directly related to how well you understand your users-the
tasks they perform.

Creating your standards

Oracle Developer standards mechanisms

Object Library (Form Builder) :


Object Group (Form Builder)
Visual attributes (Form Builder)
Template (Form Builder, Report Builder)

Recap
Creating an Effective Form
Guidelines for building forms
Designing messages

Review Questions

2
Oracle Form Module

The Form Module


F o r m M o d u le

T rig g e rs
B lo c k s

T r ig g e rs

Ite m s

R e la tio n s

T rig g e rs
C a n v a s -v ie w s
W in d o w s
A le r ts
E d ito rs
R e c o rd G ro u p s
LO Vs
P r o g r a m m in g O b je c ts

Programming Objects

P r o g r a m m in g O b je c ts
V is u a l A ttr ib u te s
P r o p e r t y C la s s e s
T r ig g e rs
O b je c t G r o u p s
O b je c t G r o u p C h ild r e n
P a r a m e te rs
P r o g r a m U n its
S p e c ific a tio n

R e fe re n c e s
A tta c h e d L ib r a r ie s

R e fe re n c e d b y

Building a Simple Form

Connecting to ORACLE Database

Creating Data Blocks

Data and Control Block

Control Block

Data Block

Compile and Run Form

Querying a Form

Records
Fetched
Table

Records Buffered

Block Display

SELECT statement

Work File

Retrieving Data

Restricted Query

Unrestricted Query
A

1
2
3
4

1
2
3
4

A
1
2
3
4

D
1
2
3
4

Database

Recap
The Form Module Objects
The Programming Objects

Review Questions

3
Master / Detail Relationships

Master / Detail Relationships


A master-detail relationship is an association between two base table blocks:

A master block
A detail block.

It reflects a primary key to foreign key relationship between the tables on which
the blocks are based.

The relation Object


You define a master-detail relationship between blocks by :
Create the relation in the New Block window at the same time you create
the detail block for that relation.
Creating and Setting the properties of a relation object.

Setting properties that effect co-ordination

Master Deletes

Coordination

Prevent Master-less Operation

Properties
Master Deletes Properties:
Non-Isolated
Isolated
Cascading
Coordination Properties:
Immediate
Deferred with Auto-Query
Deferred with No Auto-query

Recap

The Relation Object


Creating a Master / Detail Relation
Creating A Relation in the New Block window
Creating a Relation in the Object Navigator
Setting Properties that Affect Coordination
Preventing Masterless Operations in the Detail Block

Review Questions

Hands-On-Exercise 1, 2

4
The Layout Editor and The Property Window

The Layout Editor


It is a graphical design facility for creating and arranging :
Interface items
Boilerplate text
Graphics in a form.
You work on a single canvas-view. Canvas-views are displayed in windows at
runtime.

Form Builder Layout Editor

ToolBar

Ruler

ToolPalette

Selecting Objects in the Layout Editor


You select objects in the Layout Editor when you want to :
Resize, cut, copy, or move them,
Format them by setting font, color, and pattern visual attributes

Notes

Notes

Notes

The Property Window

Find field

Property Value

Property Name

Notes

Recap
The layout editor
Creating Items
The property window

Review Questions

5
Defining Block Items

Defining Buttons
Buttons are interface items that operators select to execute commands or
initiate actions.

Defining Check Boxes


A check box is a two-state control that indicates whether a certain condition
or value is

on or off,
true or false.

Check Box
The display state of a check box is always either checked or unchecked.

Defining Display Items


Display items only store and display fetched or assigned values.
Display items are generally used as boilerplate or as conditional text.

Defining List Items


A list item is a list of text elements that can be displayed as either a
poplist, text list, or combo box.
A list item displays a fixed number of elements.
Each element in a list is a text string up to 30 characters long.

Defining Radio Groups


A radio group is an interface control that displays a fixed number of
options that are mutually exclusive.
Each option is represented by an individual radio button.

Creating a Radio Group


When you create a radio group, you associate a specific data value with
each radio button in the group.
When an operator selects a radio button, the value of the radio group
changes to the value that you associated with the selected button.

Defining Text Items


A text item is an interface control.
It displays operator-enterable text in a field in either single or multi-line
display.
You can format numbers and dates in single-line text items with format
masks.

Recap

Defining Buttons
Defining Check Boxes
Defining Display Items
Defining List Items
Defining Radio Groups
Defining Text Items

Review Questions

Review Questions

Hands-On-Exercise 3, 4, 5

6
Using PL/SQL in Forms

PL/SQL in Oracle Forms


In the Oracle Forms Designer, you write PL/SQL code when you do the
following:
Create triggers and PL/SQL-type menu items.
Write user-named subprogram and PL/SQL package
Define menu startup code.

Calling Built-in Subprograms


Built-in subprograms are packaged procedures and functions that are always
available within Oracle Forms.
Examples :
Go_Item('customer.cust_id');
item_required :=Get_Item_Property('customer.custid',REQUIRED)
:control.item_A := Message_Text;

Referencing Oracle Forms Objects in PL/SQL Statements


Example :
To reference the value stored in an item :
:block_name.item_name
To Reference Objects by Internal ID :
DECLARE
id_var WINDOW;
BEGIN
id_var := Find_Window('my_window');
END;

Referencing Items Indirectly


You can reference items indirectly with the NAME_IN and COPY built-in
subprograms.
IF :emp.ename = 'smith'
IF NAME_IN('emp.ename') = 'smith'
date_var :=TO_DATE(Name_In('order.date_item'));
num_var := TO_NUMBER(Name_In('order.number_item'));

Referencing Items Indirectly ...


The COPY procedure assigns an indicated value to an indicated variable or item.
:emp.ename := 'smith'; -- direct reference
copy('smith','emp.ename'); -- indirect reference
Referencing items indirectly allows you to write more generic, reusable code.

Variables
Local Variables
Global Variables
System Variables

Global Variables
Global variables are not formally declared the way PL/SQL local variables are.

Initialize a global variable the first time you assign a value to it.
GLOBAL.my_var:= TO_CHAR(:order.total * .85);
To destroy a global variable and release its memory, use the ERASE built-in
procedure:
Erase('GLOBAL.my_var');

System Variables
Oracle Forms provides built-in system variables that keep track of runtime
status conditions during an Oracle Forms Runform session. You can read the
values of these variables in any form trigger or user-named subprogram.
Some examples of System Variables:
FORM_STATUS
BLOCK_STATUS
RECORD_STATUS
CURRENT_FORM
CURRENT_BLOCK
CURRENT_ITEM
CURRENT_DATETIME

FORM_STATUS System Variable


To refer system variable
:SYSTEM.form_status
The valid statuses are:
New
Query
Changed

BLOCK_STATUS System Variable


To refer system variable
:SYSTEM.block_status
The valid statuses are:
New
Query
Changed

RECORD_STATUS System Variable


To refer system variable
:SYSTEM.record_status
The valid statuses are:

New
Insert
Query
Changed

Recap

PL/SQL in Oracle Forms


Calling Built-in Subprograms
Referencing Oracle Forms Objects in PL/SQL Statements
Referencing Items Indirectly
Variables
System Variables
Global Variables

Review Questions

Review Questions

7
Writing Program Units

User-named Subprograms
It is a named PL/SQL function or procedure written in a form, menu, or
library module.
It can be reused without having to enter it in multiple triggers.

Creating Packages
Package organize your procedures and functions to form a suitcase of
PL/SQL objects.
Packages can contain variables that are persistent for a user's entire
session.

Recap

User-named Subprograms
Creating a User-named Subprogram
Calling User-Named Subprograms
Creating Packages

8
Triggers

Triggers
D2K applications are event driven
A trigger is a block of PL/SQL code you write to customize your
application.
You use triggers to respond to runtime events with appropriate
processing.

Triggers ...
Triggers can be attached to any object in the form:
an item
a block
the form itself.
The object to which a trigger is attached defines the scope of the trigger

Types of events
Oracle Forms recognizes a predefined set of runtime events, each of which
has a corresponding built-in trigger.

T y p e s o f E v e n ts
In te rfa c e

I n t e rn a l P r o c e s s in g

Using Triggers in Forms


Through triggers, you can control the following types of tasks:
Validate data entry.
Limit operator access to specified forms.
Display related field data by performing table look-ups.

Trigger Categories

Block processing
GUI events
Master-Detail
Message handling
Navigational
Query time
Transactional
Validation

About Built-in Subprograms


Your trigger code can include calls to Oracle Forms built-in subprograms
(called built-ins) as well as custom PL/SQL code.
Examples :
PREVIOUS_ITEM
GO_BLOCK
EXECUTE_QUERY
COMMIT

Notes

Notes

User-Named Triggers
A user-named trigger is one that has a unique, user-supplied name.
To call a user-named trigger, use the EXECUTE_TRIGGER built-in procedure.
execute_trigger('user_trigger');

Block Processing Triggers

When-Create-Record
When-Clear-Block
When-Database-Record
When-Remove-Record

Interface Event Triggers


When-Button-Pressed
When-CheckBox-Changed
When-Image-Activated
When-Image-Pressed
Key- [all]
When-Radio-Changed
When-Timer-Expired
When-Window-Activated
When-Window-Closed
When-Window-Deactivated
When-Window-Resized

Master/Detail Triggers
On-Check-Delete-Master
On-Clear-Details
On-Populate-Details

Message Handling Triggers


On-Error
On-Message

Navigational Triggers
Navigational triggers fire in response to navigational events.
Navigational triggers can be sub-divided into two categories:
Pre- and Post- triggers,
When-New-Instance triggers.

Pre- and Post- Triggers


These triggers fire as Oracle Forms navigates internally through different
levels of the object hierarchy.

Pre-Form
Pre-Block
Pre-Record
Pre-Text-Item
Post-Text-Item
Post-Record
Post-Block
Post-Form

When-New-Instance Triggers
When-New-Instance triggers fire at the end of a navigational sequence that
places the input focus in a different item.

When-New-Form-Instance
When-New-Block-Instance
When-New-Record-Instance
When-New-Item-Instance

Query-Time Triggers
Pre-Query
Post-Query

Transactional Triggers
On-Delete On-Insert
On-Lock On-Logon
On-Logout
On-Update
Post-Delete Post-Forms-Commit
Post-Insert
Post-Update
Post-Database-Commit
Pre-Commit Pre-Delete
Pre-Insert Pre-Update

Validation Triggers
Validation triggers fire when Oracle Forms validates data in an item or
record.
When-Validate-Item
When-Validate-Record

Recap

Types of events
Using Triggers in Forms
Trigger Categories Based on Trigger Functions
Built-In Subprograms
User-Named Triggers

Review Questions

Review Questions

Hands-On-Exercise 6, 7

Hands-On-Exercise 8, 9

Hands-On-Exercise 10, 11

Hands-On-Exercise 12

9
Alerts and Editors

Alerts
An alert is a modal window that displays a message notifying the operator
of some application condition.
There are three styles of alerts:
Stop
Caution
Note.

Displaying an Alert
To display an alert, your application must execute the SHOW_ALERT built-in
subprogram from a trigger or user-named subprogram.
SHOW_ALERT is a function that returns a numeric constant.
Show_Alert(alert_name)
Return NUMBER;

Changing the Alert message at Run time


Alert message could be changed at run time. You can change
the alert message programmatically with the
SET_ALERT_PROPERTY built-in subprogram.
Example
Set_Alert_Property(alert_name,ALERT_MESSAGE_TEXT,Your
Message);

Notes

Notes

Editors
There are three editors that can be used at runtime :
the default editor
a system editor
a user-named editor.

Default and System Editors


Default editor is built into every form and is automatically available from
every text item.
You can specify that Oracle Forms should use the current system editor.

User-Named Editor
A user-named editor has the same text editing functionality as the default
editor
A user-named editor can be displayed programmatically with the built-in
procedure SHOW_EDITOR.

Displaying Editors at Runtime


You can use the following built-in subprograms to display an editor
dynamically:

EDIT_TEXTITEM

SHOW_EDITOR

Displaying Editors
The EDIT_TEXTITEM procedure invokes the editor associated with the
current text item in the form.
The SHOW_EDITOR procedure displays a user-named editor at the
specified display coordinates.

Recap
Alerts
Creating and Displaying an Alert
Changing the Alert Message at Runtime
Editors
Using the Default Editor, User-Named Editor, System Editor
Displaying Editors at Runtime
Using EDIT_TEXTITEM and SHOW_EDITOR

Review Questions

Review Questions

Hands-On-Exercise 13

10
LOVs

LOV (List Of Values)


An LOV is a scrollable popup window that provides the operator with either a
single or multi-column selection list.

LOV Values and Record Groups


LOV values are derived from record group.
A record group has a column/row framework that is similar to a database
table.

The LOV is the interface object that allows operators to view, scroll, and
select records in the underlying record group.

LOV Return Items


While creating an LOV specify which record group columns should be
included in the LOV.
You can designate a return item for any column that you include in the
LOV.

LOV Properties

(x,y)

Width
Automatic Select

height

Filter before display


Column Display

Return
Value

Automatic skip

Automatic
Display

Notes

LOVs and Record Groups


Text Item

LOV

Record Group based on


Static data

Text Item

LOV

Query-based Record
Group

Database

Designating LOV Return Values


You can specify a return item for any column listed in the Column Name list.
The return item can be an item in the current form, a global variable, or a form
parameter.

Using LOV Values to Validate Text Items


When you attach an LOV to a text item, you can set the optional LOV for
Validation property .

Notes

Attaching an LOV at Runtime


You can attach an LOV to a text item programmatically with the
SET_ITEM_PROPERTY built-in subprogram.
The following example attaches the LOV called lov2 to the text item called
emp.empno:
Set_Item_Property('emp.empno',LOV_NAME,'lov2');

Displaying an LOV Programmatically


There are two built-in subprograms that can be used to display an LOV:
LIST_VALUES
SHOW_LOV

SHOW_LOV
Example to call the SHOW_LOV function :
When-Button-Pressed Trigger:
DECLARE
dummy BOOLEAN;
BEGIN
dummy := show_LOV('my_lov',15,10);
END;

Reusing an LOV

Text Item

Text Item

Text Item

LOV
Select some of the field values
Supporting Data Record Group

Setting LOV Properties at Runtime


You can use the following built-in subprograms to get and set LOV properties
at runtime:
GET_LOV_PROPERTY
SET_LOV_PROPERTY
The procedure SET_LOV_PROPERTY can be used to set the following LOV
properties:
GROUP_NAME
Size
X Position, Y Position

Recap

LOV Values and Record Groups


Specifying the Data to be Displayed in an LOV
Displaying an LOV
Displaying an LOV Programmatically
Reusing an LOV
Setting LOV Properties at Runtime

Review Questions

Hands-On-Exercise 14

11
Canvas-Views and Windows

Canvas-Views
Canvas-views are the background objects on which you place the interface
items and boilerplate objects

Canvas View
The canvas-view is displayed in the window
Types of canvas-views :
Content
Stacked
Horizontal / Vertical Toolbar

Canvas-Views ...
Content :
Every window has at least one canvas-view, and usually just one.
Stacked :
A canvas-view you display on top of another canvas-view
Toolbar :
Displays horizontal and vertical bars at the top of or to the side of a window,
respectively.

Windows
A form can include any number of windows.
For each window you create, you must create at least one content canvasview.

Document and Dialog Windows


Document windows are always displayed within the MDI application
window frame.
Dialog windows are free-floating.
The operator can move them outside the application window if they are
defined as Movable.

Modal and Modeless Windows


A window can be either modeless or modal.
More than one modeless window can be displayed at the same time
Modal windows are used as dialogs, and have restricted functionality
compared to modeless windows.

Creating Toolbars
You can create toolbars for any window in a form.
Toolbars can be displayed
Horizontally across the top of a window
Vertically on the left side of a window.

Notes

Notes

Notes

Recap
Canvas-Views
Windows

MDI (Multiple Document Interface)

Document and Dialog Windows

Modal and Modeless Windows


Creating Toolbars

Review Questions

Review Questions

Hands-On-Exercise 15, 16

12
Visual Attributes, Property Classes
and Object Groups

Visual Attribute Properties


Visual attributes are the
font
color
pattern
properties that you set for form and menu objects that appear in your
application's interface.

Visual Attribute Properties ...


Visual Attribute Name property :
Default Visual Attributes
Custom Visual Attributes
Named Visual Attributes

Attaching an VISUAL ATTRIBUTE at Runtime


You can attach an Visual Attribute to a text item
programmatically with the SET_ITEM_PROPERTY built-in
subprogram.
The following example attaches the VISUAL ATTRIBUTE called
VA1 to0 the text item called emp.empno:
Set_Item_Property('emp.empno',VISUAL_ATTRIBUTE,VA1');

Notes

Working with Property Classes


Property class inheritance allows you to quickly define objects that conform
to interface and functionality standards.
Property classes also allow you to make global changes to applications
quickly.

Notes

Notes

Notes

Reusing Objects and Code


Reusing objects helps you to maintain consistency in your applications, Also
allows you to build on work that you or other developers have done previously.

Referencing Objects in Other Modules


Referencing allows you to create objects that inherit their functionality and
appearance from other objects.
A reference object automatically inherits any changes that have been made
to the source object.

Notes

Notes

Notes

Recap
Visual Attribute Properties
Setting Visual Attributes in the Properties window
Creating a Named Visual Attribute
Working with Property Classes
Creating Property Classes
Base an object on a property class
Reusing Objects and Code
Creating a Reference Object
Create an Object Group

Review Questions

Hands-On-Exercise 17, 18

13
Form Parameters

Form Parameters
Parameters provide a mechanism for :
Defining
Setting the values of inputs that are required by a form at startup.

Form Parameter
You can pass parameter values to a form when an application executes the

CALL_FORM,
NEW_FORM,
OPEN_FORM, or
RUN_PRODUCT built-in subprograms.

Referencing Parameters
In PL/SQL, you can reference and set the values of form parameters using bind
variable syntax.
Preface the parameter name with the reserved word PARAMETER :
:PARAMETER.parameter_name := 'TOKYO';
Or
:block.item := :PARAMETER.parameter_name;

Creating a Parameter List


You can use the following built-in subprograms to create and manipulate a
parameter list:

ADD_PARAMETER
CREATE_PARAMETER_LIST
DELETE_PARAMETER
DESTROY_PARAMETER_LIST
GET_PARAMETER_ATTR
GET_PARAMETER_LIST
SET_PARAMETER_ATTR

Recap
Creating a Parameter
Referencing Parameters
Indirectly Referencing Parameters
Creating and Passing Parameter Lists

Review Questions

14
Menus

Menus
Every form runs with one of the following:
The Default menu that is built in to every form
A custom menu that you define as a separate module and then attach to the form
for runtime execution
No menu at all

The Default Menu


The Default menu is part of the form module.
Custom menu modules, however, are separate from form modules.
When you deliver a single-form application that uses a custom menu, you'll
provide two executable files:
an .FMX form module
an .MMX menu module

Menu Objects
The Oracle Forms menu hierarchy contains three object categories:
Menu modules
Menus (including main menus, individual menus, and submenus)
Menu items

Assigning Commands to Menu Items


Every menu item must have a valid Command Type property:

Null
Menu
PL/SQL
Plus
Current Forms
Macro

Notes

Writing User-Named Subprograms


You can create user-named subprograms in a menu module by writing them
in the PL/SQL Editor.
A user-named subprogram can be called from any menu item in the same
module that is defined as a PL/SQL command type.

Notes

Notes

Recap

Menus
Menu Objects
Building a Custom Menu
Assigning Commands to Menu Items
Attaching a Menu Module to a Form
Writing Startup Code
Runtime Control

Review Questions

15
PL/SQL Libraries

PL/SQL Library
A library is a collection of subprograms, including user-named
procedures, functions, and packages.
Once you create a library, you can attach it to any other form, menu, or
library module.
The same library can be attached to multiple forms and menus.

Calling Library Program Units

Applications
Procedure

Database

Function
Package

Form Module Menu


Module Report
Module Graphics
Module

Library

Notes

Recap

PL/SQL Libraries
PL/SQL Library File Formats
Calling Library Program Units
Writing Library Program Units
Steps for Creating and Attaching a Library
Creating a Library
Attaching a Library to Another Module
Editing a Library

Review Questions

16
Working with Images

Images
You can incorporate two types of images into an Oracle Forms application:
Boilerplate Images
Image Items
At runtime,
Navigating and selecting image items is possible
Cannot navigate to or modify boilerplate images.

Using Boilerplate Images


Boilerplate images are static images
You import from the file system or database
They can be used as graphical elements in your form, such as company
logos and maps.

Image Items
Image items are special types of interface controls that store and display
either vector or bitmap images.
Like other items that store values, image items can be either base table
items control items.

Notes

Recap

Images
Using Boilerplate Images
To Import a Boilerplate Image
Defining Image Items
Populating Image Items
Manipulating Images at Runtime

Hands-On-Exercise 19

Thank You Thank You

Você também pode gostar