ORACLE FORMS Oracle forms are GUI based applications. It is to develop user friendly Interface for front end users in-order to query the details and Modify the details. Oracle’s GUI based forms tools are : Form Builder: It is used to design the layout of data entry form as well as to bind event driven PL/SQL code to the form for data validation and navigation purpose. Forms Compiler : It is used to compile the file, which was developed by the form builder . It creates a binary file and save the file to hard, which can be executed. Form Runtime : It is used to run the compiled file, which was created by Forms Compiler. To run an oracle form only the Forms Runtime is required. Application built using Oracle Form Builder contain the following components 1) Form Modules 2) Menus 3) PL/SQL Libraries 4) Object Libraries 5) Database Objects 1) Form Module It is primary object created using From Builder. Form Module is collection of objects such as data blocks, canvases, frames, items and event based PL/SQL code blocks bound to triggers 2) Menus The Menu module is a collection objects such as menu items, sub menu items and event based PL/SQL code blocks. Compiled and Developed By M.Nageswar Rao B.Tech, MBA
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
ORACLE FORMS
Oracle forms are GUI based applications. It is to develop user friendly Interface for front end users in-order
to query the details and Modify the details.
Oracle’s GUI based forms tools are :
Form Builder: It is used to design the layout of data entry form as well as to bind event driven PL/SQL code to the
form for data validation and navigation purpose.
Forms Compiler : It is used to compile the file, which was developed by the form builder . It creates a binary file
and save the file to hard, which can be executed.
Form Runtime : It is used to run the compiled file, which was created by Forms Compiler. To run an oracle form
only the Forms Runtime is required.
Application built using Oracle Form Builder contain the following components
1) Form Modules
2) Menus
3) PL/SQL Libraries
4) Object Libraries
5) Database Objects
1) Form Module
It is primary object created using From Builder. Form Module is collection of objects such as data blocks,
canvases, frames, items and event based PL/SQL code blocks bound to triggers
2) Menus
The Menu module is a collection objects such as menu items, sub menu items and event based PL/SQL
code blocks.
3) PL/SQL Libraries
The library module is a collection of PL/SQL procedures, functions, Package Spec and Package Body.
These can be accessed form the forms and menus.
4) Object Libraries
The Object Library provides an easy method of reusing objects.
We can use the Object Library to:
Create, store, maintain, and distribute standard and reusable objects.
Rapidly create applications by dragging and dropping predefined objects to your form.
5) Database Objects
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Oracle’s interactive tool ( SQL * PLUS ) allows the creation of database objects like stored procedures,
functions and database triggers using appropriate SQL and PL/SQL sntax.
FORM MODULE
A form module consists of the following components
1) Block 2) Items
3) Frames 4) Canvas Views
5) Window 6) PL/SQL Code blocks
Blocks :
1) A form contains one or more blocks. Blocks are logical containers and have no physical representation Only the
item contained in a block are visible in the form interface.
2) A block, which is connected to a database object is called as Data Aware Block. A block, which is not connected
to any database object is called as Control Block
3) A block can be Connected to a database object like a table, view or synonym. A block can also be connected to
stored procedures.
4) A table, which is connected to block is called as base table.
Items :
1) Items are objects contained in blocks. A Block serves as container for items where as Item serves as contained for
data.
2) Some of Items of the block, bound to the columns of base table and some of the items of the block may not be bounded to columns of the base table.
From : Form is an interface for end user, which enable the end user to give input to an application. Form consists of
G.U.I components for user friendly. Forms are used to design GUI ( user interface ) , to enable the end user
to display, add records, modify records, and delete records in table. It is a user friendly. ( select, insert,
update, delete )
Note : 1) Reports are used only for display records. ( Select )
2) Every thing is called as an object in the form builder and report builder.
Form Builder Versions 4.5 / 6i / 9i / 10G
A Form consists of following Interfaces
1) Layout Editor 2) Object Navigator
3) Property Palette 4) PL/SQL Editor
5) Menu Editor 6) Wizard
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
1) Layout Editor :
The Layout Editor is a graphical design facility for creating and arranging interface items and
graphic objects in a form. i.e Designing user friendly screens for end user.
F2 is short cut key to access the Layout Editor
(or)
Window Module1 : Canvas2
Canvas :
A canvas is a surface--inside a window container--on which we place the interface items and boilerplate
objects that end users interact with when they run the form. By default, any canvas you create at runtime is assigned
to the window named WINDOW1. To explicitly associate a canvas to a specfic window, set the canvas' Window
property accordingly.
Layout Editor Context :
The title bar of the Layout Editor window displays context information, including the name of the current
form, the name of the canvas being edited, and the name of the current block. When you create an item by drawing
it on a canvas in the Layout Editor, Form Builder assigns the item to the current block, as indicated by Layout
Editor block context. You can change Layout Editor block context using the Block poplist on the toolbar.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Layout Editor
Context
Horizontaland
Vertical Rulers
Tool Palette
StatusBar
Canvas
MessageBar
Rulers :
The horizontal and vertical rulers at the top and left side of the workspace provide a reference for sizing and
arranging objects in the Layout Editor. To hide rulers, deselect the Rulers option on the View menu.
Layout Editor ruler units can be set to character cells, inches, centimeters, or points. To display the Ruler Settings
dialog, choose ViewSettingsRuler Settings.
2) Object Navigator
The Object Navigator provides a hierarchical display of the objects in all open modules. Objects are
grouped under the appropriate node. For example, all of the windows defined in a form module appear under the
Windows node. The Windows node, in turn, appears under the appropriate form module object.
F3 is a shortcut key to access the object navigator
( OR )
Window Object Navigator
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
3) Property Palette ( F4 is short cut key )
The Property Palette is where you set the properties of objects you create in form and menu modules.
4) PL/SQL Editor
The PL/SQL Editor is where you enter and compile code objects. Code objects in Form Builder include
event triggers, subprograms (functions and procedures), menu item commands, menu startup code, and packages.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
5) Menu Editor :
The Menu Editor is a Form Builder design tool you use (along with the Object Navigator and Property
Palette) to create and arrange custom form menu modules and popup menus.
6) Wizards
Form Builder includes several wizards to automate frequently performed tasks for both beginning and
advanced users.
Using a wizard, you can do the following:
1) create or modify a form
2) create or modify a data block
3) create and arrange items within a frame
4) create or modify an LOV
5) create or modify chart item
Window : It is an area where we can display the canvas, we can have the multiple canvases in one
window. Windows are of two types.
1) Model : We can not resize and minimize
2) Model Less window : User Friendly we can easily navigate other forms and minimize and maximize
It is a default one. If it is required to make it as model window, set property Model : Yes
Canvas : This object represents a background entity on which you place interface items, such as check boxes, radio
groups, and text items.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Developing a simple form
A form can be developed in two ways 1) by using wizard 3) Manually
In real time recommended one is manual.
Eg:
EmpNo EmpName Salay DeptNo
Using Wizard
Step1; Start the form builder
1) Select use Datablock Wizard
2) click on Next
3) select Table or view
4) Specify the name table
5) click on refresh
6) supply the user Id and password ( scott/tiger )
7) select the required fields ( >> all )
8) select create data block wizard and call
9) click on finish
10) layout wizard next it shows the name of the canvas
11) next
12) select the required fields to be displayed in the layout (Empno, Ename, Sal, Deptno)
13) Modify the Prompt and width as desired
14) Next
15) select the form/table as desired ( select table ) and click on next
Form option is used to display one record at time where table option is used to more than one record
at a time.
16) supply the frame title, No of record displayed, scroll bar and next
17) Finish
18) compile and run the form
Program Compile all
File administration Compile File ( Ctrl + T )
Program Run Form Client/Server ( Ctrl + R )
In place of last two steps : click on run tool ( shows in green color )
19) to see the records go to query execute to display ; enter clear
20) Next >> Previous <<
21) insert button , delete button, modify the record and save
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Layout shows as below
Runtime shows as below
+ Adding New Records ( enter the data and click on Save button ) X Deleting records ( place the cursor on the required record and select delete )Action Exit : to exit from the report.
Developing a Simple form manually
Above example manually
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Step1; Start the form builder
1) Select manually
2) Select Data block and create
3) Built new block manually
4) Data Block Property palette define the properties
Name : EMP_DETAILS ( as desired )
Navigation Style : Change Record
No.of records displayed : 1
Data base block : yes
Data source name : emp
Data source columns : EMPNO, ENAME, SAL, DEPTNO
5) select Canvas and create
6) F2 to go canvas or double click
7) Design the form as shown below
8) Define the properties of text fields ( empno )
Name : empno ( as desired )
Item type : Text Item
Enabled : yes
Data type : Number
Column Name : empno
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
9) Repeat the same procedure for remaining fields
10) Compile and run
CONTROLS
Tools on the Tool Palette are called as Controls
List of Controls
1) Frame 2) Text 3) Text Item
4) Button 5) Check Box 6) Radio Button
7) List Item 8) Display Item 9) Stacked Canvas
10) Tab Canvas 11) Image Item 12) Select
13) Rotate 14) Magnify 15) Reshape
16) Rectangle 17) Line 18) Ellipse
19) Arc 20) Polygon 21) Polyline
22) Rounded Rectangle 23) Free hand 24) Chart Item
25) OLE Container 26) Active X Control 27) Bean Area
28) Sound Item 29) Hierarchical Tree
Frame :
A frame is a graphic object that appears on a canvas. You use frames to arrange the items within a block.
When you arrange items within a frame, you can, for example, create a form-style arrangement, define the distance
between items and prompts, specify margins and offsets, and so on.
Frames provide these benefits:
1) A frame is an object with properties
2) When we associate a frame with a block, the items in the block are automatically arranged within the
frame.
3) Each frame can be associated with a block
4) frames can be sub classed or included within the Object Library to enforce visual standards
5) We can store frames within the Object Library to provide a method of enforcing standards across a
project or organization. You can create a series of "style sheets" for different types of blocks (single
record, multi-record, or master-detail, for example). To reuse a frame that is stored in the Object
Library, simply drag the desired frame to a canvas, then run the Layout Wizard to arrange an existing
block within it.
6) Frames can be manipulated in the Object Navigator, Layout Editor, and Property Palette
7) Frames can be visible or invisible
8) If a frame is visible, it is displayed as a beveled rectangle. The contents of a frame appear within the
frame's border.
9) The Layout Wizard uses frames to arrange items
Text ( T ) : Text is used set labels on other controls such as Text Item, Headers and etc.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Text Item : It is for user inputs and to display details of some item. Text will be assign to every column of the table
automatically.
Properties ( IMP )
Name : as desired
Item Type : TextItem
Enabled : Yes / No
Multi Line : Yes/ No
Data Type : as desired
Initial Value : as desired
Required : Yes/ No ( No : Optional fields )
Lowest Allowed Value : as desired
Highest Allowed Value : as desired
Formula : If required
Summary Function : if required
Database Item : Yes/ No
Column Name : as desired
Previous example focused on the text items ( Manual development of simple application )
Working with Check Boxes
It is either enabled or disabled. We can select multiple check boxes at a time.
The default setting. When a coordination-causing event occurs in the master block, the detail records are
fetched immediately.
Deferred=Yes, Automatic Query=Yes
When a coordination-causing event occurs, Form Builder defers fetching the associated detail records until
the operator navigates to the detail block.
Deferred=Yes, Automatic Query=No
When a coordination-causing event occurs, Form Builder defers fetching the associated detail records until
the operator navigates to the detail block and explicitly executes a query.
Deferred=No, Automatic Query=Yes
Not a valid setting.
Calling (one form) from (another form)
Develop the form, save and create exe file
Creation of exe file:
File Administration compile file (or ) use short cut ( ctrl + T)
1) CALL_FORM ()
2) OPEN_FORM ()
3) NEW_FORM ()
For these three Procedures form_name is common parameter.
Form_name = location of the form ( eg : C:\CUST-FORMS\ EMP )
EMP.FMX is a name of the Form Module file.
Extension .fmx should not be wile passing a form_name.
1) OPEN_FORM (opens a separate, independent form) :
PROCEDURE OPEN_FORM (form_name VARCHAR2,
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
activate_mode NUMBER,
session_mode NUMBER,
data_mode NUMBER,
paramlist_id PARAMLIST);
1) Multiple Child Forms can be opened
2) activate_mode :
activate_mode = ACTIVATE (The default.) Sets focus to the form to make it the active form in the
application.
activate_mode = NO_ACTIVATE Opens the form but does not set focus to the form. The current form
remains current.
3) session_mode :
session_mode = NO_SESSION ( default ) Opened form can share the same database session as the form
from which it was invoked.
session_mode = SESSION it can create a separate session of its own.
4) data_mode :
data_mode = NO_SHARE_LIBRARY_DATA (The default.) At runtime, Form Builder will not share data
between forms that have identical libraries attached (at design time).
data_mode = SHARE_LIBRARY_DATA At runtime, Form Builder will share data between forms that
have identical libraries attached (at design time).
2) CALL FORM (calls a modal form) :
PROCEDURE CALL_FORM (formmodule_name VARCHAR2,
display NUMBER,
switch_menu NUMBER,
query_mode NUMBER,
data_mode NUMBER,
paramlist_name VARCHAR2);
1) Only One Child can be Opened From the parent2) display
display = HIDE (The default) Form Builder will hide the calling form before drawing the called form.display = NO_HIDE Form Builder will display the called form without hiding the calling form.
3) switch_menu switch_menu = NO_REPLACE (The default.) Form Builder will keep the default menu module of the
calling form active for the called form.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
switch_menu = DO_REPLACE Form Builder will replace the default menu module of the calling form with the default menu module of the called form.
4) query_modequery_mode = NO_QUERY_ONLY (The default.) Form Builder will run the indicated form in normal
mode, allowing the end user to perform inserts, updates, and deletes from within the called form.
query_mode = QUERY_ONLY Form Builder will run the indicated form in query-only mode, allowing the end user to query, but not to insert, update, or delete records.
5) data_modedata_mode = NO_SHARE_LIBRARY_DATA (The default.) At runtime, Form Builder will not share data
between forms that have identical libraries attached (at design time).
data_mode = SHARE_LIBRARY_DATA At runtime, Form Builder will share data between forms that have identical libraries attached (at design time).
3) NEW_FORM (replaces the current form with a different form)
PROCEDURE NEW_FORM ( formmodule_name VARCHAR2,
rollback_mode NUMBER,
query_mode NUMBER,
data_mode NUMBER,
paramlist_name VARCHAR2 );
1) Once Child from is Opened Parent from will be Closed.
2) rollback_mode :
rollback_mode = TO_SAVEPOINT (The default.) Form Builder will roll back all uncommitted changes
(including posted changes) to the current form's savepoint.
rollback_mode = NO_ROLLBACK Form Builder will exit the current form without rolling back to a
savepoint. You can leave the top level form without performing a rollback, which means that you retain any
locks across a NEW_FORM operation. These locks can also occur when invoking Form Builder from an
external 3GL program. The locks are still in effect when you regain control from Form Builder.
rollback_mode = FULL_ROLLBACK Form Builder rolls back all uncommitted changes (including
posted changes) that were made during the current Runform session. You cannot specify a
FULL_ROLLBACK from a form that is running in post-only mode. (Post-only mode can occur when your
form issues a call to another form while unposted records exist in the calling form. To avoid losing the
locks issued by the calling form, Form Builder prevents any commit processing in the called form.)
3) query_mode:
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
query_mode = NO_QUERY_ONLY (The default.) Runs the indicated form normally, allowing the end
user to perform inserts, updates, and deletes in the form.
query_mode = QUERY_ONLY Runs the indicated form in query-only mode; end users can query records,
but cannot perform inserts, updates or deletes.
4) data_mode :
data_mode = NO_SHARE_LIBRARY_DATA (The default.) At runtime, Form Builder will not share data
between forms that have identical libraries attached (at design time).
data_mode = SHARE_LIBRARY_DATA At runtime, Form Builder will share data between forms that
have identical libraries attached (at design time).
For most GUI applications, using OPEN_FORM is the preferred way to implement multiple-form functionality.
Eg: Calling a Detailed form from the Master
Master From ( Dept Details ):
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
When Click Emp Details Button it has to Detailed from with list employees working in a perticular Dept, which was
selected in the Master form ( in the above selected Deptno : 10 )
Master Form Dept No : 20
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Detailed Form
Develop The Master Form ( DEPT ) as shown below
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Write the PRE-FORM trigger at the Master Form level to declare the Global Variable as shown below
PRE-FORM
:GLOBAL.DEPTNO:=0; -- Global variable decalaration.
Write the the WHEN-BUTTON-PRESSED trigger with follwing Code
WHEN-BUTTON-PRESSED
:GLOBAL.DEPTNO:= :DEPT.DEPTNO; -- Current record Deptno will taken into the Global variable
open_FORM('C:\CUST-FORMS\EMP');
Develop the Detailed Form as new form Module as shown below.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Go Detailed Block ( EMP ) properties set where clause as shown below
DEPTNO=:GLOBAL.DEPTNO
Write trigger WHEN-NEW-FROM-INSTANCE at the Detailed block ( EMP )
WHEN-NEW-FROM-INSTANCE :
execute_query();
Visual Attributes ;
Visual attributes are the font, color, and pattern properties that you set for form and menu objects that appear in your
application's interface. Visual attributes can include the following properties:
Font properties: Font Name, Font Size, Font Style, Font Width, Font Weight
Color and pattern properties: Foreground Color, Background Color, Fill Pattern, Charmode Logical Attribute,
White on Black
Every interface object has a Visual Attribute Group property that determines how the object's individual visual
attribute settings (Font Size, Foreground Color, etc.) are derived. The Visual Attribute Group property can be set to
Default, NULL, or the name of a named visual attribute defined in the same module.
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
There are several ways to set the visual attributes of objects:
In the Property Palette, set the Visual Attribute Group property as desired, then set the individual attributes (Font
Name, Foreground Color, etc.) to the desired settings.
In the Layout Editor, select an item or a canvas and then choose the desired font, color, and pattern attributes from
the Font dialog and Fill Color and Text Color palettes.
Define a named visual attribute object with the appropriate font, color, and pattern settings and then apply it to one
or more objects in the same module. You can programmatically change an object's named visual attribute setting to
change the font, color, and pattern of the object at runtime.
Subclass a visual attribute that includes visual attribute properties and then base objects on it that inherit those
properties.
Types of Visual Attribute :
1) Common : This is for all objects of the form Module ( from top to Bottom )
2) Prompt : This is only for Items Objects
3) Title : This is only for Frame
Created the visual attribute as desired and go to property of the required Object and set Visual Attribute property.
Property Class :
This is similar to the Visual Attribute, the difference here we choose the Attributes as desired, where as in case of
Visual Attributes we have use the provided attributes one only.
Define the property class and go properties and set at the Sub Class Information
If Visual Attributes and Property Class both are set on the same Object then Visual Attribute will be priority.
In the Apps Applications these are not requited. Apps provides predefined property class from each end every item
Simply we can select the Sub Class information in the Form Module Objects.
Program Units :
It is collection if Packages, Procedures and Functions
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
This object represents a named PL/SQL function or procedure that you write in a form, menu, or library module.
Although trigger objects are the primary mechanism for adding programmatic control to a Form Builder application,
this object supplements trigger objects by allowing you to reuse code without having to enter it in multiple triggers.
Scope of program unit is with in the Current Form only
Defining Program Units :
Mathematical Operations On Two numbers:
Create the Block with the following non database items
1) Text Filed ( Num1 )
2)Text Filed ( Num2 )
3) Text Filed (Result )
4) Button ( add)
5) Button ( sub )
Create the Block Manually
Block Properties :
Name : NUMBERS
Data Base
Database Datablock : No
Query Allowed : No
Query Data Source Type : None
Insert Allowed : Yes ( to enter the value in item )
Update Allowed : yes
Delete Allowed : yes
Advance table
DML Data Target type : None
Go to Items of above Data block ( Non database block called as Control block ) and add the items
Set the Properties
Name : NUM1
Data Type : Number
Database Item : No
Query Allowed : No
Prompt : Enter Num1
Repeat the same for remaining
Create the Canvas
Select all the items in the block and go to properties (f4)
Select the Canvas to get the layout
Layout will be as shown below
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Write the Program units for Add and Sub of Numbers
In this example for Add, procedure is taken
For Sub, function is taken
Go to program units and create
1) Create Package Spec
Specify the Package Name : Numbers_Add_Sub_PKG
Select Package Spec
Write the following code and Compile and close it
PACKAGE Numbers_Add_Sub_PKG IS
procedure Numbers_Add_Proc( A number, B number, res OUT number);
function Numbers_Sub_Funct( A number, B number ) return number;
END;
2) Create Package Body
Name should be same as Package Spec
Compiled and Developed ByM.Nageswar Rao B.Tech, MBA
Write the following code in the package
PACKAGE BODY Numbers_Add_Sub_PKG IS
procedure Numbers_Add_Proc( A number, B number, res OUT number)
as
begin
res:=nvl(A,0)+nvl(B,0);
end;
function Numbers_Sub_Funct( A number, B number ) return number
as
begin
return ( nvl(A,0) - nvl(B,0));
end;
END;
Write the Triggers on Buttons to call the above procedure and Function