Professional Documents
Culture Documents
1D
10th August 2005
D2K For ms Builder
D2K For ms Builder
Table of Contents
Dumb Terminal
A terminal that has no processing capability, which can only send information to
the central mainframe and display information given to it by that mainframe.
In these Host-Based settings the host carries out the application processing and
management of data, so the entire processing load rests on the mainframe only.
These models are stand-alone machines with their own set of data and processing
capabilities. In the centralised host-based computing models the corporate
information was centralised and available to all employees, now it is distributed
among the mainframe and personal workstations. These machines allow removing
the overload from the mainframe but the data on PCs is not available to all users
who may need it. The disconnected personal workstation users cannot share the
expensive peripheral computer devices that mainframe users can share for e.g.
Printers, Modems, Disk Drives etc,
The data and peripheral-Sharing problems gives birth to the Network /file Server
Computing model. A Network (LAN) lets a workgroup to continue reap the
benefits of easy-to-use PCs but also permits the workgroup to share the data and
peripherals as in a mainframe system. To share data in a LAN, users store files on
the 'File Server', which is a central node that stores data files where all users can
access them. In LAN, 'File Server' is an independent computer that can be best
specialised for its job by giving it lots of disk storage space. In LAN an
application running on the workstation reads and writes files on the LAN's File
Server.
D2K For ms Builder
For example in the multi-user application environment, if two users are accessing the
same file then in that case another user has to wait in line to access the same file. That's
because the file server operates in files, which are very large and prevents a user from
sharing a file when another user has it locked out.
2. If many workstations request and send many files in a LAN, the network can quickly
become saturated with traffic; which degrades the overall system performance.
The problems of the LAN have led to the genesis of the Client-Server
Technology. The Client-Server computing is also called as Distributed
Application Processing or Co-operative Application Processing. In this kind of
set-up, the application runs on the user's PC / Workstations and accesses the
centrally maintained and managed Server.
The Server
The Client
The client application or front-end application is the part of the system. In the Client-
Server application, the clients' main job is to request and retrieve information from the
server.
The Network
The Network and Communication software are the vehicles that transmit data between
the Clients and the Server in an Application System. Both the client and the server run
communication software that allows them to talk across a network.
A Client-Server system can deliver better performance than a File Server system. Client
application and a database server work together to split the processing load of an
application into atleast two parts, one of which requests things from the other. The
requester is the Client, 'and the provider is the Server. In this type of settings, the client
application works with small specific data sets such as rows in a table - not files, as in the
File Server system.
A database Server also provides the facility of row locking which ensures for the data
concurrency, as well as minimizes the network traffic, and improves system performance.
1.3 Builders
Oracle Developer 2000 products (Forms 5.0, Reports 3.0, and Graphics 3.0) are also
called as Oracle Developer 2000 Builders. With the help of above Builders users can
develop applications.
Forms Builder
Reports Builder
D2K For ms Builder
Graphics Builder
To speed development and help you get started generating objects for your application,
Form Builder provides wizards. The wizards' application-generation capabilities leave
both new and experienced developers free to work on other aspects of a form module.
Oracle Reports 3.0 is used to produce reports from the data in the Oracle Database. With
Oracle Reports you can create reports in a wide variety of styles, including Tabular,
Master/Detail, Form, Form Letter, and Matrix.
lesser system). To load all the tools with demos and on-line documentation requires
nearly 200MB of Hard Disk storage.
Developer 2000 uses all of the standard Windows interface elements like resizable
windows, pull-down menus, toolbars, point-and-click access, cut, copy, paste, dialog
boxes etc.
The Object Navigator provides the developer with a hierarchical view of the objects in
the application and in the database. It resembles the functional capabilities of Windows
File Manager. By selecting the items in the Object Navigator, the developer can view and
update the properties as well as the appearance of the object on the screen. The Object
Navigators are implemented in a consistent manner in the builders for Forms, Reports,
and Graphics.
D2K For ms Builder
1.5.3 Toolbars
Each of the Developer 2000 designers, object Navigators have an iconic toolbar on the
left side, which provides point and click access to many commonly performed operations.
Button Usage
Oracle Forms, Reports and Graphics also have their own toolbar to support their Layout
editors.
Bubble Help is provided for all the iconic buttons for each tool bars within Oracle
Deve loper 2000.
Each Oracle Developer 2000 provides a property palette to review and modify the
properties of any object within the application. The properties are displayed in forms with
a property window.
The Oracle Develo per 2000 products incorporate the use of PL/SOL Editors. Each of the
Source code within an application can be incrementally compiled using the PLISOL
Editor. The current code can be immediately checked for syntax errors and also there is
no need to recompile the entire application at the end of the development process.
1.5.6 Help
The three products of the Oracle Developer 2000 provide the on-line help facility. The
menu Help can invoke help.
D2K For ms Builder
Ø Inheritance
Ø Encapsulation
Ø Polymorphism
Based on selected activities called events, you can write triggers and program units to
define the process to be executed whenever the event occurs. Developer 2000 utilizes the
concept of (OOP) Object-Oriented Programming with object inheritance, reusability, and
data encapsulation, as well as modularity and polymorphism. These features enable the
developer to construct high-quality, critical application in a very short period of time.
Inheritance
Inheritance means a user can create any individual object, which is based on another
object's definition with its original property, as well as, it also allows user to modify the
property. Oracle Forms supports inheritance via the use of property classes.
Encapsulation
Encapsulation allows user to combine and hide data. Oracle Forms, Oracle Reports,
Oracle Graphics supports encapsulation by utilizing stored functions, procedures, and
packages.
Polymorphism
Oracle Forms 5.0 is a part of the Cooperative Development Environment Tools (CDE) of
Developer/2000 for building Client-Server applications. Oracle Forms 5.0 is used to
create form-based applications for entering, querying, updating, and deleting data. Instead
of writing programs, you define your application using simple menus, property windows,
and a powerful Wizard. Oracle Forms Builder also provides the capability to define
libraries of PL/SQL code that can be referenced from many forms application.
Form Builder is a development tool for building applications that provide users access to
information stored in a database. Form 'Builder modules can run standalone and they can
also have reports or graphics embedded in them.
When you build an application in the Forms Builder, a .FMB (Form Module Binary) file
gets created.
To run the application you need to Compile it first using the Forms Compiler Or in the
Preference Option Compile Before Run checkbox is set, so the Form is automatically
compiled before it is run.
Oracle Forms Compiler is used to generate the application built in the Forms Builder.
The Forms Compiler converts the 4GL created by the Builder into an executable file.
Compiling a form module compiles all of its code objects and creates a .FMX (Form
Module Executable) runfile. You will usually generate the executable from within the
Forms builder during the development process, prior to running the application for
testing.
D2K For ms Builder
Oracle Forms Runtime is the runform engine that uses the compiled version of the form.
Application developers use the Oracle Forms Builder to create an application, then use
the Oracle Forms Compiler component to generate an executable runfile and then use the
Oracle Forms Runtime component to run the compiled runfile.
After starting the Forms Builder the designing of an application is done through the
individual modules. You build applications in Oracle Forms by developing different
types of modules.
The highest-level Form Builder objects are 'modules'. Each module consists of any
number of lower-level objects. When you work with Form Builder, you work wit h four
types of modules
Ø Form modules
Ø Menu modules
Ø Object library modules
Ø PL/SQL library modules
A form module is a collection of objects (such as windows, canvases, blocks, and items)
and data that users interact with, in order to modify database tables. They make up the
main body of a Form Builder application, and they contain any of the user interface items
as well as the data source definitions and behavior.
The Form Module allows the programmer to create forms to facilitate data manipulation
tasks, such as adding, reviewing, changing and removing data from the database. It
consists of objects and code routines. In a form module you can define objects like
windows, fields, check boxes etc.
The Menu Module allows the programmer to create Menus, which provides the user an
easy method of activating different tasks provided in the application.
It is a collection of menus and menu item commands that make up an application menu.
A menu may consist of a main menu object and multiple submenu objects.
D2K For ms Builder
A library module is a collection of client-side code that can be shared across modules and
applications.
The PL/SQL Library Module allows the programmer to create libraries of reusable
PL/SQL programs, thus facilitating the task of application development.
It is a collection of user named functions, procedures and packages that can be called
from other module in the application.
In Object Library module is a collection of objects like items, alerts, and editors. These
Objects can be reused resulting in uniformity in the application and rapid application
deve lopment.
Oracle toots contains the PL/SOL engine, an application development tool that can
process PL/SOL blocks. This tool passes the block to its local application site and sends
only SOL statements to Oracle back-end. Thus most of the work is done at the Client-
side, not at the server side, which gives better performance and flexibility, particularly
with many users of many applications using the database.
Ø To Make the application partitioning even easier, Oracle Forms allows you to
drag-and-drop procedures between your application and the server in one simple
mouse operation.
Ø With drag-and-drop partitioning, you can quickly move procedures between your
application and. the server, without having to change any of the code in your
application.
The Oracle Forms Builder is the design component of Oracle Form 5.0. From the Forms
builder you can build, generate and execute the form.
1. Click on Start button ->Programs -> Developer 2000 R 2.0 -> Forms Builder.
OR
Welcome Screen
When you start Form Builder the following wizard is displayed. This happens only when
you start the Form Builder.
Connecting to Oracle
In order to access database objects of the Oracle Database, User should get connected to
Oracle Database.
3. Click Connect.
It is possible to work in the Oracle Forms Builder without having to connect to the Back-
end. As soon as you fire a query or access any object of Oracle Database, it will request
you for a connection. Compiler or Runtime also requires the application to connect to the
Back-end.
The Object Navigator provides a hierarchical display of the objects in all open modules.
Objects are grouped under the appropriate node. for ego All the windows defined in the
form module will appear only under Windows node. Objects and nodes in the object
navigator are displayed with the '+' or '.' symbol to indicate whether they are currently
expanded or collapsed. A grey '+' is displayed for a node that does not yet contain lower-
level objects. A round bullet is displayed in front of an object that cannot contain any
lower-level objects.
Ø Forms
Ø Menus
Ø Libraries
Ø Packages
Ø Database objects
Ø Module
When the Builder Window displays Object Navigator Window you will see a default
module MODULE1 as the only form in the window.
This node by default displays 'Module 1, in the object navigator whenever user saves the
form, then module node gets changed by user specified name.
D2K For ms Builder
Ø Triggers
Triggers are PL/SQL Code that will be executed based on specific activity or condition in
the form. These activities are also called as events. Many of the trigger events will
perform a particular default function. A trigger can be written to disable, modify, or
enhance the default processing capabilities associated with the event. Triggers can be
defined at the Form, Item, Block or Record level. Details of trigger processing will be
covered in the chapter on Processes and Triggers.
Ø Alerts
Alerts are used to provide additional information or other messages that require response
or acknowledgement from the user. These are the message windows used to warn the
user of some application condition. An example Alert is given below.
Ø Attached Libraries
Libraries are special Oracle Forms Modules that can be defined to contain reusable
procedures and functions. By attaching program unit libraries to a form, the program
code can be maintained in a single file rather than in each individual form module.
Ø Blocks
A Block corresponds in a form to the individual entity (Table, or View) in the database.
Blocks may be created that does not correspond to any table, such blocks called as Non
Base table blocks. Non-base table blocks are used to hold generic control information.
Ø Items
An item corresponds to a single data element of field. These items may contain database
columns or may be used as containers for other related data.
Ø Relations
Relations node is used when user creates multiple blocks in a form. These blocks can be
related by using relation. For e.g . In a multiple blocks form, one block is usually defined
as the primary or master block, and the other blocks display the detail information
associated with the current record in the master block. Say, the Dept -Emp relationship in
which using Master-Detail relationship we can find out how many employees are
working in the same department.
Ø Canvas-View
Canvas- Views are background objects on which other objects or items are placed.
D2K For ms Builder
Ø Editors
An editor is a window for viewing and maintaining large data fields. These data fields are
sometimes included for the entry of user comments or other infor mation that would not
normally fit in a displayed item.
Lovs also called as List of Values provide the user with list of valid entries for a field. A
list of Values presents data contained within an object called a record group whereby the
user will select one value from the list to populate a form item. The list of values may
also be used to validate the user input to ensure that a valid value is entered.
Ø Object Groups
An Object Group is a special mechanism for packaging several Form objects together. It
may then be used in other forms with a minimum of programming efforts. Once an object
group is created in a form, any of the form objects may be copied into the object group.
D2K For ms Builder
Ø Parameters
Parameters are used to pass values from one form to a newly called form in a multiple
form applications. Using parameters, values can also be passed via integration to various
developer 2000 products.
Ø Program Units
Program units are PL/SQL procedures and functions that can be called by the form
triggers. It is segment of program code that is used by more than one trigger.
Ø Property Classes
Ø Record Groups
Record Groups are the virtual tables in memory. Record groups are structured set of data
that can be used to pass data between application modules or to populate lists of values or
other list items.
Ø Visual Attributes
Ø Windows
A window is the frame within which a form appears on the user's screen. Each canvas is
assigned to the specific window in the form and several canvases may be assigned to the
same window. A single form can contain several windows or it may consist of only one
window.
The top-level nodes in the Object Navigator include Forms. Menus. Libraries. Object
Libraries. Built-in Packages and Database Objects All other nodes and the objects they
contain are indented to indicate that they belong to these higher-level nodes.
Each object in the Object Navigator is displayed with an icon that indicates its type. For
some objects double-clicking the icon invokes an editor appropriate to that type of object.
For example double-clicking the object icon for a canvas invokes the Layout Editor.
The Object Navigator can display modules in one of two views: Ownership (the default),
and Visual. The view determines which objects you see in the Object Navigator and how
those objects are arranged.
Ø Ownership View
In the ownership view, all form objects are visible, and the display hierarchy corresponds
to the form builder object ownership hierarchy: form-block—item, Items and relations
are owned by blocks; blocks are owned by forms; triggers can be owned by forms,
blocks, or items; all other form objects (windows, editors, record groups, etc.) are owned
by forms.
Ø Visual View
In the Visual view, only windows, canvases, and items are displayed. The Visual view
hierarchy corresponds to the hierarchy of objects in a form window: window-canvas-
item. Items are assigned to canvases; canvases are assigned to windows. Each window
can have multiple canvases, and there can be multiple items on a single canvas.
When the Object Navigator is in Ownership view, form items are listed under the blocks
to which they are assigned. When the Object Navigator is in Visual View, form items are
listed under the canvases on which they are displayed.
The Property Palette enables you to set the properties of objects you create in form and
menu modules. When you select an object in an editor or in the Object Navigator, the
Property Palette updates to show the properties of that object. When you need to compare
the properties of two different objects, you can invoke additional Property Palettes as
needed. Tip: Use the Freeze icon in the horizontal tool bar, in the Property Sheet.
D2K For ms Builder
1. First select the object and from the object navigator choose Tools -> property
palette menu item
OR
Right click on the object for which you want to display the property palette from
the Object Navigator or Layout editor from the popup menu select Property
Palette. (There are no properties associated with libraries. Attached libraries,
Program units.)
D2K For ms Builder
The Data Block Wizard enables you to easily create or modify data blocks for use in your
application. The Data Block Wizard can be reentered after initial creation of the data
block, enabling you to modify an existing data block, even if it was not originally created
with the wizard.
The Layout Wizard enables you to quickly layout the items of a data block. The wizard
displays the items in a frame on a canvas and lays them out in one of several layout
styles, after which you can manually alter the layout to your own specifications.
Ø Workspace
Workspace is the area of Layout editor window where you create and manipulate items,
boilerplate text and graphics.
Ø Title Bar
The title bar displays the module, current canvas and current block.
D2K For ms Builder
Ø Rulers
The horizontal and vertical rulers at the top and left size of the Workspace provide a
reference for Sizing and arranging objects in the layout editor.
Ø Grid
There is a grid defined within the workspace that helps you position the objects.
D2K For ms Builder
A canvases is a surface -inside a Window Container -on which you 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 specific window, set the canvas Window property
accordingly.
You specify the canvas you want to work in at the time of invoking the layout wizard. By
default new objects created are assigned to the current canvas. A canvas has an attribute
called viewport. The vie wport defines the area of the canvas, which is displayed in a
Window at runtime, called the view. The Position and size of viewport can be changed at
run-time.
Ø Canvas Operations
The operations that can be done on a canvas are showing and hiding the canva s, resizing
the canvas and setting visual attributes.
Ø Canvas types
Form Builder provides four types of canvases, all of which can be displayed in the same
window at runtime. A canvas' type defines how Form Builder will display it in the
window to which it is assigned. When you create a canvas, you specify its type by setting
the Canvas Type property. The four canvas types are:
1. Content
2. Stacked
3. Tab
4. Toolbar
You can import graphic objects and images from the database or the file system into the
layout editor. Oracle forms currently supports the following graphics formats:
Image Formats
Ø BMP
Ø TIFF
Ø JFIF
Ø ORACLE Format
Ø PICT
Ø PCX
D2K For ms Builder
The PL/SOL editor is the place where user can, enter and compile the code objects. The
PL/SOL editor provides a common editing environment for code objects. The code
objects in Oracle Forms include triggers, subprograms, functions, procedures, and
packages. The PL/SOL editor is automatically invoked whenever you create a trigger or
program unit, and it supports incremental compilation of the source code. With
incremental compilation, user gets an immediate feedback on any errors you may have,
and the generation of the form's executable is much quicker.
The Type and object pull down at the top of the PL/SOL editor defines the current object
context. The Name pull-down lists all of the code objects defined in that context.
Type
Sets the context to a specific type of object. When the current module is a form. Type can
be set to trigger or program unit. When the current module is menu, type can be set to
Menu Start-up code, Menu item code, or program unit. When the current object is a
library. type is always program unit.
Object
Sets editor context to a specific object scope. When type is set to trigger, object scope can
be set to form by selecting Form level in the first poplist. To set editor context to a
particular block, select the name of the object poptist. To set editor context to an item,
select the block that contains the item in the first object poplist, then select the item in the
second poplist.
Name
Name option lists all of the code object defined in the current context. Selecting a code
object from the name poplist makes that object the current object in the editor. To display
D2K For ms Builder
Ø Compile
Compiles the code in the source code field. The compiler detects syntax errors, and
references .to non-existent objects, procedures, and functions. When you compile
successfully then. in the status bar displays <Successfully Compiled>.
Ø New
Ø Delete
Ø Close
If the current selection is not a code object to which triggers are attached, an
(LOV) List of trigger names are displayed from which you could make a
selection.
OR
2. From the object navigator or anywhere in the form, if user clicks the right button
then pop-up menu will be displayed, so user can choose PL/SQL Editor.
We have seen how to work with form modules in the Object Navigator and the Layout
Editor same way we can work with menu modules in the Object Navigator and the Menu
Editor. The Navigator and the Menu Editor synchronize when you select a menu or menu
Item. Using the Graphical Menu Editor, you can create pull-down menus quickly.
D2K For ms Builder
Push Button
A rectangle with a text label or icon graphic inside.
Check Box
A text label with a graphic state indicator that displays the current value as either checked
or unchecked. Selecting a check box toggles it to the opposite state.
Radio Groups
A group of radio buttons, one of which is always selected.
Display item
A read-only text box whose value must be fetched or assigned programmatically.
Operators cannot navigate to a display item or edit text it contains.
List Item
A list of choice displayed as either a Poplist or drop list, a Tlist or list box, and a Combo
box. An example of how a list would appear during runtime.
Image Item
A bordered rectangular, that displays images fetched from the database or read in from
the file system
Chart Item
A bordered rectangular of any size, that displays a chart which is created by Oracle
Graphics. Operators cannot navigate or manipulate chart items.
Text Item
A single or multi-line text box, that displays a variety of datatypes, format masks, and
D2K For ms Builder
Sound Item
Sound items allow end users to play and record sound data while working in a Form
Builder application. Developers can set up sound items to allow end users to play, record,
and store sound data stored in a database column or in the file system.
OCX Controls
ActiveX controls, originally known as OLE controls or OCXs make use of both the
ActiveX and OLE technologies. An ActiveX control is a stand-alone software component
that provides a user interface and sends events to clients, all according to the standards
defined by COM. It is an OLE server application that is entirely embedded in an
application with OLE client capabilities.
Tab Canvas
A tab canvas – made up of one or more tab pages – allows you to group and display a
large amount of related information on a single, dynamic canvas object. Tab canvases are
displayed on top of a content canvas, partly obscuring it. Tab pages each display a subset
of the information displayed on the entire tab canvas.
Stacked Canvas
Stacked canvas are displayed in a window along with the window’s content canvas(es)
and any number of other stacked canvases.
D2K For ms Builder
3.1.1 Concepts
Blocks are logical containers that have no physical representation--only the items
contained in a block are visible in the application interface. Blocks provide simple
mechanism to group related items into a functional unit for storing, displaying and
manipulating records. Just as tables store the data in form of rows and columns in the
database, blocks consist of related items that store the item it contains. A form contains
one or more blocks. Each block can relate directly to a single da tabase or view. Each item
in a form (text item, image item, radio group, and so on) belongs to a block. However,
like other objects, blocks have properties, and can be created, copied and modified in the
Form Builder. The items in a block can be placed on difference canvas-views and can be
displayed in different windows. Windows and Canvases will be covered in detail in the
coming chapters.
Data Sources
1. Table
2. View
3. From clause (query datasource only)
D2K For ms Builder
4. Procedure
5. Transactional trigger
Using Stored Procedure as a block datasource is a option not available in the earlier
versions. You base a datablock on a stored procedure when you want to:
A stored procedure returns data to a data block by using either a Ref Cursor or a table of
records.
Ref Cursor
A ref cursor is a pointer to a server-side cursor variable. It is analogous to a pointer if "C"
D2K For ms Builder
A stored procedure that uses a reference cursor can only be used as a query block data
source; it cannot be used for DML block data source. Using a ref cursor is idea for
queries that are dependent only on variations in SQL statements and not PL/SQL.
Table of Records
A table of records is a PL/SOL structure that resembles an array of records. ThE stored
procedure constructs the array and passes back the resulting set of records t_ be used as a
block data source.
Using a table of records is ideal for queries that are dependent on PL/SQL and SQL
Efficiency in terms of the savings on network traffic increases, because it takes a single
round trip (from client to server) to execute the stored procedure, and a single round trip
for all the records returned.
1. A stored procedure that uses a ref cursor can only be used as a query block
datasource
2. A stored procedure that uses a table of records can be used as both a query and
DML block datasource
Data items correspond to table columns within the database. By manipulating a data item
(a text item, for example), the operator can automatically affect data that is in the
database.
Control items do not have any association with the database. When the operator
manipulates a control item, data within the database is not affected unless you provide the
appropriate SOL statements. In general, you create control items not to modi_ database
data, but instead to allow the operator to perform common application functions, such as
navigating from one screen to another.
1. Control items are used to display totals, averages, and other summary information
calculated from values in base table items and database tables.
2. Through control items in the application, developer can accept inputs from the user,
but that is not stored in the database.
3. Control items can also be used to display "look-up values" i.e, database values
derived from a table, other than the base table of the block.
4. Push Buttons and chart items are always control items. Because these items do not
store values, and they cannot relate to columns in the database.
D2K For ms Builder
The Data Block Wizard and Layout Wizard are powerful tools that allow you to quickly
and easily complete the tasks of creating a data block (Using data block WizBrd) and
laying out its interface objects (Using Layout Wizard).
The first thing to do is start the development environment in which you build the Form.
Launch the Form Builder by clicking on Forms Builder icon. The Builder displays
Welcome dialog box.
D2K For ms Builder
1. Create the Emp data Block that displays a single record at a time.
2. Arrange the items
3. Save and run the application
1. In the Object Navigator, Select the Data Blocks node. Click -> Create Icon on the
toolbar
It brings up the New Data Block Dialog
wizard that guides you through the process of building a data block.
4. On the Type page, click a radio button to specify a type: either Table or View, or
Stored Procedure. Click Next to select the datasource.
Ø Table or View - In the Data Block Wizard --Type Page, you select the table or the
table and view from the database, thereafter map columns from the table or view to
items in the data block.
Ø Stored Procedure - In the Data Block Wizard --Type Page, you select stored
procedures to query, insert, update, delete, and lock data for the data block.
In Table/View field name Enter the name of the table or view to which the block is
associated.
If you are not connected to a database, the wizard displays the Connect dialog.
If you wish to select a table or view from a list of available tables and views in your
database schema (or all available schemas), click Browse, which asks what kind of tables
you want to see. Default is to see Tables of current user. You can see the tables of other
users to which you have access, you may want to see views, synonyms.
Integrity Constraints
This option determines whether Oracle Forms should create a block, which enforces the
table and column constraints. This option is valid only for base-table blocks and not for
control blocks.
D2K For ms Builder
If this option is set to true then, Oracle Forms does the following:-
Ø Sets the Primary Key property to True and the Update Allowed property to False for
items that correspond to primary key columns, and sets the Primary Key property On
for the block.
Ø Creates a Key-Delrec trigger for the block if its base table is defined in the database
as having a primary-foreign key relationship with another table. The trigger prevents
the deletion of a record when there are corresponding detail records in the foreign key
table.
Ø Sets the Default property for items that correspond to columns having default value
constraints.
Click on refresh button to see all the Available Columns, the columns from the Emp
Table. Using the >(moves only the selected column) and »(moves all the column present
in the available columns) buttons, you can move the columns into the database items list
from the list of available items. E.g. If you want empno column, click on the empno
column to select it, then click on the> button to move it into the list or Database item. To
move back the columns from the database item to available Columns (In case the desired
column earlier present in the block no longer needed) click the < and «buttons.
6. Having finished creating the data block, you now have two choices:
Ø Exit the Data Block Wizard and immediately invoke the Layout Wizard
(where you can layout the items of the data block in a frame on a canvas).
Ø Just exit the Data Block Wizard
If you choose to invoke the Layout Wizard, the wizard will walk you through the
steps of:
1. Selecting a canvas on which to display your data block items, specifying whit items
to display in the layout,
2. Selecting prompts (Each interface control can have a prompt associated with it. A
prompt is the text label that appears beside and height / width for the items, creating a
frame (including style and title) in which to display the items, and choosing the
number of records to display in the frame (will be explained later in this chapter) and
the distance between those records. Using the Layout Wizard to layout the items of
your data block automates all tasks required to create the basic layout.
If you choose to simply exit the Data Block Wizard without. invoking the Layout
Wizard, you have two choices:
Layout Wizard
To select a canvas:
1. On the Canvas page, select a canvas name from the Canvas poplist.
You can select an existing canvas, or create a new canvas.
2. If you select (New Canvas), select a canvas type from the Type poplist.
If you select Tab from the Type poplist, you also must specify a tab page from the
Tab Page poplist.
D2K For ms Builder
The Canvas page is not available in the re-entrant Layout Wizard; to move a frame to
another canvas, use the Layout Editor to cut and paste the frame to the new canvas.
3. Click Next displays Layout Wizard: Data Block Page.
1. On the Data Block page, select a block from the Data Block poplist.
If you accessed the Layout Wizard directly from the Data Block Wizard, the Data
Block poplist is disabled
2. Select the data block item(s) from the Available Items list that you wish to display in
the frame
When you move an item from the Available Items list to the Displayed Items list, the
wizard places the item on the frame's canvas and sets its Displayed property to Yes
3. For each item you move to the Displayed Items list, use the Item Type poplist to
specify a datatype
If the item is a radio group, select the item in the Displayed Items list, then use the
View poplist to change the wizard's focus (from the radio group itself to the radio
buttons that comprise the group). That way you can reorder the radio buttons, or set
the prompt, width or height of a radio button (on the Items page).
(Radio Groups & Radio Buttons is covered later in this Chapter)
After moving the items to Displayed pop-list
4. Click Next displays Layout Wizard : Items Page
D2K For ms Builder
On the Items page, specify prompt text, width, and height for each item displayed in the
frame's layout.
A prompt is a textual label that is physically attached to an item. If you update the layout
the data block items in the Layout Editor, moving an item also will move its prompt.
To create a prompt
1. In the Layout Editor, double-click the desired item to display the Property Palette.
2. Under the Prompt node, type the desired text label in the Prompt property field.
3. Click Next displays Layout Wizard : Style Page
D2K For ms Builder
On the Style page, click a radio button to choose between a form layout and a tabular
layout.
Frame
A frame is a graphic object that appears on a canvas. You use frames to arrange items
within a block. A frame is an object with properties. When you associate a frame with a
block the items in the block are automatically arranged within the frame. Each frame can
be associated with a block.
To display the Property Palette for the frame object; double click on the selected frame;
or right click on the selected frame to see the popup menu and click on property palette or
you can choose Tools - > Property Palette from main menu.
Tip:
If the line on the frame is not to be displayed find the line color tool at the bottom of the
tool palette and click on it. Click on "No Line" tool.
1. On the Rows page, enter the title you wish to display at the top of the frame in the
Title field.
2. In the Records Displayed field, enter the number of records you wish to display in the
frame (the default is 1).
If the layout style of the frame is:
Form – common when the data block is a master block – set the number of displayed
records to 1.
Tabular – common when the data block is a detail block – adjust the number of
displayed records to display the desired number of detail records.
D2K For ms Builder
3. In the Distance Between Records field, enter the physical distance (measured in the
form's coordinate system units) with which to separate the records displayed in the
frame.
4. To display a scrollbar adjacent to the frame (both at design-time and runtime), set the
Display Scroll bar check box to checked. Scrollbars are typically useful for multi-
record.
5. Click Next displays Layout Wizard : Finish Page
Having finished laying out the items of the data block in a frame, you are ready to exit
the Layout Wizard and continue work on the application. When you click Finish, the
wizard will close the Layout Wizard, and automatically display the layout of your frame
in the Layout Editor one of Form Builder's design tools.
A powerful quality of the Layout Wizard is its ability to operate in re-entrant mode. This
means you can use the Layout Wizard to modify the layout of an existing frame-even if
the frame was not originally created with the Layout Wizard.
To invoke the Layout Wizard in re-entrant mode, select the block or the existing frame in
the Object Navigator (under the Canvases node) or Layout Editor and choose Tools ->
Layout Wizard.
To select a stored procedure as the data source for your data block, you must specify an
individual procedure for querying records for the data block. You also can specify
procedures for inserting, updating, deleting, and locking records. The Data Block Wizard
provides a page for each of the above functions.
On the Query page, in the Procedure field, enter the name of the procedure that will
retrieve information for the data block, and click Refresh. If you are not connected to a
database, the wizard displays the Connect dialog. To map a column or columns from the
stored procedure to a database item in the data block.
Ø On the Insert page, in the Procedure field, enter the name of the procedure that will
insert information for the data block, and click Refresh.
Ø To specify a value for an argument, enter it in the Value field.
D2K For ms Builder
Ø Exit the Data Block Wizard and immediately invoke the Layout Wizard (where you
can layout the items of the data block in a frame on a canvas) OR
If you choose to invoke the Layout Wizard, the wizard will walk you through the steps of
selecting a canvas on which to display your data block items, specifying which items to
display in the layout.
It is not compulsory to add all the procedures. Attach only those procedures that are
required by your application.
The following chapter will cover how to create a master – detail block.
Items are the most basic also most important- elements of an application's interface. They
are a bridge between the back-end and the front-end. Based on the way the data is
presented to users in a GUI environment items can be classified as data entry items and
GUI controls. Data Entry Items include text and display items. GUI controls include push
buttons, radio buttons, check boxes and list boxes, additionally image items, OCX
controls and OLE.
Push button is an interface item, which can be placed on any block. This interface item is
used to initiate action such as Navigation, Save a form, Exit a form, Close a window,
display an alert etc. It does not store a value of its own and hence has no datatype. There
are two kinds of Push Buttons (based on appearance)
Text Iconic
These buttons will display the text or the label of the button clearly indicating their
functionality e.g. Help, Cancel.
Iconic Button
Contain an icon instead of a label. The icon graphically represents the functionality of the
button - used mainly in toolbars
D2K For ms Builder
Mouse Navigate property is to specify whether a mouse click in the item should cause
Oracle Forms to set focus to the item. The Mouse Navigate property applies only to GUI
applications. By default this property is True, when user activates the item with the
mouse, Oracle Forms performs the navigation to the item and moves the input focus to
the item. So if user has written When-Sutton-Pressed trigger on the item, it will never get
fired.
Do not forget to change the 'Mouse Navigate Property' as false because, when user
activates the item with the mouse, Oracle Forms does not perform navigation to move to
the item and the associated trigger will get fired.
On MS Windows, the lookup path for icon files is defined by the TK21_ICON
environment variable .in the ORACLE.lNI file. When you enter the name of the icon file
in the 'Icon Name_property', do not include the path or .ICO file extension.
When-Button-Pressed
Ø Fires when End users select a button by clicking it with the mouse, or select a button
by navigating to it and pressing [Select]. The cursor remains in the button unless the
button command moves it to a different item.
Ø Oracle Forms provides the interface event trigger called 'When-Button-Pressed' for
push buttons to execute a command or to initiate an action. When an operator selects
the button, Oracle Forms executes the code in the When-Button-Pressed trigger.
Ø To attach this trigger keep the item selected and invoke the PUSQL editor by right
click for pop-up menu or by choosing Programs->PUSQL Editor from the object
Navigator.
Ø The following example shows the code written for the Exit (Iconic Push Button):-
Begin
Do_Key(‘Exit_Form’);
End;
Ø Do_Key is the built -in restricted procedure, (which accepts the built-in subprogram),
that executes the key-trigger, which corresponds to the specified built-in
subprograms.
A check box is a two-state control indicating whether a certain condition is True or False,
On or Off, Checked or Unchecked. When you define a check box, you must specify
which value you want the check box to represent as checked and which value you want it
to represent as unchecked. Operators toggle between the state of a checkbox. Check
boxes store characters, Numbers, and Date values.
Similarly the value of a check box can be committed to the database through standard
commit processing.
Create the item from scratch in the a Layout editor by selecting the checkbox icon from
the toolbar.
D2K For ms Builder
There are three ways in which you could specify Other Values.
When-CheckBox-Changed
This trigger fires when the operator changes the state of the Check Box.
Built-ins :
Checkbox_checked
Return Value:
Boolean
D2K For ms Builder
Radio group is an interface control consisting of a group of buttons of which only one is
selected (mutually exclusive). When you create a radio group, you associate a value with
each radio button. A radio group can include any number of radio buttons. Operators can
select a different button by clicking with the mouse. When you select anyone button from
the group, another gets deselected. User can select only one button at runtime. 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. Radio buttons make up the gr oup.
Example
In the given example we are creating a radio group for job item of emp table. This can be
done in two ways:
1. In the Layout Wizard after moving the Available Items to Displayed items. Select the
item whose Item Type you want to change (in our e.g. item job). From the Item Type
list select radio group.
In the Object Navigator select the Property Palette of the item whose Item type you
want to change. Under the Item Type Property from the pull-down select Radio
Group. In the Default value property enter MANAGER. Close Property Palette to
return to Object Navigator.
You now see the Radio Buttons heading under this item as seen in the figure below.
Double-click on the radio buttons node Open the property sheet of the radio button and
set the following property.
If your block has 'record displayed property' for 5 records then set 'item displayed Displa
property' of the radio group as '1', else you will see 5 radio buttons.
Other Values
A radio group can store a fetched or assigned value that it is not one of the values that
you associated with a specific radio button in the group. When you create a radio group,
you must specify how you want it to handle such other values.
Syntax:
Syntax:
Set_Radio_Button_Property (itemid ITEM, button_name VARCHAR2,
Property NUMBER, value NUMBER);
Displayed : (True/False)
Enabled : (True/False)
Height : Character value in points
Label : Label Name
x_pos : x position in points
y_pos : y position in points
When-Radio-Changed
This trigger fires when an operator selects a different button in a Radio Group.
Example
Whenever user clicks on the ‘CLERK’ radio button it will be disabled at runtime
begin
if :emp. job = 'CLERK' then
Set_Radio_Button_Property('emp.job', 'CLERK', ENABLED, Property_false);
end if;
end;
Display items are similar to the text item, but they store only fetched or assigned values.
They are non-naviga ble items, meaning we cannot edit their values at runtime. They are
used to display non-enterable totals, company logos. Company Names, Title column and
text labels for column values.
In the Object Navigator, create a display item. To create a display item, select the block
where you want to insert the display item, then select the Item node, and the choose
Navigator->Create.
Tip:
You can also create display items by drawing them on a canvas in the Layout Editor by
selecting the display item icon from the tool palette.
An existing item's item type can be changed from existing type to Display Item in the
Property Palette.
D2K For ms Builder
Calculated Items
A common task in creating a form is to create an item that represents some calculated
value. E.g. You could combine several database items into a concatenated string in a
separate item that doesn’t correspond to a column in the base table. Another common
example is the Total field that sums the record in a block. An amount field calculated as
Quantity multiplied by Rate.
Use the Calculation Property group. Create a display item not a base table by setting the
item property Database Item to No. Fill in the properties in the Calculation Group Setting
Calculation mode to Formula turns on the Calculation feature.
Emp.Sal + NVL(:Emp.comm.,0)
Whenever any changes occur in the record, Developer /2000 recalculates the field and
displays the new value.
For totals :
Use Summary Calculation items. Set Pre-Compute summaries property in the Advanced
Database group for that block to Yes which tells Developer/2000 to calculate the
summary before it does a query.
Tip
Set the Total items property Number Of Items Displayed to 1.(usually it is zero meaning
the same number of items as records displayed in the block). Because you are
aggregating, the block displays multiple records ,you however do not want to display one
total for each record.
In the Object Navigator, highlight the items node and choose Navigator -> Create a Text
Item is created by default.
Go to the Property Palette of the item and set the canvas property to the desired canvas.
OR
In the Layout Editor, click on the following icon from the tool Palette.
Click in the Layout Editor where you want to place the Text Item.
You can go to the Property Palette of these items to set the different properties. Some of
the property settings have been explained below.
D2K For ms Builder
Property Value
Required Setting the Required property to ‘True’ will compel the user to
enter the value in it.
Format Mask Sets up a mask for the data to be displayed.
Multi-line You can set the multi-line property to True. The Multi-line property
determines whether a text item displays a single line of text or
multiple lines of text. A multi-line text item stores multiple lines of
text by wrapping text to the next line.
Vertical Scroll Bar Setting it to true will attach a scroll bar to the multi-line item.
The Format mask property is used to display data according to certain pre-defined
pattern. Some of them have been discussed below.
1. In case of amount fields, if you want to enter only the digits but display it
business format, then you can set the format mask to $999,999.99PR. Now if you
enter 1000.10 then it will be displayed as $1000.10. If -1000.10 is entered it, will
be displayed as <$1000.10>
2. If you want to embed characters inside a numeric string, you can enclose them in
double quotes in the format mask setting. Say if you want your output to be like
(022) 6187034, then you can specify it in your format mask as "("999")" 9999999
TO save the user the trouble of entering the extra characters like '(', set the format
mask to FM"("999")"9999999. so that the user enters only the digits.
Display_Item
Syntax
Display_ltem(item_id, attribute);
Display_ltem(item_name, attribute);
This built-in can be used to modify an item's appearance by assigning a specified display
or visual attribute to the item. Whenever an item is created Oracle Form assigns a unique
id to that item. To refer to that item you can use its name as well as item id. So the first
parameter to the above built-in is either the item id or the item name. The second
parameter is the name of the visual attribute. This visual. Attribute will modify the
display properties of the text item.
DISPLAY_ITEM only affects the display of the current instance of the item; other
instances of the specified item are not affected.
D2K For ms Builder
Get_Item_Property
Syntax:
Get_ltem_Property(item_id, property);
Get_Item_Property(item_name, property);
It is used to get the current value of the given property for the item. The first parameter
refers to the item, whereas the second property refers to the property of the item you want
to know the property settings for the Required property, you can Get_ltem_Property
('Empno' . Required).
Set_Item_Property
Syntax
Set_Item_Property(item_id, property,value);
Set_Item_Property(item_name, property,value);
It is used to set the properties of an item programmatically. The second parameter refers
to the property name, which you want to set, whereas the value refers to the value to
which you have to set the property to.
In some cases you may be bale to get – but not set – certain object properties.
A list item is a list of elements of text type that can be displayed as a poplist, text list or a
combo box. A list item displays a fixed number of elements maximum of 30 Characters
long. Selecting a different element in a list deselects the previously selected elements.
Values for every list elements can be populated either at design time or dynamically at
runtime.
Ø Text List
Text List appears as a rectangular box. It displays fixed values (Scro1Iable). Does not
allow user input. User has to select from the available values in the list.
Ø Combo List
Combo List appears as a single field. When the user clicks on the list item, a drop down
list is displayed. It allows for user input apart from selection from the list like poplist but
allows user input.
All of these lists display a list of text items in some way. These strings are not necessarily
the value for the item. The list transforms what you see on the screen – a label, into an
actual value in the item, and it's that value that Forms stores in the database. Because of
this level of indirection between the label and value you can use the text for display and
some other datatype for the field.
E.g.
In the database the grade field is stored as number but the list displays text i.e. Clerk
stands for Grade 4; Salesman stands for Grade 3; Officer stands for Grade 2: Manager'
stands for Grade 1 It also translates the 1 when you query the record from the database,
displaying "Manager" instead.
Other Values
A list item can also store a fetched or assigned value that is not one of the value
associated with a specific element in the list.
When you define a list item, you must specify how you want it to handle such Other
Values.
Reject other values as not allowed Specify which element in the list is to
be highlighted when the value of the
list item is an Other value
In case of other list item user has to specify the default value or other value: But in case
of combo box list items accept operator-entered data, so you do not have to define an
Other value for combo box list items. The default value specifies the initial value of the
list item.
D2K For ms Builder
You can create a list item from the existing 'text item' by changing its 'Item Type
Property' to list item, through Object Navigator. Layout Wizard or Layout Editor.
Through object navigator we can also insert any item and change it to list item (Use
Property Palette) or you can create list items by drawing them on a canvas in the layout
editor.
In the Layout Wizard- Data block Page after moving the available items to database items
from the Item Type pull down select list item.
A hard-coded list is a list that you fully specify in the designer. You fill out a dialog box
with the label, and their corresponding values, which become part of the client-side
application, the advantages of this approach are simplicity and speed because you can
create the list very quickly and the list is in the memory when you open the application.
The disadvantage is that you cannot change the list without regenerating the application.
1. Select the property palette of the list item. Under the Functional node select
Elements in list pr operty Click More... Button. .
OR
Double Click Elements in list Property, you see the List item Elements dialog
box.
List Elements popup contains the label that will appear during runtime. In List Elements,
type the label that appears during runtime.
In the List Item Value popup type the value that needs to be stored in the database.
e.g. The list should display Manager, Salesman, Clerk in the pull down when the user
clicks on the pulldown in item job.
Enter the labels and corresponding values. If you want the value to be NULL, leave the
value cell blank. Use the down arrow or mouse to move to a new item in the list.
Use Ctrl + < (use Shift) key to delete the list item you have currently selected.
When-List-Changed
This trigger is used for Poplist and Combo List
When-List-Activated
This trigger is used with only Tlist. (dclick)
Image items allow you to integrate images or pictures into your applications. Image item
is a bordered rectangle of any size that can be used to store and display images fetched
from the database or the file system. They can display images of different formats
(.Bmp,.Tiff etc.). Image items can be mapped to columns in the database or read from the
file system. Image items are dynamic and can change with records being displayed.
You can include two types of images into a Forms Builder application:
Ø Graphic objects
Ø Image items
Graphic Objects
Graphic Objects are static images: Users cannot navigate to these items at runtime. They
have to be imported from file system or database. Other items can be placed on the top of
these images. When the form module is saved the image is incorporated into the form
module. These items can be used to display logos and maps.
Image Items
These are dynamic image Items. Users can navigate to them at runtime. It has to be
imported from filesystem or database. They can be related to the column of a base table
or a control item. Only the definition of the image is stored as a. part of the Form module.
It is populated only at runtime.
D2K For ms Builder
Images and drawings are always stored in the database in Oracle Format. Thus, if you
execute READ _IMAGE_FilE to populate an image item with a BMP file and then issue
a commit. Oracle Forms inserts the im~ge in the corresponding LONG RAW column in
Oracle Format.
1. Create a new item in the Object Navigator (a text item is created by default). Go
to the Property Palette of the item and change the item type to image.
2. Set the image item’s display appearance by using the Properties window. There is
no Datatype property for Image items. The datatype is predefined as Long Raw.
You can populate the image items with image in two ways:
1. You can fetch it from the database if it has been stored in the database (You can
have a table which has a column of type Long Raw)
You can simply execute the query and the image item will be populated by the
corresponding item in the database. You can also modify or change the image and
then save the changes. The modified image is stored in the corresponding Long
Raw column in the database.
2. You can also execute the Read_image_file built-in to populate the image item
with a image from the Filesystem.
Syntax
Filename : Indicates the name of the file in which the image should be stored
Filetype : Indicates the type of the file
Item_id : The id of the image item
Item_name : The name of image item in char
You cannot write a SELECT statement to select a LONG RAW value INTO an image
item.
Built-ins
Read_Image_File (as explained above)
Write_Image_File
Used to write the contents of an image item to a file.
Syntax
Write_Image_File(file_name VARCHAR2, file_type VARCHAR2, item_id item,
compression_quality NUMBER, image_depth NUMBER);
Filename : Indicates the name of the file in which the image should be stored
Filetype : Indicates the type of the file
Item_id : The id of the image item. Use the FIND_ITEM built -in to return the ID
to an appropriately typed variable. Datatype is ITEM
Item_name : The name of image item in char
Compression Quality
(optional) : The degree of depth Form Builder will apply to the image when it stores
it to the file. Datatype is VARCHAR2.
Image_depth
(optional) : The degree of depth Form Builder will apply to the image when it stores
it to the file. Datatype is VARCHAR2.
Syntax
Values Description
ADJUST_TO_FIT Scales the image to fit within the display rectangle: the
entire image is visible and the image fills as much of the
image item as possible without distorting the image.
SELECTION_RECTANGLE Scales the image so the selected region fully fills the
image item
ZOOM_IN_FACTOR Enlarges the image by the zoom_factor
ZOOM_OUT_FACTOR Reduces the image by the zoom_factor
ZOOM_PERCENT Scales the image to the percentage indicated in
zoom_factor.
Ø All the images, which are stored in the database, are stored in the Oracle Format
regardless of the original type of image
Ø If you are storing the image to the file then the indicate d filetype should be consistent
with that of the image being stored in it.
When_lmage_Activated
This trigger fires when user double -clicks on the image item
When_lmage_Pressed
This trigger fires when user clicks or double -clicks on the image item
Basically Chart items are used to view the displays generated in Oracle Graphics. The
details about this will be contained in the chapter Integration of Oracle Products (Oracle
Forms, Oracle Reports, and Oracle Graphics).
A template is an object that you can use to format a module with basic contents
Developer / 2000 Forms does not provide explicit templates, (like Reports and Graphics
components provide). The welcome Window of the Forms Builder lets you build a new
Form based on some already existing Form. Click on Build a New form based on a
Template radio button. The open Form dialog box lets you choose a .FMB file to use as a
template.
There is no other way to get this dialog box other than by starting Form Builder.
D2K For ms Builder
Tip:
You can also Open the template Form using the Open tool then save it under another
name using File - > Save As.
You should build a standard Form with the Objects that you want to standardize.
4.1 Introduction
A master- detail relationship is an association between two data blocks--a master and a
detail block. The relationship between the blocks reflects a primary key foreign key
relationship between the tables on which the blocks are based.
Ø Ensures that the detail block displays only those records that are associated the
current (master) record in the master block.
Ø Co-ordinates querying between the two blocks
:Item.ordid = :Ord.ordid or
:emp.deptno = :Deptdeptno
That is,
To maintain the master -detail relationship at runtime, Form Builder co-ordinates master
and detail blocks to ensure that the records displayed in the detail block associated with
the current record in the master block.
Any event that makes a different record in the master block the current record is
ordination-causing event. Deleting a record or pressing [Up] or [Down] to move to
different record are both examples of co-ordination-causing events. When such a event
D2K For ms Builder
occurs, Form Builder automatically does the processing necessary to a ordinate the
master and detail blocks.
Clear phase During the clear phase, Form Builder navigates internally to the
detail block and flushes the irrelevant detail records.
Population phase During the population phase, Form Builder issues a SELECT
statement to repopulate the detail block with the detail records
associated with the new master record. These operations are
accomplished thr ough the execution of triggers.
A relation is a logical object that specifies the relationship between one master block and
one corresponding detail block. In the Object Navigator. the rel<;ition object appears
under the block that is the master block in the relation.
When you create a relation, Form Builder generates the triggers and PL/SQL procedures
required, to enforce co-ordination between the master and detail blocks. The actual code
that Form Builder generates depends on how the properties of the relation are set.
Ø Create the relation on the master-detail relation page of Data Block Wizard when
you create the detail block for that relation
Ø In the Object Navigator insert a relation object under the Relations node for the
appropriate master bloc k. Both the master block and the detail block should exist
1. Choose Tools -> Data Block Wizard to invoke the Wizard. Choose an appropriate
table for the detail block and include the columns from the table
Make sure that you include the foreign key column(s) in the block
Click on the Next button to get the Wizard's master-detail page shown in figure
below.
D2K For ms Builder
A potential master block is one that is based on a table that has a foreign I reference to
the base table of the current block. This constraint must be defined at the time of creation
of the tables. Choose the master block and the, condition gets created automatically. (The
Master Block must already be specified when you create a relationship.)
3. Click on the Next button and proceed with block formation as usual. Create the
Layout with the Layout Wizard
D2K For ms Builder
Form Builder creates the block and relation specified. In the Object Navigator, the
new relation object appears under the master block.
The default relation name is in the form IT'asterblock_detailblock, for example, Ord-'tem
or Dept_Emp.
You can define a master-detail relationship between two existing blocks by creating a
relation object in the Object Navigator. Both the master block and the detail block must
already exist.
1. In the Object Navigator, locate the block that you want to be the master block in
the relation. If necessary, click on the + to expand the block so that the Triggers.
Items, and Relations nodes are visible.
2. Position the cursor on the Relations node under the master block, then select
Navigator -> Create.
3. The name of the master block you selected is entered for you automatically
records from the Master field. In the Detail field enter the name of the detail block
or select a block from the LOV associated with this field.
4. Set the Master Deletes, Co-ordination, Join Condition, and Prevent Masterless
Operation properties as desired then choose OK to accept the relation definition.
The maximum length for Join Condition is 255 characters you can specify a join
condition with the following entries:
Ø An item name that exists in both the master block and the detail block (do not
preface the item names with colons).
Ø an equating condition of two item names where one item exists in the mal master
block and the other exists in the detail block
The primary-foreign key relationship between the base tables in the database can. Can be
a purely logical one. It is not required that the relevant tables and columns have explicit
primary key or foreign key column constraints.
D2K For ms Builder
Non-Isolated
The default setting prevents the deletion of a master record if associated detail records
exist in the database.
Isolated
Allows the master record to be deleted and does not affect the associated detail records
exist in the database.
Cascading
Allows the master record to be deleted and automatically deletes any associated detail
records from the base table at commit time. When relations are nested to several levels,
only records in the immediate detail block are deleted. That is deletions do not
automatically cascade to multiple levels of a relation chain.
If your database is using the cascading deletes feature on the Server side do not use the
Cascading deletes option in Form Builder.
Co-ordination Properties
The Co-ordination properties Deferred and Auto-Query determine when the population
phase of block co-ordination should occur. Co-ordination of the detail block with its
master can be
Ø Immediate
Ø Deferred with Auto-query
Ø Deferred with No Auto-query
Co-ordination Description
Immediate Here the deferred and auto-query are both not checked
i.e. are set to false. It is the default setting When co-
ordination-causing event occurs the detail records are
fetched immediately.
Deferred with Auto-query Deferred and auto-query are both checked, set to True.
D2K For ms Builder
Specifies whether operators should be allowed to query or insert records in the detail
block. When set to True, Form Builder does not allow records to be inserted in the detail
block when there is no master record in the master block, and does not allow querying in
the detail block when there is no master record that was retrieved from the database.
You can delete a master-detail relation by selecting it in the Object Navigator a choosing
Navigator->Delete. The following table shows what happens when you de_ a relation or
an object that is part of a relation:
Keep in mind that when you set the Delete Record Behavior pr operty of a relation to
Cascading, the deletes are enforced only for the immediate detail block in the relation.
D2K For ms Builder
For example, consider the complex master -detail relation involving relations' between
blocks A and B (A_B), and. Band C (B_C) where-B is both the detail block in the A_B
relation and the master block in the B_C relation.
When the Delete Record Behavior property is Cascading for the relation A_B, the detail
records in Block B are automatically deleted if the master record in Block A is deleted.
Detail records in Block C are not automatically deleted when a master record In Block A
is deleted. But if the Delete Record Behavior property of relation B_C is Cascading, then
detail records in Block C are deleted when Block A is deleted. This is because deletion of
records in Block A cause records in block B to be deleted. This in turn causes deletion of
detail records in Block C as the corresponding master records from Block B are deleted.
Master-with-dependent-details
When you create this type of relation, consider the effect of the Delete Record Behavior
and Coordination properties on the detail blocks. For example, if one relation in a chain
of related blocks is set to deferred coordination, all subsequent blocks will also be
deferred. Thus, when relation A_B is deferred and relation B_C is immediate, Form
Builder does not coordinate Block C with Block B until Block B is coordinated with
Block A.
Master-with-independent-details
To create this type of relation, define the individual relations A_B and A_C separately (in
any order).
Detail-with-two-masters
A detail-with-two-masters relation involves a single detail block that has two master
blocks. Form Builder displays the appropriate detail records for whichever master block
is the current block in the form. For example, in the sample application referred to earlier,
the ORD block could be a detail bloc k having two master blocks CUSTOMER and EMP.
End users could then see all of the orders for a particular_ customer, or for a particular
sales representative (employee).
D2K For ms Builder
In other cases, however, you might want to create master-with-two-details with each
relation joining on the same foreign-key item in the detail block. However, because the
Copy Value from Item property can only point to one master block item, you will need to
write additional code to coordinate querying and updating for the second relation if you
are joining on the same item in the detail block.
Depending on the desired functionality, this might include writing a Pre-Query trigger for
the detail block to ensure that the correct primary-key item value is copied to the foreign-
key item in the detail block. For example,
You might also want to create a When-New-Block-Instance trigger that checks the
coordination status of the detail block whenever the end user navigates to a different
master block, and, if necessary, populates the detail block.
D2K For ms Builder
Introduction
In a Developer/2000 application the question is where to put the code. Since you are not
developing the application from scratch, you have to put the additions into the already
existing Developer/2000 logic. Hence you need to understand what processes are and
where the triggers fire within those processes. 0/2000 applications are Event-driven i.e.
when you run an application you interact with runtime system to cause events, which in
turn start various form processes. The form processes contain the preprogrammed
behaviour for forms, reports and graphs. As various internal events occur during this
processing, the runtime system handles them by running the code you have written in
PL/SQL.
5.1.1 Concepts
Triggers are blocks of PL/SOL code you can attach to another object. : a form ,a data
block ,or a data block item. But unlike procedures or functions these blocks of code fire
or execute in response to Events. So, what are Events? We ll, an event can be anything
like 'Pressing any Key' or 'Clicking the mouse button' or 'Inserting or saving a record'.
Whereas, your trigger is the code, which will be executed in response to the occurring of
the event. Thus, we can write triggers to add functionality to a default application.
The user interacts with the application by moving the focus from object to object. This
movement is 'navigation' .By navigating from item to item, record to record, block to
Process block or form to form the user controls the tasks that comprise the application
Navigation Events (going to a different item. going to a different record, going to a
different block, going to a different form) constitute the basic events of your form
application.
Every trigger has a name and encapsulates PL/SQL code so that it can be associated with
an event and executed and maintained as a distinct object. Names of the trigger
correspond to runtime events. In other words Trigger names correspond to Runtirne
Events. For example Key-Next-Item trigger corresponds to pressing of the [next
item_key]. Oracle executes the code present in the trigger when [next item key] is
pressed.
D2K For ms Builder
Developer /2000 applications are Event-driven. When you run an application you interact
with runtime systems to cause events, which in turn start various form processes. The
form processes contain pre-programmed default behaviour for forms, reports, and
graphics. As various internal Events occur during this processing the runtime systems
handles them by running the code you write in PL/SQL : it fires triggers.
Oracle Forms is event driven. When we say this, we mean that whenever Oracle Forms
detects an event, it initiates a process to accomplish the event. Forms predefine this
process. A process is a series of individual, related events that occurs during a specific
Oracle Forms Runform operation. The process involves validation, navigation and
database transactio ns. There are over hundred events. Each event can have a different
series of individual events that occur in order to accomplish the parent event.
For every event, Oracle Forms provides predefined triggers that can be used to augment
or enhance default processing. To enhance default processing, you associate a trigger
with an event. The trigger modifies the manner in which Oracle Forms processes the
event. When Oracle Forms detects an event and the trigger is present, Oracle Forms
executes the trigger code. Some events can cause more than one trigger to fire. Anyone of
the triggers can be used to modify default processing
This can be done by setting the trigger property Execution Hierarchy in the trigger
property palette.
D2K For ms Builder
When you create a trigger, you attach it to a specific object, either an item, a block, or the
form itself. The trigger's scope is the set of objects that fire the trigger; it consists of the
object that owns that trigger and any object belonging to that object. For e.g., if you
attach a trigger to a block, events in all the items in that block fire that trigger. Triggers
scope is defined at the trigger definition level. Thus, a block level trigger fires within that
block, but not in another block.
If there is more than one trigger with the same name in a particular scope by default
developer/2000 fires the one attached to the object lowest in the hierarchy. For e.g., if
you have a When-New-Item-Instance trigger on both an item and that item's block
Developer/2000 fires the trigger on the item and ignores the one on the block .You carn
change this behaviour for a particular trigger by changing the Execution Hierarchy
property of the trigger in the triggers property palette. The default is 'Overide' but you can
also choose Before or After.
Some triggers make sense only when defined at a specific level. When-Validate-Record.
for e.g. does not apply to individual items, so you can define it only at block and form
levels. Developer/2000 V 2.0 adds the SmartTriggers feature which identifies the most
likely triggers to define for a particular object.
To use this feature, right click the object for which you want to define a trigger in the
Object Navigator or Layout Editor.
Triggers are named objects, the properties of a trigger determine its scope and
functiona lity. Consider the following before creating the trigger.
Ø the name of the trigger, that is, the event that causes it to fire
Ø the object to which the trigger is attached i.e. the scope of the trigger
Ø the PL/SQL code that executes when the trigger fires
2. A list of trigger names is displayed. Highlight the trigger you require and click on
OK button.
3. The PL/SQL Editor is displayed. Here you define the scope of the trigger. You can
define the triggers at three levels
Ø Form level
Ø Block level
Ø Item level
4. Set the Scope of the trigger by attaching the trigger to an object in the form. In the
object field you can select the block name, if the trigger which you want to define is
D2K For ms Builder
a block level trigger. Within a block if you ha ve to define the trigger on an item then
you can specify that too.
5. Enter the PUSOL code in the trigger. Choose compile to have Oracle Forms
compile the trigger text. Oracle Forms also compiles all the triggers in a form when
you generate the form.
Most triggers you use are built-in triggers, triggers that Developer /2000 supplies these
triggers come in several categories. Each trigger has a specific name - When-Button-
Pressed, Post-Query, On-Delete that you choose from a list of trigger names. You can
also add your own user-defined triggers & fire them explicitly.
A user named trigger is one that has a unique user supplied name. A user named trigger is
executed by calling it in built-in trigger or user-named routines. The procedure
Execute_Trigger is used to call the trigger.
12 Post-event These are the subevents which fire after the execution of
On-Eevent or when event triggers. E.g. Post-insert event
occurs after the execution of On-insert trigger
13 Key Triggers Activated by pressing specific function keys
Before we explore these triggers in detail, let us first understand how procedure occurs in
Forms.
Entering or leaving any object in an application (be it a form, block, record or item)
causes navigation. The Pre-Navigational triggers (Pre-Form, Pre-block, Pre-Record, Pre-
text-Item) occur for that object just before entering into that object. Leaving an object
causes the Post-Navigational triggers to fire (post-Form, Post-Block, PostRecord, Post-
Text-Item).
Navigational triggers such as the above do not support Restricted Package Procedures
(RPPs are built-in procedures in Oracle Forms that cause navigation to take place). Since
the above triggers fire in response to such restricted package procedures, they cannot be
used in the above triggers where the form is still in a state of navigation. However, it is
possible to use restricted package procedures navigational triggers such as When-New-
object-Instance because these triggers fire only after navigation to the object (Form,
Block, Record or Item) is complete.
A query is a request to the database. An Oracle Form application has an in-built query
process that gives you a lot of flexibility without writing a single line of code.
Ø The concept of creating an example record in a block (Le. enter a query) that lets
you enter conditions to attach to the default query
Ø Next, you execute the query that you entered
Ø Executing a query will cause the rows to be fetched into the block
Entering a Query
When you enter a query In an Oracle Forms applIcation by pressing the [Enter Query]
key or calling the ENTER_QUERY built-in procedure, you are building the SELECT
statement.
D2K For ms Builder
SELECT select-list
FROM table
WHERE query-condition
ORDER BY order-by-list
The select-list is the set of column names that correspond to your record items. The table
is the base table that corresponds to the block in the form. The order-by-list is a list of
columns in the select statement that specifies the order for the queried records.
The query-condition is the set of SOL expressions that specifies which records return.
This set of expressions has three parts.
Default Conditions
It is the set of conditions you specify as the default where clause in the block property
palette at design time. It can also be changed at runtime through a trigger.
Ø Column condition
Conditions you enter by filling out columns in the example record in the Enter-
Query mode.
Ø Special condition
Conditions you enter through the Where dialog box in the Enter-Query mode
When you are entering a query, oracle Forms does not validate items or records
and does not permit navigation out of the current block in which you are to enter
the query.
The Query Allowed block property lets you disable a query for a block. You should
specify a block to be a control block by leaving the Base Table property of the block
blank. In which case query for the control block will not be performed.
Executing a Query
Once you have entered your query conditions, you then execute the query by pressing the
[Execute Query] key or calling the built-in procedure EXECUTE_QUERY. However you
can execute a query without having entered a query first. In this case all the rows will be
retrieved using only the default where clause of the block property.
When you execute a query, Oracle Forms first checks whether the block allows queries.
If so, it navigates to the block, validating any records that have not being validated. If
there are Changed records in the block, it prompts the user to commit, post or clear the
changes before executing the query.
Oracle Forms then fires the Pre-Query trigger for the block. The Pre-query trigger is the
last event in which you can still modify the default where condition so as to alter the
D2K For ms Builder
query criteria after which the Oracle Forms will actually start building the select
statement internally.
During the selection phase Oracle Forms fires the Pre-Select trigger. (Fires during
Execute Query and Count Query processing after Form Builder constructs the SELECT
statement to be issued, but before the statement is actually issued. Note that the SELECT
statement can be examined in a Pre-Select trigger by reading the value of the system
variable SYSTEM. LAST_QUERY.)
If there is an On-Select trigger it executes the SELECT statement. The Post-Select and
When-Clear-Block triggers are fired next. The example record is flushed from the block.
Forms then fetches the rows.
Fetching Records
After completing the process of executing the SQL query, Oracle Forms organizes the
fetching of records.
A forms transaction is a sequence of events, processes and triggers that ultimately results
in either saving data to the database or rolling back changes.
Posting to the database means writing any pending changes in a form to the database
through a series of INSERT, UPDATE and delete statements. Oracle Forms generates
these statements as a part of default processing. Post does not commit changes to the
database. A post is always followed by a commit or rollback as a part of default
processing.
During the process of Posting, Oracle Forms navigates to the form and validates it. IF
there are no changes that require posting, the process stops right here. If there are changes
that require posting, then Oracle Forms issues a savepoint.
back the entire transaction. This permits Oracle Forms to post multiple times without
rolling back all the posts except the one that failed.
After issuing a savepoint, Oracle Forms fires the Pre-Commit trigger, (this is the first
trigger to fire as a part of the default processing of Post and Commit). For each block in
the Form, Oracle Forms validates the block, then determines whether the block has any
changes that affect the database. If the block is a control block, then it has no such
changes. The database operation for posting is done, In the following sequence
irrespective of the sequence in which the user perform the inserts, updates and deletes.
Oracle Forms builds statements internally for each row of the block that is deleted,
updated or inserted.
During the Posting process it fires Pre-Event, On-Event and Post-Event triggers for each
of the events of Insertion, Updation and Deletion as a part of the default processing.
The On-Insert trigger calls a package procedure Insert_Record that actually builds the
Insert statement internally and inserts a row into the table.
The On-Update trigger calls a package procedure Update_Record, which actually builds
the Update statement internally and updates a row in the table.
The On-Delete trigger calls a package procedure Delete_Record, which actually builds
the Delete statement internally and deletes a row in the table.
After processing all the blocks in the form, it fires the Post-Forms-Commit trigger
marking the end of the Posting process.
At this point of time all changes are written to the tables, but not committed to the
database. Hence a rollback is possible.
Next, the database commit takes place when Oracle Forms fires the On-Commit which by
default calls the Commit_Form package procedure.
After the database commit, the Post-Database-Trigger fires and from here on it is not
possible to rollback the changes committed.
Validation is the process of making sure that an object satisfies all the constraints defined
on it. Oracle Forms automatically validates Blocks, Records and Items. You can provide
additional functionality by adding constraints as a part of the validation process (through
D2K For ms Builder
Ø When the user tries to navigate out of an item whose item state is new or changed.
(E.g. pressing the enter key or tab navigating or through a call to the ENTER
built-in-procedure).
Ø As part of the default processing of Post and Commit
1. New
2. Changed
3. Valid
Duplicating a record:
Duplicating a record copies the values from the previous record into the new record. The
state of the items in the new record can be in any of the following states, New, Changed
or Valid.
When you modify an item in any way, Oracle Forms marks the item as Changed. All
validation related triggers fire for an item whose status is New or Changed. If validation
fails for some reason, then the cursor remains on the item itself forcing the entry of a
valid value.
After successful validation of an item depending on its status, Oracle Forms marks the
item as Valid, so no future validation is needed if the user navigates out of the item
without modifying it once again.
Record State
Ø New
D2K For ms Builder
Ø Changed
When you modify any item of a record (so as to enter a value or edit the existing one) the
record status becomes changed.
Ø Valid
A record is said to be valid if ->
Ø Oracle Forms validates all the Changed or New items in the record and validates the
record.
Ø Soon after it fetches the record from the database or commits the record to the
database or commits the record to the database
Ø Record validation takes place only for records with Changed status
Locking makes the transaction serializable. Oracle Forms uses row exclusive locks which
prevent other transactions from updating or deleting the row.
By default, Oracle Forms acquires row locks under any of the following circumstances.
When the operator changes the value of a base table in a database row.
When the operator requests an explicit lock through the record -> lock menu item.
When a trigger makes a change to the database through an update or delete statement.
When-Clear-Block:
Fires whenever Form Builder flushes the current block; that is, removes all records from
D2K For ms Builder
the block.
This trigger fires just before Oracle Forms clears data from the current block. May be
used to perform automatic commit before flushing rows from the block. Clear Block
(commit_ mode). It fires during query processing, but does not fire when Forms executes
the CLEAR_FORM built-in.
When-Create-Record:
Fires when Oracle Forms creates a new record. When user presses the [Down] key after
navigating to the last record in the block or the [Insert] key or selecting the menu item
Record -> Insert.
May be used to assign default values to the form items, without marking the record as
changed.
Example
To set the hiredate column in the Emp Block to the current date, each time a new record
is created.
Trigger: When-Create-Record of Emp Block
Begin
Select sysdate into :Emp.hiredate
From Dual;
End;
When-Database-Record
Fires when Oracle Forms first marks a record as an insert or update. This occurs when the
commit status changes from new to insert or from query to changed.
When-Remove-Record:
Fires before Forms clears or deletes a record (Clear_Record, Delete_Record).
When-Button-Pressed:
Fires when the user selects a push-button, either by a mouse click or keyboard
interaction. May be used to initiate an action like commit a form, exit a for, clear a block,
perform a query etc.
Example:
Begin /* If changes have been made to the form, then commit the form */
If :System.Form_Status = 'CHANGED' then
Commit_Form;
/*If the changes have been saved successfully,
then the form status changes to 'QUERY'*/
If : System. Form_Status <>'QUERY' then
Message('Commit Failed');
Raise Form_Trigger_Failure;
End if;
End if;
End;
When-Mouse-Click:
Fires when user clicks depending on the object to which it is attached.
When-Mouse-Double-Click:
Fires when user double clicks depending on the object to which it is attached.
When-Mouse-Enter:
Fires when the mouse enter the item, block or form to which it is attached. May be used
to enable or disable an item on its entry or display the balloon help.
When-Mouse-Leave:
Fires when the mouse leaves the item
When-Radio-Changed:
Fires when the user selects a different button in the radio group.
When-Window-Activated:
Fires when a window is made the active window. Also fires at form start-up. All window
D2K For ms Builder
When-Window-Deactivated:
Fires when a user deactivates a window by setting the input focus to another window.
When-Window-Closed:
Fires when the user closes a window using the window specific close command (using
the control menu)
When-Window-Resized:
Fires when window is resized by a call to the RESIZE_WINDOW () built-in. It also fires
at form start-up.
On-Check-Delete-Master:
This trigger automatically created when you define a master-detail relation and set the
Relation Object's property for Master-Deletes to Non-Isolated. It fires when the user tries
to delete a row in the Master block in a Master-Detail Form. The trigger queries the
database to see if detail record exist for the master record. If details exist, the trigger
displays the message "Cannot delete master record when matching detail records exist”
On-Clear-Details:
This trigger is automatically created when you define a Master-Detail relation. It fires
during the clear phase of co-ordination, and clears all of the detail records in the detail
block. Co-ordination causing events can Delete_Record, Clear_Record. This trigger calls
the Clear_All_Master_Details procedure.
On-Populate-Details:
Oracle Forms creates the On-Populate-Details trigger for every master-detail relation. It
fires during the population phase of block co-ordination. The trigger first checks the
status of the master record and the value of its primary key field, then navigates to the
detail block to issue the appropriate query. The trigger calls the Query_Master_Details
procedure.
Pre-Form:
It fires at form startup. It is the first event to take place. It may be used to perform an
action just before Oracle Forms navigates to the Form from. “Outside” the form. It may
be used to initialize global variables and check authorization
D2K For ms Builder
Pre-Block:
It fires just before entering the block process. It may be used to perform an action before
Oracle Forms navigates to the block level from the form level. You can provide the entry
into the block on a particular condition by filling the trigger.
Pre-Record:
It fires just before entering the record. It may be used to perform an action before Oracle
Forms navigates to the record level. You can setup global variables as well as visual
attributes.
Pre-Text-Item:
It fires just before entering the item. It may be used to perform an action before Oracle
Forms navigates to a text item. You can set up global variables.
Post-Text-Item:
It fires after leaving the item. You can manipulate an item when Oracle Forms leaves a
text item. You can set up global variables as well as clear Global variables.
Post-Record:
It fires after leaving the record. You can manipulate a record when Oracle leaves a
record, you can clear global variables and reset visual attributes.
Post-Block:
It fires after leaving the block. You can set or clear global variables.
Post-Form:
It fires after leaving the form. This trigger may be used to erase global va riables, remove
recordgroups etc.
When-New-Form-Instance:
It fires at form start-up after navigation to the form is complete, Restricted package
procedures such as Go_ltem() etc. can be used in this trigger. It can be used to initialise
the form, perform query and navigation at start-up.
When-New-Block-Instance:
It fires after navigation to the block is complete. Fires each time a block is visited. It can
be used to initialise the block and perform query. It supports restricted package
procedures.
When-New-Record-Instance:
It fires after navigation to the record is complete. Fires each time a record is visited. It
can be used to initialise the record, set visual attributes. It supports restricted package
procedures.
D2K For ms Builder
When-New-Item-Instance:
It fires after navigation to the item is complete. Fires each time an item is visited. It can
be used to initialise the item, invoke LOV or Editor. It supports restricted package
procedures.
When-New-Instance triggers fire just after Forms has put the cursor in the Target location
and starts waiting for the user actions. Unlike the Pre- and Post -navigational triggers, the
When-New-Instance triggers do not fire in response navigational events that occur during
default form processing.
Post triggers will not fire, if the validation process for that object fails. Pre triggers do not
fire in Enter Query Mode.
Transactional triggers fire in response to a wide variety of events that occur as a form
interacts with the data source.
On-Check-Unique:
This trigger fires during a commit operation when Oracle Forms normally checks record
that the Primary key values are unique in a base table, It fires once for each et visual
attributes, record updated or inserted. If a duplicate is found, Oracle forms displays the
following message,
FRM -40600 Record has already been inserted
On-Column-Security:
This trigger fires when the block property ‘Column Security’ is set to True.
On-Count:
Fires when Oracle Forms performs the Count Query operation, to determine the number
of rows that the query criteria will retrieve. It prompts the following message,
FRM xxxxxx : Query retrieved x rows
On-Close
This trigger fires when the query is closed either by an Abort_Query process or when all
the records that satisfy the query criteria have been retirieved.
Pre-Commit:
This trigger fires once during the post and commit phase as apart of the default
processing of posting and committing. When the user initiates a commit, it is the first
trigger that marks the start of the posting phase.
Pre-Delete:
This trigger fires during the post and commit process. It typically fires just before the On-
Delete trigger. It fires once for every row deleted. It may be used to prevent deletion of
D2K For ms Builder
On-Delete:
This trigger fires during the post and commit process. Typically, it fires after the Pre-
Delete trigger and before Post-Delete-Trigger. It fires for every row deleted.
Post-Delete:
This trigger fires during the post and commit process. Typically, it fires soon after the
On-Delete trigger. It fires for each row deleted.
Example
Ensure that the employee details are recorded in an employee retirement table upto the
employee’s retirement.
Pre-Update:
This trigger fires during the post and commit process. It fires just before the Update
trigger. It fires once for each row updated.
On-Update:
This trigger fires during the post and commit process. It fires once for every row updated.
Post-Update:
This trigger fires during the post and commit process. It fire typically soon after the On-
Update trigger. It fires once for each row updated.
Pre-Insert:
This trigger fires during the post and commit process. It fires just before the On-Insert
trigger. It fires for each row inserted.
D2K For ms Builder
On-Insert:
Fires during the post and commit process. It fires once for each row inserted in the
default sequence. May be used to populate derived columns, to assign values to items not
displayed in the form.
Post-Insert:
This trigger fires during the post and commit process. It fires typically soon after the On-
Insert trigger. It fires once for each row inserted. May be used to update an audit trail.
Post-Forms-Commit;
This trigger fires after all changed rows are written (posted) to the database. It fires after
the form levels post is complete but before the database commit. A rollback is possible
from here. It fires before the On-Commit trigger.
On-Commit:
This trigger fires when Oracle Forms would normally issue a database commit statement
to finalize the transaction. It will fire once after all the Inserted, Updated and Deleted
rows are posted in the default sequence.
Post-Database-Commit:
This trigger fires after the On-Commit trigger, after the transaction is finalized and a
database commit is done. No rollback is possible from here. May be used to refresh
record groups, re-initialize global variables.
On-Lock:
This trigger fires as soon as the user acquired a lock on the row when he attempts to
update or delete the row.
On-Logon:
This trigger fires once per login when Oracle forms normally initiates the logon
sequence.
On-Logout:
This trigger fires once per log out when Oracle forms normally initiates the log out
sequence.
On-Sequence-Number:
This trigger fires when Oracle Forms normally perform the default action of generating
sequence numbers for the default item values. (When Oracle Form interacts with the
database to get the next value from a sequence object).
When-Validate-Record:
This trigger fires when the user navigates out of the record or as a part of the default
sequence of posting. It will fire only for records whose status is Changed.
Example
To check if the date of retirement of an employee is always greater than his date of
joining.
Begin
If :Emp.hiredate > :Emp.RetDate Then
Message('Invalid Dates ');
Raise Form_Trigger_Failure;
End if;
End;
When-Validate-Item:
This trigger fires when the user attempts to navigate out of the item or as a part of the
default sequence of posting. It fires for items with status as New or Changed.
Example
To populate control items (non-base table) during data entry. In the Order Entry form,
populate the values of the Customer name and Customer Address depending on the value
of the Custid field entered by the user. (Name and Address are control items)
Begin
Select name, address Into :ord.name, From customer
Where custid = :ord.custid;
End;
D2K For ms Builder
Pre-Query:
This trigger fires durin g execute query or count query processing, just before Oracle
Forms constructs and issues the Select statement to identify rows that match the query
criteria. It may be used to alter the example record that determines which row will be
identified by the query. If the trigger fails, the query is cancelled.
Example
Allow the user to query the Emp table based on the Department number selected at
runtime. Also allow the User to sort the output on any one of the following columns:
Empno, Salary or Hiredate.
Declare
ord- by char (1) ;
Begin
ord_by : = : ctl. sort;
If ord_by = ' E ' then
set_block_property('Emp',order_by, 'Empno');
Elsif ord_by = 'S' then
set_block_propertY('Emp',order_by, 'Sal');
Elsif ord_by = 'H' then
set_block_property( 'Emp' ,order_by, 'Hiredate' ).;
End If;
End;
Post-Query:
When a query is open in a block, this trigger fires each time Oracle Forms fetches a row
into the block. It may be used to populate control items (non-based table items), calculate
statistics about records retrieved and calculate running totals.
D2K For ms Builder
Example
To populate the department name into a control item in the Emp block for each
employee.
Begin
Select dname into :emp.dept_Name From dept
Where deptno = :emp.deptno;
END;
Message-Handling Triggers
On-Error Trigger
It fires in response to any error. It can be used to trap errors. You can change the default
error message given by Forms and replace it with your own message.
On-Message Trigger:
It fires in response to a default message by Oracle Forms. You can use it to change the
default message to the custom message.
Restric ted-Built-Ins:
A property class is a named object belonging to a module that contains a set of properties
and their settings. Once you create a property class you can base other objects on it. An
object based on Property Class can inherit the setting of any property in the class that is
valid for that object. When you make changes to the property class the changes are
reflected across all the objects that have inherited that class. Thus we can say that Form
Builder possesses Object Oriented features like inheritance Property class Inheritance is a
powerful feature that allows you to quickly define objects that conform to your interface
and functionality standards.
Inheritance is a relationship between objects such that the child object has all the property
settings of the parent object plus whatever additional ones that makes it a different.
You are already aware that for every Form Object the properties are defined in the
Property palette for that Object. You can assign values to these properties, say for
example Enabled, Displayed are properties of an object, whereas the values that you can
assign to them are 'True' or 'False'. You can create a Property Class and add the required
properties to it, and then assign values to it. Keep in mind that the object does not get all
the properties from the property class, just the values for the ones it already supports.
Thus you can say that a Property Class supplies initial values for the properties which
you can override to customize the object to your needs.
You can create a huge property class and then apply the property settings of the class to
the different types of objects. For example, a property class might contain properties that
are common to all types of items, or that, which apply only to radio groups, or apply only
to check boxes.
A Property Class itself can be based on another property class. Property classes allow you
to make global change to applications quickly by simply changing the definition of a
Property Class, you can change the definition of all objects that inherit properties from
that class.
1. In the Object Navigator, position the cursor on the Property Classes node and click on
the ‘+’ create button in the toolbar.
2. A property class object with a default name is inserted under the node. Open the
property palette of this class and you see that new property class does not contain any
properties.
Example
To create a Property Class for push buttons
Name: Button_Class
Item Type: Button
Canvas: <Canvas Name>
Enabled: True
Navigable: False
Mouse Navigable: False
Iconic: True
3. Select the property palette of the object to which the class is to be inherited. Select the
D2K For ms Builder
Subclass Informatio n property under the General nod_. The subclass Information
window is displayed. Choose the Property Class option and enter the appropriate
property class name and the module name to which the property class belongs. The
modules that are open will be seen in the list of modules.
4. A sign besides the property indicates that it has been inherited
Ø Select all the properties under one property group. Remain in the property palette.
Ø Click on the Property Class icon on the top horizontal tool bar. Forms builder will
notify the user that it has created a Property class with the selected property settings.
You can new base other objects on this class.
Creating a property class in this manner is faster than the previous method.
Example
To create four stacked canvases of the same size (width and height) and their x and y co-
ordinates also must coincide such that they overlap each other. So only one canvas is
visible at any point of time.
After inheritance the properties of the object can be either in an Inherited state or in a
Variant state.
A sign beside a property of the inherited object indicates that the property is
in an inherited state, which means the settings of the class from which it inherited the
property shall prevail runtime.
D2K For ms Builder
The setting of the new property can be made to override the inherited one, in which case
there will be sign and the settings of the individual property shall prevail.
Hence, once the object is based on a property class, you can modify its definition and
properties as follows,
To convert the property setting of an object from variant to inherited click on the Inherit
icon on the top horizontal tool bar in the property palette of that object.
The toolbar provides quick access to commands. Click once on the icon for the command
you want to execute. The Toolbar shown in the previous figure is explained below:
Copy Properties: Copies the property settings currently displayed in the Property
palette to the clipboard
Paste Properties: Pastes the clipboard property settings to the list of properties in
the Property palette. Properties that are on the clipboard but
not in the property list are ignored.
Add Property: Displays a list of values (LOV) from which you can choose a
property to be added to a property class. This command is
available only when you try to create the Property Class object
through the Property Class node in the object Navigator.
Delete Property: Removes the property currently selected in the property list. This
command is available only when you try to create the Property
Class object through the Property Class node in the object
Navigator.
Property Class: Creates a property class from the list of properties currently
displayed in the palette. The new property class object is inserted
under the Property Classes node in the Navigator and assigned a
default name
Inherit: Sets the current property to its default setting. If the property list is
based on a property class that includes the current property, the
default setting is the setting defined in the class. If the current
property list is not based on a property class or is based on a class
that does not include the current property, inherit sets the property
to the oracle forms default. (Inherit -sets the property to the forms
default for string values only, not for complex values).
Intersection/Union: Toggles the Property palette between union and intersection
display modes. This option determines which properties appears
when more than one object is selected at a time (a multiple
selection). In intersection mode (the default), only properties that
D2K For ms Builder
However, if the object itself has a similar trigger owned by it then the trigger attached to
the item would take precedence over the trigger that was defined with the property class
at runtime.
Ø In the Object Navigator, click on the Triggers node under the property class
Ø Click the create ‘+’ button in the toolbar
Ø Select the desired trigger from the LOV
Ø The PL/SQL Editor appears, showing the trigger you selected.
Ø Enter and compile the desired trigger code, then Close the editor
Ø The new trigger appears under the Trigger node for the property class
Look at the Fonts & Color node in the property palette of an Item.
D2K For ms Builder
Ø Font properties: Font Name, Font Size, Font Style, Font Width, Font Weight. Color
and pattern properties: foreground Color, Background Color, Fill Pattern, and White
on Black.
The Visual attribute group property specifies how the object's individual attribute
setting are derived. The following settings are valid for this property.
Ø Default
When Visual Attribute Group is set to Default, the individual attribute settings are
determined by a combination of factors, including the type of object, the resource file in
use, and the window manager.
An item that has Visual Attribute Group set to Default, or that has individual attribute
settings left unspecified, inherits those settings from the canvas to which it is assigned.
Similarly, a canvas that has Visual Attribute Group set to Default, or that has individual
D2K For ms Builder
attribute settings left unspecified, inherits those settings from the window in which it is
displayed. Visual attribute settings derived through window -canvas or canvas -item
inheritance are apparent only at runtime, not at design time.
Ø Named Visual Attribute
Specifies a named visual attribute that should be applied to the object. A named visual
attribute is a separate object in a form or menu module that define a collection of visual
attribute properties. Once you create a named visual attribute, you can apply it to any
object in the same module. When Visual Attribute Group is set to a named visual
attribute, the individual attribute settings reflect the attribute settings defined for the
named visual attribute object.
7 Form Objects
7.1 Editors
There are occasions when you need to create or maintain long strings of characters in
your application. But it becomes difficult for the user to view the entire contents of the
field and he has to scroll through it. In such cases he can make use of Editor, Which can
also provide basic editing tools such as search and replace, or cut and paste.
1. Default
2. System
3. User named
Default Editor
This is Forms internal editor. It provides standard-editing features, is built into every
form and is automatically available from every text item.
System Editor
If there is a system editor available you can specify that Form Builder use this editor in
Windows environment this editor is the Notepad Editor.
User Editors
It is an object that you can create from the object navigator. Because it is a named object
you can specify Editor attributes such as title, position, size, visual attribute. It can be
displayed programmatically with the SHOW_EDITOR built-in. The Show_Editor built-
in can be used not only to specify the location at which you want to display the editor, but
the source and destination of text can also be specified. You can invoke it from one or
more text items.
You can invoke the default editor by using Edit -> Edit from the runtime menu. It can be
displayed programmatically by executing the EDIT_TEXTITEM built-in.
e.g.
Create a form having a block based on Customer table. Since it has a field comments that
D2K For ms Builder
has long strings of chara cter, we will attach our editor to this field.
Built-in
Edit_TextItem
Syntax:
Edit_TextItem;
Edit_TextItem (x NUMBER, y NUMBER);
Edit_TextItem (x NUMBER, y NUMBER, width, NUMBER, height NUMBER);
e.g.
Edit_TextItem(100,100,140,135);
Parameter x specifies x coordinate to place the editor
Y specifies y coordinate to place the editor
Width specifies the width of the entire editor window
Height specifies the height of the entire editor window
To invoke the system editor open the property sheet of the desired text item and set the
property to SYSTEM_EDITOR by selecting SYSTEM_EDITOR from the Editor
property poplist.
You can also specify the editor's display co-ordinates by setting the Editor X position and
Editor Y Position properties.
You will invoke the System editor in the same manner as you invoke the Default Editor
by using Edit- Textitem built -in.
You can create the user defined Editor through the object navigator as follows:
The Custom Editors have an additional feature. You Use the Show_Editor built-in not
only to display the user named editor at the location you want, but also specify the source
of the text (message_in), and the destination of the contents of the dialog box
(message_out), when user dismisses it by pressing Ok.
Syntax
Show_Editor(editor_name, message_in, x, y, message_out, result);
The result parameter is a Boolean IN OUT parameter. If the operator accepts the editor,
SHOW_EDITOR sets result to TRUE, and sets message_out to the current text string. If
the operator cancels the editor, SHOW_EDITOR sets result to FALSE, sets message_out
to NULL.
Syntax
SHOW_EDITOR(editor_id, message_in, message_out, result);
SHOW_EDITOR(editor_id, message_in, x, y, message_out, result);
SHOW_EDITOR(editor_name, message_in, message_out, result);
SHOW_EDITOR(editor_name, message_in. x, y, message_out, result);
Description
Displays the given editor at the given co-ordinates and passes a string to the editor, or
retrieves an existing string from the editor. If no co-ordinates are supplied, the editor is
displayed in the default position specified for the editor at design time.
Parameters
Editor_id: Specifies the unique ID that Form Builder assigns when it creates the
editor. Use the FIND_EDITOR built-in to return the ID to a variable of the
appropriate data type. The data type of the ID is Editor.
Editor_name: Specifies the name you gave to the editor when you define it.
Message_in: Form item that displays text into editor.
Message_out Form item where the typed string must be sent.
X, Y Position: It's optional to specify these parameters.
Return value: is of Boolean type.
True If editor was accepted. False: If editor was cancelled
e.g.
After a query operation the value of comments field is passed to variable ‘var’ the Editor
is then Displayed. If the operator makes modifications to the Comments then the item is
updated.
Ed_name VARCHAR2(40);
Val VARCHAR2(32000);
Ed_ok BOOLEAN;
BEGIN
Ed_name:= 'my_editor1' ;
Ed_id := Find_Editor( ed_name );
Val := :Customer.comments;
Show_Editor( Ed_id, val, 10,14. val, Ed_ok);
IF Ed_ok THEN
:Customer.comments := val;
END IF;
END;
The visual attributes used by the default editor are default attributes of Form Builder. If
you want to make it look consistent with your application then create an Editor Object
and set its Properties in the Property Palette.
e.g.
1. Create an editor in object Navigator
2. Set its Visual Attribute Name Property to a Visual Attribute already created by
you.
3. Set the title Property. You can also specify a bottom Title, Scrollbars for the
dialog box.
4. Attach the editor to the desired text item
7.2 Timers
A Timer is an internal clock created at runtime only and can be re-initialized on its
expiry. A Timer is a programmatic construct, which you can create, modify or delete.
When you create or modify a timer, you can specify the time, which elapses before the
timer expires. Using the When-Timer-Expired trigger, you can specify what actions must
be performed at that time.
Syntax
Create_Timer (timer_name, milliseconds, iteration);
e.g.
This statement when executed will create a timer named 'my_timer' which will expire
D2K For ms Builder
after 1000 milliseconds i.e. 1 sec. The iteration parameter can take two values REPEAT
and NO_REPEAT. If REPEAT is specified the timer will repeat upon expiration of this
timer. If NO_REPEAT is specified then the timer will not repeat once it expires.
e.g. no 1
To create a timer at form start-up which expires every 10 secs to display a message.
TRIGGER NAME: PRE -FORM
Trigger Text;
Declare
time_id timer;
Begin ,
time_id := create_Timer( 'my_timer',10000,_REPEAT);
if Id_ Null(time_id) then
Message('Error in creating timer');
Raise form_Trigger_Failure,
End if;
End:
e.g. no 2
To display a running clock in the form
Trigger Name When-New-form-Instance
Trigger Text
Declare
Timer_id timer,
Begin
Timer_id := Create_timer (‘clock’,1000,repeat);
End;
Trigger: When-Timer-Expired
/*Create a control block named control_block having run_clock as a text item*/
If Get_Application_Property(Timer_Name) = 'CLOCK'
then
:control_blk.run_clock:=To_char(sysdate,'HH:MI:SS');
end if;
D2K For ms Builder
e.g.
Declare
Tm_name varchar2 (30);
Begin
Tm_name := Get_Application_Property(Timer_Name);
If tm name = 'Timerl' then
…Do… this…;
Else Tm_name = 'Timer2 ' then
…Do… this…;
End If;
End;
1. Highlight the LOVs node in the object navigator and select Navigator -> Create from
the menu
2. The following dialog will be displayed:
Ø If you want to attach an existing record group, you can browse through the
record groups that exist in Form module, by clicking on the SELECT button.
Ø If you want to create a record group based on a query, you can do so by entering
the Query in the Query text column
3. Click on the OK button to create the LOV.
If you have written a query in the Query Text you will see that along with the LOV a
Record Group is also created. After creating an LOV it can be attached to an item.
D2K For ms Builder
Open the Property sheet of an item and set the following Miscellaneous settings:
To specify the return values i.e. the text item to which the value from LOV should be
entered, open the property sheet of the LOV and select the Column mapping Property.
The following dialog is displayed. Enter the name of the item in the Return item column
and set the width appropriately.
The Return Value specifies the name of the form item or variab1e to which Form Builder
should assign the column's value whenever the operator selects an LOV record. A return
item-can be a form object, a global variable or a form parameter.
D2K For ms Builder
To display an LOV during a runform session after attaching it to a text items. You can
simply run the form, when you navigate to the item, the status bar displays a message
showing <List Of Values>, which indicates that a list is attached to that item. Choose
Edit ->Display List from the runform menu to view the list.
Or you set the LOV's Auto-display property to True, Form Builder displays the LOV
automatically when the operator navigates to the text item.
To display the list programmatically you can write a trigger or user-named routine that
executes the SHOW_LOV or LIST_VALUES built-in subprogram.
D2K For ms Builder
List_Values
It can be used when current item has an LOV attached. It can be called in the When-New-
Item instance trigger.
NO_RESTRICT
Form Builder will not use the automatic search and complete feature.
RESTRICT
Form Builder will use the automatic search and complete feature.
Show_Lov
D2K For ms Builder
It can be displayed irrespective of whether an LOV has been attached to an item or not. It
returns true of a selection was made and false if it was cancelled.
Syntax
SHOW_LOV (lov_id LOV);
SHOW_LOV (lov_id LOV, x NUMBER, y NUMBER);
SHOW_LOV (lov_name VARCHAR2);
SHOW_LOV (lov_name VARCHAR2, x NUMBER, y NUMBER);
Parameters
lov_id: Use the FIND_LOV built-in to return the ID to an appropriately typed
variable. The datatype of the ID is LOV.
lov_name: The name you gave to the LOV when you define it. The datatype of the
name is varchar2.
x: Specifies the X coordinate of the LOV.
y: Specifies the Y coordinate of the LOV
Because SHOW_LOV is a restricted built-in, when you use it to display an LOV. Form
Builder ignores the LOV’s Automatic Skip property.
If you want to move the cursor to the next navigable item, use the LIST_VALUES built-
in. LIST_VALUES is an unrestricted built-in.
There are several properties of LOV that govern the behaviour of the LOV’s objects at
runtime. You can set them in the Property Palette.
First you change the look of the LOVs dialog box – Visual Attribute Name property to
the desired choice (Create a visual attribute to attach it to the LOV).
Other Properties
Automatic Select
If Auto confirm is set to ‘Yes’ the, when the list is reduced to one element through the
auto-reduction process, that element will be picked automatically without users having to
confirm the selection. (Default – False)
Automatic Display
If Auto display is ‘Yes’ each tome the focus is on the item to which the LOV is attached,
the LOVs dialog box is displayed. (Default – False)
D2K For ms Builder
Automatic Refresh
If the Auto Refresh is ‘Yes’ (default) means each time the LOV dialog box is invoked,
the query to which the record group is populated will be fired. If false the query is fired
only the first time the LOV is invoked.
Automatic Skip
Moves the cursor to the next navigable item when the operator makes a sele ction from an
LOV to a text item. When Automatic Skip is set to No, the focus remains in the text item
after the operator makes a selection from the LOV.
Set_Lov_Property
Syntax
Set_Lov_Property(‘Lov_name’, Property, value)
Parameters
Lov_name: Indicates the name of the LOV in quotes or the id of LOV without quotes.
Property: Indicates the name of property which is to be set.
Value: Indicates the value to which the property is to be set.
Declare
x boolean;
Begin
x := Show_Lov ('My_LovI);
End;
e.g. – 2
1. Create a form that has a block based on customer table. Let us try to query the form
based on the customer numbers. Paste a push button labeled ‘Select’
2. Create a LOV. The query Text column should have the following query:
Select custid from customer
Let the Return Value be :global.cno
3. Write the following code in the When-Button-Pressed of ‘Select’;
Declare
Lov Selected boolean;
Begin
D2K For ms Builder
Lov_Selected := Show_Lov('Cust_Lov');
If Lov_Selected then
Execute_query (No_validate) ;
End If;
End;
4. Pre-Query of Customer block
:customer.custid := :global.cno;
7.4 Alerts
Form Builder has many built-in alerts that display pre-defined messages. You can also
create your own custom alerts that display in response to application-specific events. Say,
for example you have to run a form but you have not connected after logging into forms
Builder Form Builder Brings up the 'Connect' dialog box.
Alerts are internal Form Objects that when invoked at runtime are displayed as modal
dialog boxes. They are used to notify the user of some application condition. They may
be used to warn the user about some action, which might cause some undesirable
situation.
Form Builder has many built-in alerts that display pre-defined messages. You can also
create your own custom alerts that display in response to application-specific events.
It is a kind of dialog box that displays a message with an icon. Every alert must have at
least one push button and may have up to three buttons. Every other operation in the
application is halted until the alert is dismissed. Pressing one of its push buttons can
dismiss the alert.
Steps
Ø In the Navigator, select the Alerts node and then choose Navigator -> Create
Ø Go to the Properties window, set the Alert Style property to either Stop, Caution
message in the alert window.
Ø Set the Message property by entering the message you want the alert to display at
runtime. You can enter upto 200 characters.
Ø Define one or more buttons for the Alert by entering the text table in the Button 1
Label, Button 2 Label, Button 3 Label properties. Buttons that do not have labels are
not displayed. Default buttons are OK and Cancel.
Ø Choose the default Alert button Button 1, Button 2 or Button 3
Ø The default button is the button that is selected implicitly when the operator presses
[Accept]
X := Show_Alert(alert_name);
Where x is declared as a numeric constant
The constant returned by the Show_Alert function indicates the alert button, which the
operator selected and is one of the following:
You can store the value of the returned constant like the above and perform an action
depending on the button pr essed by the user.
e.g.
To create an Alert that warns the user whether he really wishes to exit the application.
This alert may be displayed from the When-Button-Pressed trigger for ‘Quit’ Push
button.
Steps
Ø Create the Alert as usual from the Object Navigator
D2K For ms Builder
8 Record Groups
A Record Group is an internal Forms Builder data structure that has a column / row
framework and can be thought of as two-dimensional array if multiple data types.
Basically, they are sepa rate objects that belong to a Form module in which they are
defined. They can be created dynamically or at design time. A record group can have
unlimited number of columns of type Char, Long, Number or Date provided that the total
number of columns does not exceed 64K.
At Design Time
In Navigator, select Record Groups node and click on create ‘+’ button in the toolbar.
The following New Record Group Window will be displayed.
At Runtime
Query record group
Let us create a query record group at runtime. The following code generates a record
group named ‘RG1’ and populates it.
Declare
Rg_id recordgroup;
Err_cd number;
Begin
Rg_id := create_group_from_query(‘RG1’, ‘select emp_no ‘ | | ‘, ename from emp’);
Err_cd := populate_group (rg_id);
If Err_cd < > 0 then
Message (‘Cannot populate the record group’);
End if;
End;
In the declaration part of the code rg_id has been defined to be an item of type
recordgroup. The CREATE_GROUP_FROM_QUERY built-in creates a record group
and returns the object id of type recordgroup. The CREATE_GROUP_FROM_QUERY
D2K For ms Builder
The syntax is
CREATE_GROUP_FROM_QUERY(recordgroup_name,
Query,
Scope,
Array_fetch_size);
Where recordgroup_name is the name of the record group being created. Query is a valid
SQL SELECT statement, enclosed in single quotes. Scope specifies whether the record
group can be used within the current form or with every form in a multi-form application.
Takes the following constants as arguments.
Ø FORM_SCOPE – indicates that the record group can by used only within the current
form. This is the default argument.
Ø GLOBAL_SCOPE – indicates that the record group is global, and that it can be used
within all form in the application. Once created, a global record group persists for the
remainder of the runtime session.
Array_fetch_size specifies the array fetch size i.e. the number of records that will be
fetched at a time. The default array size is 20.
We have nit supplied the scope and array_fetch_size parameters as they are not the
required parameters and have default values.
Initially the record group does not have any rows. To populate the group with data the
function POPULATE_GROUP built-in is used. It returns 0, if successful or the oracle
error code, if it fails. Next we check the value returned by POPULATE_GROUP built-in
and display the message “Cannot populate the record group’ in case the group has not
been populated with records.
Declare
Rg_id recordgroup;
Col_id groupcolumn;
Begin
Rd_id := create_group ( ‘RG1’ );
Col_id := add_group_column (rg_id, ‘DNAME’, CHAR_COLUMN,20);
Add_group_row ( rg_id, END_OF_GROUP);
End;
To create non-query record group use the CREATE_GROUP function. This function
creates a record group, which does not have any rows or columns and returns the object
D2K For ms Builder
Example
1. To create a dynamic list item
Ø Open a New form
Ø Create a block base d on EMP table
Ø Create a query record group at deign time that contains the name of
departments and department numbers. The property sheet of the record
group is as follows.
D2K For ms Builder
Ø Populate the list item dynamically at runtime, using the design-time query record
group. For this write the following trigger code.
Trigger: When-New-Item-Instance on Deptno
Declare
List_id item;
Rec_grp recordgroup;
begin
list_id := Find_item (‘Emp.Deptno’);
rec_grp := find_group (‘RG2’);
If populate_group(rec_grp) = 0 then
Populate_list(list_id, rec_grp);
Else
Raise Form_trigger_failure;
End If;
End
In the above code we first populate the already created record group RG2. if
Populate_group has been successful in fetching the records we populate an item of type
List item (Combo Box) with the record group using the Populate_list built-in.
populate_list removes the contents of the current list and populates the list with the values
from a record group. If Populate_List is not successful then we are raising the
D2K For ms Builder
9.1 Introduction
A canvas is a surface – inside a window, a container – on which you place the interface
items that end users interact with when they run the form. Canvas views are the
background objects on which interface items and boilerplate objects are placed.
Each item refers to exactly one canvas in its Property Palette. You can divide a data
block’s items between different canvases.
A canvas does not stand alone as an interface object. To see it and its items you must
display the canvas in a window, a rectangular area of the application display surrounded
by a frame. Developer/2000 makes these separate objects and lets you build windows that
provide a View of the canvas. A View is a rectangle within the windows that covers all or
part of the canvas. The part of the canvas that you can see through the window is the
view.
When you create a form module, you work with various objects specific to form modules,
such as: windows, canvases, blocks and items. A window is, by itself, and empty frame.
Windows have a title bar and handles for interaction, allowing end users to scroll, move,
and resize the window. Items are interface objects that display information to end-users
and allow them to interact with the application.
In short, we can say that a canvas-view is similar to the canvas on which we paint,
whereas a window is like the frame in which we enclose the canvas.
A canvas type defines how Form Builder will display it in the window to which it is
assigned. When you create a canvas, you specify its type by setting the Canvas Type
property.
Content Canvas
A content canvas-view is a base view, which occupies the entire window on which it is
placed. There must be at least one content canvas-view for each window. A window can
have more than one content canvas-view, but only one will be displayed at a time, during
runtime.
Tab Canvas
A tab canvas is made up of one or more tab pages, which allows you to group and display
a large amount of related information on a single canvas object. Like stacked canvases,
tab canvases are displayed on top of a content canvas. Tab pages each display a subset of
the information displayed on the entire tab canvas. The tab canvas is a new type of
canvas that enables you to organize and display related information on separate tabs.
When the operator clicks the label area of a tab page at runtime, the tab page is brought to
the front of the tab canvas, obscuring all other tab pages on the tab canvas.
Tab pages have properties, and items placed on a tab canvas have tab canvas properties as
well as tab page properties. You can define a canvas to have a series of tab pages.
D2K For ms Builder
About Views
Whenever you create a block Form Builder automatically creates a content canvas in the
Layout Wizard. You can also create a canvas in the object navigator by selecting the
‘Canvas’ header and clicking Create tool. You can set the ‘Canvas Type’ (default
Content) and the window that displays the canvas in the Property Palette for the canvas as
shown in the figure below.
You can control the display of the Canvas background through the View | Show Canvas
menu item, available when Layout Editor is active. You can also resize the canvas itself,
by dragging the Selection handle in the lower right corner of the canvas. To see this turn
on the View | Show Canvas menu item. You can also change the Width and Height
attributes in the Property Palette.
The View | Show View menu item lets you see the view. If you display the canvas in a
window, the view is the area of the canvas you would see.
Stacking Canvas
Steps
1. Create two Canvases Dept_canvas and another Emp_canvas. By default both Canvas
are of type Content.
2. Create two data blocks in the usual way (using the data block wizard)
3. First a Dept data block on the Dept_canvas and a Emp Data Block on the
Emp_canvas. Set up the master – detail relation between dept and Emp block.
4. Change the ‘Canvas Type’ property of Emp_canvas from Content to Stacked
5. Select Emp_canvas, Choose Tool -> Layout Editor. In the Layout Editor size the
view. To size the stacked view Choose View -> Show View (do not do this if the
D2K For ms Builder
option is already Checked). The Layout Editor displays the View as a 1-point black
rectangle with ha ndles, which you can resize. (Scroll downwards if the handles are
not visible) Drag the handles upward to reduce the size to a little larger than the frame
surrounding the data block.
6. In the Layout Editor Choose View -> Show Canvas (do not do this if the option is
already Checked). Size the canvas following the method followed for sizing rge view.
Keep the size of the canvas a little more than the View or equal to the view.
If you want to see where the Emp_canvas canvas will be stacked during runtime.
1. Select the Dept_canvas from layout Editor.
2. From the menu select View -> Stacked Views. Select Emp_canvas from the list of
stacked canvases displayed. Clic O.K.
ViewPort X Position : 25
ViewPort Y Position : 25
In other words the above properties set the coordinates at which the Emp_canvas should
be stacke d on content (Dept_canvas)
ViewPort Width is the width of the view
ViewPort Height is the height of the view
D2K For ms Builder
(In the layout editor with stacked canvas selected, open property palette of the canvas
keeping both open, in the status bar in the layout editor you can actually see the x and y
position of the view (lower right corner).
ViewPort X position on Canvas and ViewPort Y position on Canvas under the Physical
node in the property palette of the canvas are used to set the position of the canvas where
it should be displayed with respect to the window.
For content or toolbar canvas-views, the view size is determined by the size of the
window.
The final step is to tell Form Builder when to show the stacked canvas. Ordinarily, you
show the canvas and its window by navigating to an item on that canvas. This has the
effect of making the stacked canvas appear and disappear when you navigate to and from
items on it.
In our e.g. we want to navigate to the dept block, not to an item on the Emp_canvas but
you still want to see the stacked canvas every time you navigate the dept block then
D2K For ms Builder
Show_View (‘Emp_Canvas’);
If the stacked canvas needs to be displayed when required only, then, in the Dept_canvas
create a puch button Emp_details as shown
9.3 Windows
As described earlier, window is like a frame on which the canvas-view are placed. The
frame provides a title bar and a handle for interacting with the window. It is necessary to
have atleast one content canvas on a window. There can be any number of windows in a
form. Every new form contains a window named WINDOW1 by default.
MDI Window
Forms supports MDI (multiple document interface) system of windows management.
MDI applications display a default window called application window. The Windows
manager automatically creates a MDI (multiple document interface) window at runtime.
This type of window does not come in the forms list of window styles, since it is created
at runtime. The name of the MDI Window is FORMS_MDI_WINDOW.
D2K For ms Builder
Document:
A Document window is always displayed within the framework of the application
window. If the size of the application window is less than the document window, you
specify its modality by setting the Modal property to True or False. The default is False,
which creates a modeless window.
Dialog Windows:
A Dialog window is a mobile window. We can move it out of the application window, if
we have defined it as movable (i.e. settings its movable property in property sheet to
true). The dialog window does not get clipped even if the size of parent window is less
than it is.
Modeless Windows
1. More than one modeless window can be displayed at the same time
2. Modeless windows can also be layered to appear either in from of or behind other
windows
3. Modeless windows can remain displayed until they are dismissed by the operation
or hidden programmatically.
4. You can set the Remove on Exit property for a modeless window to specify
whether it should remain displayed when the operator navigates to another
window.
5. You can set the properties of a modeless window to specify its border and title
and whether operators should be allowed to scroll, resize, move, close, iconify,
and zoom the window
Modal Windows
1. Modal windows are usually used dialogs
2. Modal windows cannot have scroll bars, and setting the Scroll Bar properties for a
modal window has no effect
3. The Remove on Exit property doe s not apply to modal windows. By default,
Form Builder prevents operators from navigating out of modal windows with the
mouse, but does not allow them to navigate to another window with keyboard
commands. When such navigation occurs, Oracle Forms always closes the modal
window, unless the target window is itself a modal window
D2K For ms Builder
10 Object Groups
10.1 Introduction
An object group is a container for a group of objects. Related objects are packed together
in an object group, which can then be copied or reference in another module. Thus, object
groups enable us to implement reusability.
For examples, all the data entry forms have to be provided with common facilities like
adding, deleting, saving a record etc. Instead of creating these buttons for these activities
and writing various triggers on them, we can create push buttons for these activities in a
separate canvas/block an then include this in the object group. This object group can then
be referenced across the forms. Thus, with the help of object groups, we can reuse the
block as well as the contents of the block (items, triggers) and maintain consistency.
You can create object groups in Form and Menu modules. Once you create an object
group, you can add and remove objects to it as desired.
In the Object navigator, position the cursor on the object Groups node and choose
Navigator -> Create. An object group with a default name in inserted under the node.
When you double-click to expand the object, the Object Group Children node appears.
Objects you add to the group appear under this node.
In the Object Navigator, drag the desired object(s) under the Object Group Children
node.
The screen figure 1 shows us an object group named ‘object_group25’. The ‘Ctl’ block is
a control block, whic h contains the iconic buttons. This block is assigned to a vertical
toolbar type of canvas-view ‘TOOL-CAN’. The block and the canvas view have been
dragged under the object group children node.
D2K For ms Builder
In the Object Navigator, select the object(s) you want to remove from the group and
choose Edit -> Cut, Edit -> Clear, or Navigator -> Delete. Removing an object from an
object group does not delete the object from the module.
To reference the object group created in one module from another module.
Click on subclass to subclass the object group. When you subclass an object, you create
an object that inherits its functionality and appearance from another object. Subclassing
and the resulting subclassed object maintains a link to its source object. A subclassed
object automatically inherits any changes that have been made to the source object when
you open or recompile the module that contains the subclassed object unless both
modules are open. If both modules are open, changes are inherited immediately.
For example, when you copy a block, the new block includes any items that were
owned by the block and any triggers that were attached to the block or its items.
When a block is dragged into an object group, all objects that are owned by the block
(items, triggers, relations) are also included in that object group. But objects owned
by blocks cannot be placed in an object group independently of the block in which
they are defined. To include these objects in an object group, you must include the
block itself.
3. The objects in a group must all be defined in the same module. You cannot place
objects from two different forms in the same object group.
D2K For ms Builder
5. When an object in an object group is deleted from a module, it is removed from the
object group automatically.
6. Deleting an object group from a module does not delete the objects it contains from
the module.
7. Object groups do not store copies of the objects they contain, but rather pointers to
the objects. The size of the module does not increase substantially, even though
object groups might be defined in it.
D2K For ms Builder
Form Builder is a development tool that allows you to create applications with multiple
blocks, windows. Many a times a need arises, when the func tionality of a system must be
split into different subsystems. Each of these subsystems may be further divided into
smaller systems, which are implemented as separate Form modules. In development
efforts for large enterprise systems, you need to create and maintain separate modules,
which are later on integrated, in larger systems. In these systems, a module that
represents the most important part of functionality is usually launched first. The users can
invoke the other modules as and when needed.
A multiple-form application is one that is designed to open more than one form during a
single Runform session. When the runform session is invoked to run a form, Form
Builder looks for the form in the appropriate directory and then loads it into memory
form, which is being executed. These forms can, in turn, invoked still other forms. When
one form programmatically invokes another, Form Builder looks for the new form in the
appropriate directory and then loads it into memory.
When you deliver a multiple-form application to end users, all >FMX, .MMX, and .PLL
(form, menu, and library) files that will be called during the session must reside in the
working directory.
Ø Open_Form
Ø Call_Form
Ø New_Form
11.2 Open_Form
This is a procedure to open an independent form. When one form invokes another form
by executing OPEN_FORM, operators can navigate between the forms as desired. An
opened form can share the same database session as the form from which it is invoked, or
D2K For ms Builder
Calling Open-Form leaves the current form accessible but replaces the current menu with
the called forms menu.
You can navigate to items in other forms either with the mouse OR with the Go_Form,
Next_Form and Previous_Form built-in subprograms. While navigating Developer/2000
does no validation and fires no triggers other than the When-Window -Deactivated trigger
on the current form and the When-Window-Activated trigger and When-Form-Navigate-
trigger on the target Form.
Use a When-Form-Naviagte trigger to perform actions when any cross form navigation
takes place without relying on window activate and window deactivate events.
When you specify the ACTIVATE parameter, Open_Form gives the called form the
focus and ignores any statement following the Open_Form call in the calling PL/SQL
block. When you specify NO_ACTIVATE parameter, Open_Form keeps the focus on the
calling form and continues executing the statements following the Open_Form call.
If you use Open_Form, you can open the form in a new database session, and hence can
initiate a different transaction, by using the SESSION Parameter. Default is to Open the
form in the same session as the calling form. Opening separate forms in separate sessions
keeps your transaction separate so that you can deal with them independently. On the
other hand, if the forms use the same tables, you can get lock conflicts when both
transactions try to access the same tables at once. Separate sessions are most useful when
the forms do not share tables. NO_SESSION opens the form in the current session.
Syntax
Open_form (form_name);
Open_form (form_name, activate_mode);
Open_form (form_name, activate_mode, session_mode);
Open_form (form_name, activate_mode, session_mode, data_mode);
Open_form (form_name, activate_mode, session_mode, paramlist_name);
Open_form (form_name, activate_mode, session_mode, paramlist_id);
OPEN_FORM (form_name, activate_mode, session_mode, data_mode paramlist_name);
Parameter Description
Form_name Indicates the name of the form to be opened Open_form (‘my_form’);
Activate_mode It takes two values ACTIVATE and NO_ACTIVATE. ACTIVATE
sets focus to the form to make it the active form in the application
whereas NO_ACTIVATEE opens the form but does not set focus to
the form. The current form remains the active form. You can open a
form named ‘my_form’ from the running/current form in activate
mode as Open_form (‘my_form’, ACTIVATE);
Session_mode This parameter can take two values NO_SESSION and SESSION.
NO_SESSION option specifies that the opened form should share the
D2K For ms Builder
Tips
When you open a form with ACTIVATE or NO_ACTIVATE option, then any start-up
triggers (lie pre-form) of the opened form that would normally fire will execute.
When you open a form with ACTIVATE option 9the default), the opened form received
focus immediately; trigger statements that follow the call to OPEN_FORM never
execute.
When you open a form with NO_ACTIVATE specified, trigger statements that follow
the call to OPEN_FORM will execute after the opened form has been loaded into
memory and its initial start-up triggers have fired.
Form Builder Runform must be running with the Session option turned ON when you
execute OPEN_FORM with the session_mode parameter set to SESSION. If the Session
option is Off, Form Builder issues an error and does not open the indicated form. This
option can be turned on by setting the environment variable FORMS45_SESSION /
FORMS50_SESSION (set in oracle.ini file) to TRUE. This setting enables multiple
sessions in Forms.
11.3 CALL_FORM
When you call one Form from another, the form which makes a call is referred to as the
parent form while the one which is called is referred to as the called form. A call to
CALL_FORM built-in loads the called form into the memor y (for its execution), but the
parent form also remains active i.e. the parent form does not release the memory
allocated. Form Builder runs the called form with the same Runform preferences as the
parent form. When the called form is exited Form Builder, processing resumes in the
calling form at the point from which you initiated the call to CALL_FORM. Till the
control is in the called form, you cannot navigate to the parent form. You have to exit the
D2K For ms Builder
Syntax
Call_form (form_name);
Call_form (form_name, display);
Call_form (form_name, display, switch_menu);
Call_form (form_name, display, switch_menu, query_mode);
Call_form (form_name, display, switch_menu, query_mode, data_mode);
Call_form (form_name, display, switch_menu, query_mode, paramlist_id);
Call_form (form_name, display, switch_menu, query_mode, paramlist_name);
Call_form (form_name, display, switch_menu, query_mode, data_mode,
paramlist_name);
Parameters
Parameters Description
Form_name Specifies the name of the called form. The name must be enclosed in
single quotes.
Display Takes any of the two values HIDE or NO_HIDE. HIDE is the default
parameter. It clears the parent form from the screen before drawing the
called form. When NO_HIDE option is specifies, Form Builder
displays the called form without clearing the calling form from the
screen.
Switch_menu Takes any of the two values NO_REPLACE or DO_REPLACE.
NO_REPLACE is the default parameter; when it is specified the
default menu of the parent form remains active for the called form.
When DO_REPLACE option is specified the called form retains its
own menu.
Query_mode Takes any of the two values NO_QUERY_ONLY or QURY_ONLY.
When the NO_QUERY_ONLY mode is specified the called form runs
in normal mode. In the normal mode you can insert, update and delete
the records from the called form. QUERY_ONLY option causes Form
Builder to run the indicated form in Query Only mode. In this mode
you can only query the data, but cannot insert, update or delete any
records.
Data_Mode NO_SHARE_LIBRARY_DATA (The default) At runtime, Form
Builder will not share data between forms that have identical libraries
attached (at designe time).
SHARE_LIBRARY_DATA At runtime, Form Builder will share data
between forms that have identical libraries attached (at design time)
Paramlist_id This is the unique ID, which Form Builder assigns to the parameter
list, when it is created. It specifies the unique ID Form Builder assigns
when it creates the parameter list.
Paramlist_name This is the name of the parameter list, which you create. This list
should consist of parameters of TEXT_PARAMETER type only.
This trigger does not fire when control returns to a calling form from a called form.
D2K For ms Builder
In a multiple-form application, this trigger does not fire when focus changes from one
form to another.
A – Parent form
B – Called form
When Form A calls Form B, Form B becomes the active form in the session, but Form A
remains in me mory.
1. When you call form B from A, initially Oracle Form will issue a savepoint for form V
i.e. a savepoint is set for form B when it is called or started. So when B is the active
or current form and if a rollback is fired during its processing then all the
uncommitted changes get rolled back to the save point of form B. This means that all
the changed in formB will get rolled back but not the changes made to form A.
2. If form A is running in the QUERY_ONY mode, then form B will also run in
QUERY_ONLY mode irrespective of the query_mode poramter for form B.
3. Some memory allocated for CALL_FORM is not deallocated until the Runform
session ends. So be cautious, when creating a large stack of called forms.
4. When the calling form has pending updates or deleted that have not been posted or
committed, the called form runs in the post-only mode.
Using Call_Form or New_Form requires that you use commit or post data to the database
before calling the new form.
When we update, delete or insert any record Form Builder has to maintain the status of
the record and mark these records as changed, deleted or inserted. When a commit
operation is fired, Form Builder issues appropriate SQL statements to update, delete or
insert. It then issues a COMMIT statement to commit all these changes and make them
permanent onto the database.
Posting consists of writing updates, deletions, and insertions in the form to the database,
but not committing these transactions to the database i.e. these changed are not made
permanent. To only post the changes the POST built -in can be used. When the changes
are posted Form Builder need not maintain the status if the records.
D2K For ms Builder
When the called form is running in the post -only mode, then the called form is allowed to
fire a commit. This is because if the commit is fired then the changes made to the calling
form also get committed. It is only allowed to post the changes. A form called from a
form running in post only mode also runs in post-only mode.
To avoid the form from running in post-only mode, explicitly post the changes made in
the calling form by using the POST built-in. execute this procedure just before making a
call to other form. After that whenever a commit is issued in the called form, the changes
made to the calling form are also committed.
If the called form is running in the post-only mode, then before exiting the form and
returning to the parent form, it is required to post the changes made in the called form.
After that whe never commit is issued in the parent form then the changes made to the
calling form as well as to the called form are posted.
11.4 NEW_FORM
The new_form built-in loads the new form into the memory after exiting the parent form.
It runs with the same preferences as the parent form. If the parent form has also been
called from another form then, the new form runs with the preferences of its parent (i.e.
you can say that the new form runs with the Runform preferences of its grandparent).
Syntax
New_form (form_mode);
New_form (form_mode; rollback_mode);
New_form (form_mode; rollback_mode; query_mode);
New_form (form_mode; rollback_mode; query_mode, data_mode);
New_form (form_mode; rollback_mode; query_mode, paramlist_id);
New_form (form_mode; rollback_mode; query_mode; paramlist_name);
New_form (form_mode; rollback_mode; query_mode, data_mode, paramlist_name);
Parameters
Parameters Description
form_name Specifies the formmodule of the called form. The name must be
enclosed in single quotes. The data type of the name is CHAR
rollback_mode This parameter can take three values TO_SAVEPOINT,
NO_ROLLBACK or FULL_ROLLBACK.
When the TO_SAVEPOINT option is specified Form Builder rolls
back all uncommitted changes (including posted changes) to the current
form’s savepoint.
D2K For ms Builder
1. When a form is called through anothe r form by using the new_form built-in, the
calling form is terminated as the parent form.
2. Form Builder releases memory that the terminated form was using
3. If the calling form had been called by a higher form, i.e. if A. B, C are three forms
such that A calls B and B in turns calls C, the Form Builder keeps the higher call
active i.e. it’ll keep A active and treat it as a call to the new form C. So A will be
treated as parent to C.
4. Form Builder runs the new form with the same Runform options as the parent for m. If
the parent form was a called form i.e. form B in our example, Form Builder runs the
new form with the same options as the parent for i.e. of form A.
rolling back the entire transaction. Creating a savepoint when you move to a different
form, gives you more control over what happens when the called form closes. If there is a
rollback and there is a savepoint, ORACLE only rolls the changes back to the point
before you called the new form, preserving all the changes you made and posted.
Exit_Form and Clear_Form have two parameters, the commit mode and the rollback
mode. The exit process first commits any changes based on the commit mode. The
commit mode can take any of the following values:
ASK_COMMIT :Ask the user whether to commit changes, then validate changes
and commit (default).
DO_COMMIT :Validate the Changes, commit and exit without asking the user.
NO_COMMIT :Validate the Changes, exit without commit
NO_VALIDATE :Exit without validating, committing or asking the user.
The rollback mode may have one of the following three possible values.
TO_SAVEPOINT :Roll back changes to the current form’s savepoint, then exit
(default)
FULL_ROLLBACK : Rollback changes to the beginning of the current transaction, then
exit.
NO_ROLLBACK :Exit without rolling back any changes. This values for rollback
mode is not supported in Clear_Form.
Example: Leave the called form, without rolling back the posted changes so they may be
posted and committed by the calling form as part of the same transaction.
BEGIN
Post;
/* Form_Status should be ‘QUERY’ if all records were successfully posted. */
IF :Systen.Form_Status <> “QUERY’ THEN
Message (‘An error prevented the system from posting changes’);
RAISE Form_Trigger_Failure;
END IF;
/* By default, Exit_Form asks to commit and performs a rollback to savepoint.
We’ve already posted, so we do not need to commit, and we don’t want the
posted change to be rolled back. */
Exit_Form(NO_COMMIT, NO_ROLLBACK);
END;
11.6 Parameters
When invoking a new module from an existing form, you may need to pass values from
the current environment to the new one. One way could be global variables, global
Variables are visible across all modules. If you need to initialize some values upon new
D2K For ms Builder
form’s startup, you can pass these values using parameter lists.
Within one module, variables can have local and global scope. Scope and visibility of
local variables does not extend beyond the program unit in which they are defined. The
global variables are visible throughout all active modules and accessible from all their
objects. Parameters implement different visibility and accessibility of certain data items
across the boundaries of the module. They are objects that are you used to pass data
between modules e.g. when a form calls another form or between products e.g. When an
Oracle Reports is executed from inside Form Builder.
A Form Parameter is an object that belongs to a Form. To Create one, Select the
Parameter node in the Object Navigator, and choose Create tool. In the property palette of
the parameter, set the desired values for name, datatype, maximum length, default value
and comment. You will be creating these parameters in the called form and these
parameters will receive the values from the parent form.
To reference these parameters or to access the value contained in the parameter in the
called form you prefix the name with “:PARAMETER” and a dot separator.
e.g.
If you have created a parameter with name ‘dno’ and want to assign its value to a variable
D2K For ms Builder
For e.g. to use the parameter Currec_attr to set the form parameter in a when-New-Form-
Instance trigger you would refer to :PARAMETER.Currec_attr.
Declare
V_Form_Id FormModule;
BEGIN
V_For,_Id := Find_Form (: System.Current_Form);
Set_Form_Property(V_Form_Id, Current_Record_Attribute,
: PARAMETER.CURREC_ATTR);
END;
11.6.3 Using parameter lists to pass values from one form to another
Parameter are passed to called forms by means of a parameter list. Parameter lists are
created programmatically and are used to hold parameter names and their values. They
are internal three column constructs that contain the parameter names, the type of
parameter and it’s value. Parameter names are called keys.
The parameters whose values are being passed must have been defined in the called form
at design time. That is, the called form must be expecting a value for each of the
parameters included in the parameter list it receives from the calling form. In short, create
the parameter list in the calling form and the parameters at design time in the called form.
TEXT_PARAMETER
When a parameter is defined of type TEXT_PARAMETER, then character values (string
of 255 values) can be passed to the other form or Oracle products.
DATA_PARAMETER
When you specify a parameter of type DATA_PARAMETER, you have to pass the name
of record group defined in the parent form. You can use data parameters to pass data
when you use run_product built-in to pass data to other product and not to pass data
within forms.
11.7 Built-ins
CREATE_PARAMETER_LIST
Syntax
CREATE_PARAMETER_LIST (name);
Creates parameter list with the given name
ADD_PARAMETER
Syntax
ADD_PARAMETER(list key, parameter type, value);
List:
Specifies parameter list to which parameter is attached.
Key:
Name of the parameter.
Parameter type:
Either text or data type parameter.
value
actual value
GET_PARAMETER_LIST
Syntax
GET_PARAMETER_LIST(name);
Returns a parameter list ID when it finds a valid parameter list with the given name.
e.g.
To create a parameter list and pass it as a parameter to the called form by using
Open_form built-in.
Declare
P1_id paramlist;
Begin
/* ‘param is the name of the parameter list */
p1_id := get_parameter_list (‘param’);
/* If a list with name ‘param’ already exists the destroy the lsit */
if not id_null(p1_id) then
destroy_parameter_list(p1_id);
End If;
P1_id := Create_parameter_lst(‘param’);
D2K For ms Builder
open_form(‘form2’, ACTIVATE,NO_SESSION,p1_id);
END;
The keys in the parameter list should have same names as that of the parameters defined
in the called form.
D2K For ms Builder
12 Libraries
A library is collection of objects. These objects can be PL/SQL program units like
functions and procedures or Form objects like alerts, editors, push buttons etc. Based on
the type of objects stored in the library Form Builder provides us two types of Library
modules.
Ø PL/SQL Libraries
Ø Object Libraries
There are three PL/SQL library file formats, .PLL, .PLX, and .PLD
.PLL : The library .PLL file contains both library source code and the compiled,
executable code. The >PLL file is created or updated when you save your library
module. When you save your library module, the changes are reflected in each
module to which the library is attached.
.PLX : The library .PLX file is a platform-specific executable that contains no source.
You can generate a .PLX file from the Designer or from the command line.
When you attach a library to a module in the Designer, you attach the .PLL
version of the library. At runtime, Form Builder looks for a .PLX file by that
name in the default a search path. If no .PPLX file is present, Form Builder looks
for the .PLL file by that name.
.PLD : The >PLD file is a text format file, and can be used for source-controlling you
library files.
D2K For ms Builder
1. Select File -> New -> Library to open a new library module in the designer
OR
Select the Libraries node and then choose Navigator -> Create
2. To create a program unit, expand the desired library node, select the Program Units
node, and then choose Navigator -> Create
The New Program Unit dialog appears
3. Specify the program unit Name and its Type (Procedure, Function, Package Spec, or
Package Body). Choose OK.
The PL/SQL Editor appears. Write PL/SQL c ode into it and compile it.
4. Save the library to file or database.
Once you create a library, you can attach it to any other form, menu, or library module.
Then, you can call library program units from triggers, menu item commands, and user-
named routines you write in the modules to which you have attached the library.
Libraries can also be attached to other libraries. When a library attaches another library,
program units in the first library can reference program units in the attached library.
2. Double Click on this node or select Navigator -> Create to get an Attach Library
dialog.
3. Enter the name of the library to be attached or search the name by clicking on FIND
4. Click on Attach button and the library gets attached to the current module. Once
library is attached, you can successfully compile form triggers and procedures that
reference the library program units.
When Form Builder encounters a call to a program unit, it first looks for the program unit
in the current module, then searches the attached libraries.
If you have attached a library to your module, you will not be able to view the code of the
program units it contains from the Attached Libraries node in the Navigator. To edit or
view library program units, you must open the library module itself.
When you edit a library, your modifications are not reflected in any modules that the
library is attached to, until you save your changes.
1. In the Navigator, open the library module and then add, edit or remove program
units from the library as desired.
2. Save the library module
D2K For ms Builder
The changes are reflected in each module to which the library is attached.
Library modules being separate module are compiled independently of forms and menus.
As a result, you cannot refer directly to form bind variables (the values of form items,
system and global variables, and parameters) in a library program unit i.e. you cannot
refer directly to the following variables:
1. :block_name.item_name
2. :GLOBAL.variable_name
3. :SYSTEM.variable_name
4. :PARAMETER.parameter_name
Hence, we have to use the NAME_IN built-in to refer to the values of bind variables.
You can say Name_In(‘block_name.item_name’) to get the name of the item.
To set the values of bind variables we have to use the COPY built-in.
For example to set the value of item empno from EMP block to 7999 we can use Copy in
the following manner:
Copy(‘7999’, emp.empno’);
When COPY is used to set the value of a form item in a library routine, that item is
marked as CHANGED. This behavior can affect subsequent validation and comit
processing.
Whenever possible, you should write library program units that rely on IN and IN OUT
parameters for passing data between the form or menu module and the library. You can
also use functions with return values for this purpose. When you call a library procedure
that uses parameters, you can pass bind variable references as actual parameters, as
shown here:
My_library_procedure(:form_block.form_item,:System.Cursor_Block);
The Object Library provides an easy method of reusing objects and enforcing standards.
With the help of Object Libraries we can make use of powerful, object-oriented features
D2K For ms Builder
to improve produc tivity through object reuse we can rapidly create applications by
dragging and dropping predefined objects to your form.
You can create template forms, reports, or charts for enforcing standards and rapidly
develop applications. Whenever a new document is created using a template, all the
objects in the template (e.g. standard toolbars, standard layout, and standard libraries etc.)
are automatically included.
Library modules are stored in binary format. They can be saved to files or to the database,
and are portable across platforms. When you compile a binary module, Form Builder
creates a platform-specific runfile. You can also use the Forms Compiler to create a
human-readable text file that is portable across platforms. In case of Object Libraries we
have the following file formats:
The Object Library consists of tabs. You can add objects to these tabs. You can arrange
the objects in such a wa y that similar types of objects exits on the same tab page. This
will clear after you understand how to create the Object Library,
To add Objects
Drag the object to be added and drop it into the desired tab page.
D2K For ms Builder
The above figure shows that an object named Comment_Editor has been added to the
Object Library. The Comment_Editor is a user defined editor and can be used in different
forms where it is required to attach such an editor to an item. Thus what we have done is
that we have created an object in the form module and then included it in the Object
Library by dragging it.
To reuse the Objects in the Object Library, it will be required that the object created in
the Form module should simple inherit the properties from the parent objects. These
parent objects are nothing but the standard objects saved in the Object Library. Inheriting
the properties from the parent class essentially means that you have to subclass the object
created in the Form module. This subclassing can be done in different ways.
To include this object in any other Form module, first save the Library and then simply
drag the object from the Object Library and drop it under the relevant node. Forms
Builder will show you the Subclass-Copy-Cancel screen. You can subclass or copy the
object as desired.
One more method of subclassing (deriving) an object from the objects stored in Object
Library is that you can create the object and then double-click on the subclass
D2K For ms Builder
information property in Property Palette to see the Subclass information dialog. Select the
object included in the Object Library, in order to subclass your current object from the
already created object. Here the object that you have created in your Form module is the
derived class as you are deriving its properties from some other class. This other class or
the parent class is the standard object stored in the Object Library.
12.2.4 SmartClasses
Object Libraries feature Smart Classes are the objects that you define as being standard.
They can be used to convert objects to standard objects. In other words, we can say that
Object libraries can be used to specify the classes that are frequently used as the basis of
other objects in forms. If you mark an object in the library as standard class, whenever
developers create a new object of that type, they can quickly pick from a context-
sensitive list of standard classes know as Smart Classes.
As seen from the figure 4, the object for which a smartclass is created is tick marked. To
add comment to the objects in the Library Tabs choose Object -> Edit Comment from the
menu. Type the desired text in the Comment dialog.
To create an object (in the Form module) based on this SmartClass you can drag the
object into the Form module under the desired node.
If you have to apply the SmartClass to an already existing object, then highlight the
object to be based on the SmartClass and right click to display the popup menu. Click on
the SmartClass option. This is shown in figure below. Whenever you apply a SmartClass
to an object, the object is automatically subclassed.
D2K For ms Builder
In order to modify a smartclass object drag the object from Object Library to the form
module under the appropriate node, make changes to the object and shift + drag the
object back to the Object Library. The following Dialog box is displayed.
Click on Yes to replace the existing object by the modified object. In order to reflect the
changes made to the parent SmartClass in every child instance of the SmartClass perform
the following steps:
Ø After subclassing from the parent object (the object included in the Object
Library), now if you modify the object as explained earlier then the links between
the parent and the child objects are maintained.
The Link is maintained between the parent and child object only if you have subclassed
the child object through the Subclass Information property in the pr operty palette.
12.3 SmartTriggers
SmartTriggers are the triggers that appear in the popup menu (displayed by RightClicking
on the object) of the object. Clicking on the SmartTriggers option in the popup menu
gives you a list of most frequently used triggers for that type of item. These are the
triggers that are the most probable triggers for the item types. Say for textitems, triggers
like When-Validate-Item, Pre-Text-Item, Post-Text-Item and When-New-Item-Instance
are the most probable triggers. If the item type is List Item then along with When-
Validate-Item and When-New-Item-Instance the When-List-Changed triggers appear in
the popup. Note that Form Builder does not generate any code for these triggers. You
have to add the code to these triggers in the PL/SQL editor.
D2K For ms Builder
13 Menus
13.1 Introduction
A menu is a hierarchical structure that provides a quick and convenient way to run the
Forms application. You can run your forms using Default menu or customized menu or
without using any menu.
The Default menu is part of every form, and is used automatically if you do not specify
otherwise. In order to use the default menu for a particular form module, invoke the Form
Module property sheet. Type DEFAULT in the menu module property field. Choose OK
to accept the property palette. You cannot change the structure of the default menu.
We will concentrate on the menu component of the menu module. Each menu module
contains one or more menus. Each menu contains one or more menu items.
Just as you work with form modules in the Navigator and the Layout Editor, you work
with menu modules in the Navigator and the Menu Editor. The Navigator and the Menu
Editor synchronize when you select a menu or menu item. For example, if your select an
item in the Menu Editor, that item is selected in the Navigator as well, even if it requires
expanding a node or a menu.
You can display multiple menu modules at the same time in separate Menu Editor
windows. With one Menu Editor window open, select another menu module in the
Navigator, then choose Tools -> Menu Editor. This graphical editor can be used to create
individual menus and add items to menus. The property sheet of the each item allows you
to define special type of menu items and assign commands to menu items.
In order to access the menu editor, at least one menu module must be open in Object
Navigator.
While learning how to create a menu we will create the following menu. Your menu
hierarchy should be as shown:
1. Create menu by selecting the menus node (the menu component within the menu
module). Oracle Forms create a menu named MAIN_MENU having a menu item
with name ITEM1 and <New Item> by de fault. To work in outline style use the
object navigator. To work in graphic style use the menu editor. We will be working in
the menu editor.
2. Type a menu label to replace the default label.
3. To add new items choose Menu -> Create Right or click Create Right icon. The Menu
Editor create a menu item <New Item> and selects it so you can edit the label.
Once the main menu is complete, you are ready to create the individual menus, which
means adding menu items to the menu. For each parent item on the main menu you can
create a list of related child menu items in the following manner.
Ø Your individual menu for example Action menu will look like this.
D2K For ms Builder
You will notice that when you add the first menu item, Oracle Forms places a shaded
rectangle or handle to the left of the first item, such as Action. The handle lets you move
all the items on the menu as a unit or display the Menu level properties in the Properties
window.
Menu items can call submenus, which are displayed to the right of the item.
To create a submenu:
Create a submenu for the menu item Master and add two items to this submenu. Name
these items as Employee and Department. We will be using these items to run our
Employee and Department master forms.
Ø Click Create Down icon from the tool bar, to Create Item (Clear All) under the Action
menu.
Ø Click Create Down icon from the tool bar, to Create Item (Save) under the Action
menu
Ø Click Create Down icon from the tool bar, to Create Item (Exit) under the Action
menu.
D2K For ms Builder
Ø To create items under the Forms menu. Select Action by clicking on Action menu
Ø Now click Select Right Icon from the toolbar. <New_Item> is created type Forms
Ø Click Create Down icon from the toolba r to create Item (Master) under the Forms
Menu
Ø There is a sub menu (Employee & Department item) under the Master Item click
create right icon from the toolbar (make sure the currently selected menu is Master)
type Employee under the Master Menu
Ø With Employee menu item being the currently selected menu item click Create Down
icon on the toolbar type Department.
Ø Select the Forms menu, click Create Right icon on the toolbar a <New_Item> is
created type Edit.
Ø The Edit menu is created, create menu items for Edit menu Click Create Down icon
from the toolbar. In <New_Item> type Cut. Click Create Down icon from toolbar
Type Copy Click Create down icon type Paste
Ø Follow the same steps for the Query Menu too
Figure 13-6: The Complete Main Menu as seen in the Menu Editor
D2K For ms Builder
Figure 13-7: The Complete Main Menu as seen on the Object Navigator
If the object you want to navigate is visible, clicking on it moves the builder’s focus on
the object and selects it. To select a menu item click inside the rectangle that represents it.
You will notice that when you add the first menu item, Oracle Forms places a shaded
rectangle or handle to the left of the first item. The handle lets you move all the items on
the menu as a unit or display the Menu level properties in the Properties window.
D2K For ms Builder
To select a menu, click the menu handle to its left. E.g. when you Click the handle on the
left of the Clear_All item the Action_menu menu is selected in the object navigator.
You can customize your menu using different item types. In addition to plain menu items
Forms has provided us with four types of special menu items Check, Radio, Separator
and Magic. The type determines how the item is displayed and whether the item can have
an associated command.
To assign a command to a menu item, invoke the property palette for the menu item and
enter the command Type and the command text property.
Ø Menu items
Ø Subprograms (user-named routines)
Ø Start-up code
You can use PL/SQL code in menu items by defining the item command type as PL/SQL
and writing the code in command text. To assign a PL/SQL command to a menu item in
the Menu editor, select the menu item, set the Command type property to PL/SQL, enter
the code and choose compile.
PL/SQL menu items commands are similar to form triggers. In addition to standard
application functions such as navigation, validation and database interaction, you can use
PL/SQL commands to do the following actions.
D2K For ms Builder
Action Comments
Invoke a form A menu item with PL/SQL command tyoe can
invoke a new form in the same session by calling
the OPEN_FORM, CALL_FORM or the
NEW_FORM built-in procedures
Execute operating system commands To execute operating system commands from a
PL/SQL item call the HOST built-in. parameters
to the built -in specify the operating system
command to execute.
Invoke another Oracle Tool You can all the RUN_PRODUCT built -in to
invoke different Oracle Products like Oracle
Forms Runform, Oracle Reports or Oracle
Graphics.
Call the DO_KEY built -in To execute the key trigger that corresponds to
the specified built-in routine.
Call EXECUTE_TRIGGER built-in Unlike PL/SQL menu items, a user-defined
trigger defined in the form module can directly
refer to the values of the form items. If you want
to write a user-named routine or anonymous
block that uses direct references, you can place it
in a user-named trigger and then call that trigger
from a PL/SQL menu item command with this
built-in.
Pop-Up Menu is a floating menu that pops up when you click the right mouse button on a
canvas or item. They let the user quickly fire off some action relevant to the location of
the mouse in the application.
Right Click on the Popup Menu Select the Menu Editor. In the Menu Editor Create the
following menu.
To make this popup menu available when the user right clicks either in the canvas or on
an item:
Ø Select the property palette of Canvas
Ø From the property Popup Menu pull-down select the desired popup name.
Ø In the RunForm Right Click anywhere in the Canvas to display the popup menu.
D2K For ms Builder
13.9 Toolbars
Toolbars is a standard feature in GUI applications. They group together iconic buttons
and help users access functionality that is used frequently.
Developers must provide icons to associate with each menu item that appears in a Menu
Bar.
In the Menu Property Palette, the Property Visible in Horizontal Menu Tool Bar specifies
whether the menu item should appear (represented by an icon) on the horizontal or
vertical menu toolbar (or both) of a form. The Property Icon in Menu specifies whether
the Icon should appear in the pulldown menu item.
13.9.1 SubPrograms
Menu startup code executes when a menu is loaded into the memory at form startup or as
a result of call to the CALL_FORM, NEW_FORM, or REPLACE_MENU built-in
procedures. Startup code can be used to perform the following tasks.
To write the startup code for menu, select the desired menu module in the Menu Editor or
Object Navigator Invoke the properties window and fill in the Startup Code field or
double-click the Startup Code field to invoke the PL/SQL Editor. Writing startup code is
similar to writing a trigger, and startup code can include anonymous blocks and calls to
built-in subprograms.
To write a startup code, Select Menu Module to invoke the property palette, choose
Startup Code to invoke the PL/SQL editor. Enter and compile the PL/SQL code to be
executed at startup of menu.
e.g.
To disable the menu when the form starts; the menu should be enabled only after
confirming if the user is allowed access to the menu.
Syntax
Ø GET_MENU_ITEM_PROPERTY(menu_name.menuitem_name VARCHAR2
property NUMBER);
Ø SET_MENU_ITEM_PROPERTY(menu_name.menuitem_ name VARCHAR2
D2K For ms Builder
Set_Menu_Item_Property(“ACTION_MENU.SAVE’,ENABLED,
PROPERTY_FALSE):
To Enable this item after checking the password, assume a form which accepts username
and password. If password is correct then the Save option should be available to the user.
To do this write the following code in the appropriate trigger:
Set_Menu_Item_Property(“ACTION_MENU.SAVE’,ENABLED,
PROPERTY_TRUE):
e.g.
Code the following
If Name_In (‘Emp.Ename’) = ‘Adams’ Then
Statements…
Else
Statements…
End if;
In the Menu Module property palette, set the Main Menu property to indicate the name of
the main menu. This tells Form Builder, which individual menu is the main menu in the
module Operators cannot navigate above the level of the main menu. In the Main field of
Menu property sheet enter the name of the main menu in the module. The default for this
property is the name of the module itself, however, the main menu is not required to have
the same name as the module.
Before you can run a custom menu with a form you must:
Ø Generate the menu module to create a runtime menu file. With the Menu the
current node Click File -> Administration -> Compile File or use shortcut Ctrl + T
Ø Attach the menu to a form
D2K For ms Builder
In the Form Property Palette the Menu Source property when attaching a menu to a form,
there are two ways to specify the location of the runtime menu file: direct reference or
database lookup. To refer to the .MMX file directly
1. Open the Property palette of the Form module to which the menu is to be
attached.
2. In the menu name property, simply enter the path and filename of the menu
runfile.
At form startup, Oracle Forms automatically loads the specified .MMX file. If the menu
design module is stored in the database, and if the form will be connected to that database
at runtime, you can attach a menu to a form through database lookup.
1. Set the Menu FileName and Menu Directory properties to specify the location of
D2K For ms Builder
A mnemonic character is a special character in menu item name that operators can use
with a function key to select the menu item, without having to use the mouse. To define
the mnemonic character for a menu item, enter the ampersand (&) in from of the
character in the main menu item name.
A keyboard accelerator is a function key or key sequence that operator can press to
execute the menu item command. Oracle Forms provides five logical accelerator keys
that you can assign to menu items, named [ACCELERATOR1] through
[ACCELERATOR5]. To assign accelerator keys to a menu item, select menu item in the
menu editor, type the logical accelerator key you want to assign to the item in the
Accelerator property field. Associate logical key to a physical device key or key
sequence.
D2K For ms Builder
14 Product Integration
14.1 Introduction
Product integration as the name suggests explains how to integrate different Oracle
Products namely Form Builder 5.0, Report Builder 3.0 and Graphics Builder 3.0.
Integrated applications improve end-user productivity by providing combined access to
multiple special-purpose tools.
The primary way to integrate Form Builder with other tools is to write an appropriate
form trigger to invoke another tool in response to some event. When Form Builder
invokes another product, it can also pass parameters to the other product.
Run_Product is a built-in that helps you to invoke other products from Form Builder with
the RUN_PRODUCT built-in procedure. By default, when you invoke Report Builder or
Graphics Builder with RUN_PRODUCT, the called product logs on to ORACLE using
the current form operator’s USERID. The syntax for RUN_PRODUCT is shown here:
Syntax
RUN_PRODUCT(product, document, com-mode, exec-mode, location, list, display);
Form Builder uses the parameters you pass to RUN_PRODUCT to construct a valid
command line invocation of the called product. RUN_PRODUCT takes the following
parameters:
Product : A numeric constant that specifies the Oracle tool to be invoked: FORMS,
REPORTS, GRAPHICS, or BOOK.
Com-mode : Specifies the communication mode to be used when running the called
product. Valid numeric constants for this parameter are SYNCHRONOUS
and ASYNCHRONOUS.
SYNCHRONOUS
Specifies that control returns to Form Builder only after the called product
has been exited. The operator cannot work in the form while the called
product is running. Synchr onous is required when passing a record group
to a called product as a DATA_PARAMETER; for example, when
invoking Graphics Builder to return an Graphics Builder display that will
D2K For ms Builder
Location : Specifies the location of the document or module you want the called
product to execute, either the file system or the database.
Display : Specifies the name of the Form Builder chart item that will contain the
display generated by Graphics Builder.
Example 1
Say you have to display a report that displays customer-wise orders. To run this report
through your menu write the following code in the menu item code.
Example 2
Let us create a form and use it to run a report as well as graphics. The report shows
region wise sales for the given month. The graphical display shows the same in the
graphical manner. (You will be creating this report and the graphical display in due
course. In this example we will see how to integrate these three products)
declare
p1_id paramlist;
Begin
PL_ID := GET_PARAMETER_LIST(‘param’);
If not id_null (p1_id) then
Destroy_parameter_list (p1_id);
End if;
P1_id := create_parameter_list(‘param’);
Add_parameter(p1_id, ‘mon’, text_parameter, :ctl.month);
Run_product (REPORTS, ‘reg_sales’, ASYNCHRONOUS, RNTIME,
FILESYSTEM, PL_ID, NULL);
END;
declare
p1_id paramlist;
Begin
PL_ID := GET_PARAMETER_LIST(‘plist’);
If not id_null (p1_id) then
Destroy_parameter_list (p1_id);
End if;
P1_id := create_parameter_list(‘plist’);
Add_parameter(p1_id, ‘mon’, text_parameter, :ctl.month);
Run_product (GRAPHICS, ‘reg_sales’, ASYNCHRONOUS, RNTIME,
FILESYSTEM, PL_ID, NULL);
END;
6. To execute this form without errors, remember to create parameters in the report
and graph with name as ‘Mon’ of type character.
7. The Query for the report and graph should be as follows:
Select Region, Sum(Total) From Ord, Customer Where To_Char (Orderdate, ‘Mon’) =
:Mon Group by Region
You can use Reports wizard and chart Wizard from within Form Builder. To work in
Reports Wizard highlight the Reports node in the Object Navigator and click on the
Create ‘+’ icon in the toolbar. The following New Report dialog is displayed.
D2K For ms Builder
Thus you can enter the name of an existing report or specify the name of a new report
file. In case you want to create a new report object to be based on the block in you tick
the Base Report on Block checkbox. Click on OK button. Forms Builder takes you to
Report Builder Report Wizard. In case your report is not based on any block, enter the
query in the Data page of Report Wizard. Once you are inside the reports Builder you
can view the report as desired. Thus you can create a report object via Forms.
You can open the Property Palette of the report object and set the execution mode and
communication mode properties under the Dev/2000 Integration node. You can run a
report using the Run_Report_Object built-in subprogram. This built-in returns a varchar2
value.
Chart Wizard is available in the Layout editor. When you work in the Chart Wizard it
creates a chart and the Chart item in the specified block.
In the Property Palette of the Chart item you will find that there is a new node Dev/2000
Integration node. With the help of properties under this node you can specify whether
you want to run the ogd file in Batch/Runtime execution mode. Synchronous /
Asynchronous communication mode. These are the same as explained earlier. You can
also specify the data source or the block name, the data from which the chart will be
drawn. The Property Palette for the Chart item is as shown.
D2K For ms Builder
15.1.1 ActiveX
ActiveX is composed of a group of technologies or components to develop and
implement applications for Internet. An ActiveX control is not a type of VBX. Vbx
controls function strictly under 16-bit applications, they do not function under 32-bit
environment. It is recommended to use ActiveX controls and OLE Servers developed and
distributed by third parties.
Form Builder provides support for ActiveX controls. ActiveX controls are reusable
components that can be embedded in your Form Builder Application. Form Builder acts
as an ActiveX control container. Each ActiveX control exposes a set of properties,
methods, and events. Properties define the ActiveX control’s physical and logical
attributes, methods define actions that the ActiveX control can perform, and events
denote some change in status in the ActiveX control. A client application manipulates an
ActiveX control by writing values to and obtaining values from its properties, invoking
methods that are used to get and set properties, and intercepting and acting on events.
OLE is not an application development environment. It is an architecture that integrates
software services.
OLE means Object Linking and Embedding and it refers to the technology of working
with compound documents. Compound documents link or embed one or more documents
together solving the problem of integrating different object types in a single document.
For instance, a compound document can be a Form module document that contains
objects from other applications such as word processor documents or spreadsheet
documents.
D2K For ms Builder
Applications that support OLE can be OLE Servers, OLE containers or both. An OLE
Server application creates OLE objects that are embedded or linked in the OLE
Containers. Examples of OLE Servers are MS-Word, MS-Excel. OLE Container
applications do not create documents for linking or embedding. For example Form
Builder is a OLE Container application. The OLE Container control allows you to add
insertable objects and call OLE Server in your Forms application. ActiveX controls
originally known as OLE controls or OCX’s make use of both ActiveX and OLE
technology. Extending the compound document solution to extend scope of sharing
services, the Component Object Model (COM) was introduced as OLLE2. ActiveX
includes the OLE implementation of COM and improves on it by extending its
capabilities to take advantage of Internet. This is something, which OLE did not have.
COM is a Microsoft model for building objects. It is a general architecture that lays the
foundation on which OLE version 2.0 is based. It establishes a common model for
interaction among software. Therefore Com can be implemented with any software.
Word processor documents, spreadsheet documents, know controls and video clips are
examples of component objects that can enhance the capabilities of your form. Instead of
recreating functionality that already exists, you can access these capabilities by exploiting
the ActiveX and OLE support in Form Builder. Component objects provide speciality
services not available in Form Builder, thereby enhancing the client application.
Steps:
To create a single-record bloc, set the Records Displayed block property to 1, or set the
Number of Items Displayed property (for the ActiveX control container) to 1.
3. Double-click the object icon nect to the newly created item to display the Property
D2K For ms Builder
Palette.
4. Under the General node, set the Item Type property to ActiveX Control.
5. Under the Physical node, set the Canvas property to the name of the desired
canvas.
To display an item at runtime, you must assign it to a canvas.
6. Insert an ActiveX control
For ActiveX controls that interact directly with the data from a record, it is best to
insert ActiveX controls in a single-record blocks.
Steps:
1. In the La yout Editor, select the ActiveX control containers then click the right
mouse button to display the popup menu.
2. Choose Insert Object to display the Insert Object dialog.
3. Choose the desired control, then click OK.
4. In the Layout Editor double -click the ActiveX control container to display the
Property Palette
5. Under the Functional node:
Ø Set the OLE Class property each OLE Class contains a number of
controls.
Ø Set the desired control and container properties
1. Choose Program -> OLE Importer Menu Item to display the OLE Importer
dialog.
2. Select the desired OLE Class, then select the desired OLE methods and events.
3. Click OK
4. Form Builder displays the imported methods under the Program Units node in the
Object Navigator. You can access these OLE methods from your application by
using the STANDARD and OLE2 built-in packages.
Write the appropriate PL/SQL code to interact with the ActiveX control
The Calendar control displays a monthly calendar that you can insert in a form. Control
file Name is <SCAL.ocx.
The Calendar control supports properties that you can use to set and retrieve the date and
to control the appearance of the calendar. It supports methods that you can use to set the
day, month, and year, to show an about box, and to refresh the calendar. It also supports
events that notify your application when the user has moved to a new date on the
calendar, when the user has clicked or double-clicked on a date, and when the user has
pressed a key.
At runtime when you execute the query, at that time data will be fetched and when you
click on the ‘…’ button the calendar will be displayed.
D2K For ms Builder
User can select any date along with the month and year. User can place the selected date
in the ‘Hiredate’ field.
D2K For ms Builder
Steps
1. Create the new form.
2. Create the ‘EMP’ block.
3. Keep the layout style as ‘Form’
4. Select Empno, Ename, Job and Hiredate columns from the EMP table.
5. Change the name for the EMP canvas to EMP_CAN.
6. Create a push button named as ‘…’ and set its general properties
D2K For ms Builder
12. Place the CTL block on the ‘CTL_CAN’ and EMP block on EMP_CAN
13. Keep the CTL_CAN canvas active to place OCX control.
14. Click on the ‘OCX’ tool and draw a rectangular box.
15. Click the right mouse button to display the popup menu
D2K For ms Builder
16. Select the ‘Insert Object’ option from the menu. It displays the insert object dialog
box.
23. To import the methods and events of the Calendar control, select the Program -> OLE
importer from the layout editor window’s menu.
D2K For ms Builder
24. Form Builder shows the OLE libraries interfaces along with the classes and events
and methods as shown below.
25. Select the ‘Mscal.calendar/7’ OLE class and select its events and methods, which will
be seen in the methods and events boxes.
The moment you select the methods and events, in the object navigator all the related
program units get created.
D2K For ms Builder
26. Go to the Object Navigator and expand your ‘+ Program Unit’ node. Check out the
packages and it’s related procedures and functions. In this form we will call those
readymade procedures and functions through the ‘Select Date’ push button.
27. Go to the ‘CTL_CAN’ canvas and select the ‘Select Date’ button and write when-
button-pressed triggrer as shown below:
Example 1
/*Getting an ActiveX control property using accessor*/
tblname varchar2;
tblname := table_pkg.TableName(:item(‘Oblk.Oitm’) .interface);
For e.g.
DATE_DAY:= mscal_icalendar.day(:item ‘ctl.acti’).interface);
Mscal_icalendar is the name of the program unit created from the OLE Importer.
DATE_DAY is the name of the property accessor.
CTL is the name of the block and acti is the name of the item
D2K For ms Builder
Example 2
:item(ActXitem’).OCX.Spindial.spindialctrl.1.Needleposition :=
:item(ActXitem’).OCX.Spindial.spindialctrl.1.Needleposition + 1;
ActXItem is the name of the item, Spindial.spindialctrl.1 is the name of the ActiveX
control server, and Needleposition is the name of the property.
:form.cursor_item.OCX.spindial.spindialctrl.1.Need1position :=
:form.cursor_item.OCX.spindial.spindialctrl.1.Need1position + 1;
You can activate an OLE object from a Form Builder OLE Container with in-place
activation or external activation. Activating an OLE object allows you to have access to
features from the OLE Server application that originated the OLE object. In-place
activation and external activation are possible only if the OLE Server application that
originated the OLE object is accessible by your computer. Both in-place activation and
external activation also depend on the OLE activation property settings of the OLE
Container. The OLE activation property settings are specified in Form Builder. If the
OLE Server application is accessible, the activation property settings of the OLE
Container determine whether in-place activation or external activation occurs when an
embedded OLE object is activated. Linked objects can only be activated with external
activation; in-place activation does not apply to linked objects, even if the in -place
activation property is set to yes. Activation of an OLE object is possible in Form Builder
and during Forms Runtime.
In-place Activation
In-place activation occurs when an OLE Container and its embedded object remain in
place when activated, Form Builder remains surrounding the OLE Container. In-place
activation is available for embedded objects, but it is not available for linked objects.
External Activation
External activation occurs when an OLE object appears in a separate window that is
opened by an object’s originating OLE Server application. Because an OLE Server
D2K For ms Builder
application starts up with its own windows, Form Builder menu options and toolbars
remain intact during external activation. External activation is available for both
embedded and linked objects. When a OLE object is activated, the object’s originating
OLE Server application is launched, and the OLE object appears in a separate OLE
Server application window. The separate window has the menu options and toolbars of
the OLE Server application. When the contents of a linked source file is modified with
external activation, a linked object can be updated manually or automatically. Manual
updates require an explicit instruction for an object to reflect changes from a linked
source file. Automatic updates occur as soon as you modify a linked source file.
The object that needs to be included in more than one document, so that changes affect
multiple form modules and other documents. The source document can always be
accessed if the object is lined. The form module size is a concern: Linking, unlike
embedding, does not increase the size of the form module by the size of the object.
D2K For ms Builder
Table of Figures
Table of Contents
An invoice is a bill, which is send to the customer after the goods have been dispatched.
In most of the business concerns the items sold re on credit. When the customer receives
an invoice against the goods received by him, he verifies the amount on the invoice and if
the invoice is valid, he makes the payment.
The invoice is prepared on the computer and a printout of the invoice (3 copies) is taken.
Once copy of the invoice is send to the customer, second copy is send to the accounts
department and the third copy is retained by the invoicing department.
When the customer receives an invoice, he makes a payment to the accounts department.
An outstanding amount is the amount, which the customer has not yet paid. The balance
filed in ‘CUSTOMER’ table represents this amount.
Creditlimit is that maximum amount till which the customer is allowed to purchase goods
on credit. The outstanding balance should not exceed the Creditlimit.
The company has a sales department. The work of employees in sales department is to
implement marketing strategy and to convince the customers. They have to strike a deal.
They are given a specific target i.e. the number of customers. The status indicates the
target, which he has achieved.
The tables required for the above system have already been Normalized for you. The
validations for the data entry forms and the reports that are required to be generated have
also been specified.
Lab Assignments
2 FORMS
Solve the following based on the tables given below:
Tables
1. Salesmen Table
2. Customer Table
3. Product Table
4. Price Table
5. Ord Table
6. Item Table
The Forms, Reports and Graphics created by you in these assignments constitute a Sales
Order Processing Application. Your Final Application will look as follows:
Figure 11
Lab Assignments
Figure 12
2.1 Day - 1
1. Create a block based on Salesmen table using the Data Block Wizard with scroll
bars and integrity constraints. Explore the Runform menu. What does the option
Query -> Count Hits do? Are any triggers generated?
Lab Assignments
Figure 13
2. Create a form with a block based on Customer table so that your output looks as
shown below.
Ø Show the scroll bar
Ø Enforce integrity constraints
Ø Left align all the column text
Ø Give the proper description of column names at the time of block creation
Figure 14
Lab Assignments
2.2 Day – 2
1. Create a Master-Detail form using Salesmen and Customer tables. Enforce
integrity constraints. Change the properties of relation object and see how the
master-detail relationship works. Your output should be as follows:
Figure 15
2. Create a form using Customer table. Create a control block to contain the push
buttons. When you click on Execute button, it should execute the query for the
custid entered in the field. If no custid is entered, it should give you a message
indicating that you have to enter custid. Write appropriate code in the Save,
Cancel and Quit buttons
Figure 16
3. Create a form having multi-record based on Customer table and a control block.
The output is as shown below. The control block should have a radiogroup and a
check box in addition to other items. As soon as you click on any of the radio
buttons it should perform query in the sorting order ascending or descending
depending on whether the check box is checked or not.
Figure 17
Lab Assignments
2.3 Day - 3
1. Create a form as shown below based on the Customer table. As soon as a query is
performed the name of the salesman should be displayed in the display item
‘Representative’
Figure 18
2. Create a form as shown below based on the Customer table to add a new customer
performing all validations. Enforce integrity constraints. When you enter existing
custid and tab out, a message should be displayed indicating that the custid
already exists and the control should remain in the same field. The Comments
field should be multi-line and have a vertical scroll bar.
When you enforce integrity constraints, what are the triggers generated? What do
these triggers do?
Lab Assignments
Figure 19
As soon as you enter the product id and tab out then, if it exists in the database,
query should be executed to display the product description. The corresponding
records in the price table should be displayed and the control should move to the
new record in the Price block to enter the prices for a certain period.
If the Product if does not exist in the database then on tabbing out the control
should move to description field.
Lab Assignments
Figure 20
2.4 Day - 4
1. Create a form based on Customer table. Create an Lov named ‘Lov_Cust’ sorted
on Custid giving two columns Custid and Name. Create another Lov named
‘Lov_Name’ sorted on Name having two columns Custid ad Name. Create two
Push buttons with Labels ‘Custid’ and ‘Name’. When you click on ‘Custid’
button, ‘Lov_Cust’ should get attached to ‘Custid’ item. When you click on
‘Name’ button, ‘Lov_Name’ should get attached to ‘Custid’ item.
2. Create a form having block based on customer table and a control block.
Figure 21
Figure 22
Lab Assignments
Figure 23
2.5 Day - 5
1. Create a Master-Detail form based on Ord-Item tables to generate an order.
Implement the following in it:
Ø Create a display item to display the name of customer
Ø Attach an LOV to Custid field
Ø Complan and M_O_P (Mode of Payment) should be RadioGroups. Values
for Complan should be ‘A’, ‘B’ and ‘C’. Values for mode of payment are
‘1’ indicating Cash, ‘2’ Cheque and ‘3’ D/D.
Ø The itemid should be autogenerated and a non-navigable item
Ø Prodid should be a list item. Populate it with a runtime record group
Ø As soon as prodid is selected the corresponding actual price should be
displayed. This price should be such that it is the standard price of the
product for which the orderdate is between the Startdate and Enddate
Ø Put a check that Shipdate should be greater that Orderdate
Ø If the customer has not paid the amount, then his balance should be
credited by that amount in the customer table. (Use Post-Insert trigger)
Ø Use a general purpose Alert to display any messages
Ø The Total field is a display item that calculates the order total
Ø Same product should not appear more than once in a given order
Ø A running clock should be displayed at top right corner of the screen (not
shown in the figure below)
Figure 24
Lab Assignments
2. Create a vertical tool bar canvas. Attach it to a control block that has iconic push
buttons. Use the push buttons to form the tool bar and to perform operations like
add, delete, enter-query, execute query, cancel, save and exit the form. Create
another block based on the customer table and attach it to a content canvas. You
output should look as shown. For the iconic buttons make use of the .ico files in
<D2k Home>\TOOLS\DEVDEM20\BIN\ICON.
Figure 25
2.6 Day - 6
1. Create a multi-record form based on Salesmen table. Add two non-base table
items to that block that display the number of customers of each customer and the
total amount of the orders bagged by each salesman.
Implement the following:
In all you have to create four forms. The output is as shown below:
Figure 26
Figure 27
Lab Assignments
Figure 28
3. Create an object library. In this library include the iconic buttons and the
horizontal and vertical toolbar created in the assignment 2 of day 5. use the iconic
buttons created in different forms.
Lab Assignments
2.7 Day - 7
1. Created a menu as shown below and attach the forms that you have already been
created.
Figure 29
Figure 30
Lab Assignments
Figure 31
Steps:
3 Reports 3.0
3.1 Day - 8
1. Create a simple tabular report based on the ‘Customer’ table
Ø In the label page change the width of the following columns as follows:
1. Custid 4
2. Change the label for name column to ‘Customer’s Name’ and
specify width as 25
3. Address 15
4. Creditlimit 6
5. Balance 6
Figure 32
2. Create a break report based on the ‘Customer’ table. This report should display
the no. of customers for each sales representative and also should display the total
outstanding payments for all representatives. The output should be same as shown
below.
Lab Assignments
Figure 33
3. Create a simple Master/Detail report based on the Product and Price table. This
report displays the product details and its related price details. See the output
given below.
Lab Assignments
Figure 34
4. Create a Master/Detail report based on the ‘Orders’ and ‘Item’ table. Create two
queries based on these tables and join them by ‘Data Link Tool’
Ø There should be one formula column, which will calculate the tax by 0.4% per
order
Figure 35
5. Create a lexical parameter report. This report is based on the ‘ORD’ table in
which the order details will be displayed along with the name and addresses of the
customers by using placeholder columns. Create your own parameter form
window to accept the query condition. The output and the parameter window
should display as shown below.
Lab Assignments
Figure 36
Lab Assignments
Figure 37
3.2 Day - 9
1. Create bind parameter report. This report shows the orders, which is placed by
customer for the period of user-defined ‘from-date’ to ‘to-date’ parameters. See
the sample output given below.
Lab Assignments
Figure 38
Ø Create the parameter form window to accept the from date and to-date user-
parameters value
Lab Assignments
Figure 39
2. Sample Output displays the details of the customer in the form of Mailing Report,
which can be used to print the addresses of the customer.
Lab Assignments
Figure 40
3. Create an invoice report as shown below. In this report create the layout on oyur
own.
Hint:
Create three queries for (order, item and salesmen table) in the data model
window and create the layout objects in the layout editor by selecting frame,
repeating frame, filed and boilerplate text tool.
Lab Assignments
Figure 41
4. Create ‘Matrix with group style report’ to display the “Order Information for all
Customers” i.e. the orders placed by him along with the product description and
each item’s quantity. It should also show the total no. of orders placed by him and
the quantity of a particular item sold along with the grand total of all item sold.
The output should look same as shown below.
Lab Assignments
Figure 42
Lab Assignments
4 Graphics
4.1 Day - 10
1. Create a Pie chart that displays the number of customers of each representative.
When you click on the pie slice the columnar information of the customers and
the order amounts for that repid should be displayed. When you click on the given
column then order and the order totals of that particular customer should be
displayed.
Figure 43
Lab Assignments
Table of Figures
Figure 1............................................................................................................................214
Figure 2............................................................................................................................215
Figure 3............................................................................................................................216
Figure 4............................................................................................................................216
Figure 5............................................................................................................................217
Figure 6............................................................................................................................218
Figure 7............................................................................................................................218
Figure 8............................................................................................................................219
Figure 9............................................................................................................................220
Figure 10 ..........................................................................................................................221
Figure 11 ..........................................................................................................................222
Figure 12 ..........................................................................................................................222
Figure 13 ..........................................................................................................................223
Figure 14 ..........................................................................................................................224
Figure 15 ..........................................................................................................................225
Figure 16 ..........................................................................................................................226
Figure 17 ..........................................................................................................................226
Figure 18 ..........................................................................................................................227
Figure 19 ..........................................................................................................................228
Figure 20 ..........................................................................................................................228
Figure 21 ..........................................................................................................................229
Figure 22 ..........................................................................................................................230
Figure 23 ..........................................................................................................................231
Figure 24 ..........................................................................................................................232
Figure 25 ..........................................................................................................................233
Figure 26 ..........................................................................................................................234
Figure 27 ..........................................................................................................................235
Figure 28 ..........................................................................................................................236
Figure 29 ..........................................................................................................................237
Figure 30 ..........................................................................................................................238
Figure 31 ..........................................................................................................................239
Figure 32 ..........................................................................................................................240
Figure 33 ..........................................................................................................................241