Professional Documents
Culture Documents
10gforms 120425012532 Phpapp02 PDF
10gforms 120425012532 Phpapp02 PDF
Name
______________________________________
Batch :
______________________________________
Confidential
Copyright 2008
Second Edition
Email:
info@sqlstar.com
No part of this publication may be reproduced (incl. photocopying) in any way, without
prior agreement and written permission of SQL Star International Ltd., Hyderabad. SQL
Star International Ltd., Hyderabad assumes no responsibility for its use, nor for any
infringements of patents or other rights of third parties which could result.
Confidential
ii
Table of contents
10g FORMS
CHAPTER
No.
CHAPTER TITLE
PAGE
NO
1.
1 12
2.
13 25
3.
26 39
4.
40 65
5.
66 77
6.
78 100
7.
101-126
8.
127-142
9.
Triggers
143-167
10.
168-193
11.
194-213
12.
Navigation
214-228
13.
229-249
14.
Transaction Triggers
250-263
15.
Flexible Code
264-275
16.
276-292
17.
293-308
18.
309-340
19.
Managing Menus
341-372
Confidential
iii
Chapter 1
Introduction to
Oracle Forms Developer Suite
Objective
At the end of this chapter, you will be able to:
Confidential
Oracle Designer: This Oracle modelling tool helps to collect the business
requirement by giving support to SDLC process.
Website developers:
These developers are mainly those, who see Internet as the only media to work
with, in order to publish their information. Oracle has come up with Oracle portal
keeping these developers in mind.
MIS Developers:
Oracle business intelligent toolset has helped MIS developers to create reports
which help the management to make mission critical decisions. This toolset
also contains a product, which can be used by the end user to generate dayto-day reports.
Oracle business intelligent toolset comprises the following products, which
provides a whole range for reporting, analysis, and trending facilities:
Oracle Discoverer
Oracle Express
Confidential
Grid Computing
The database systems such as Relational, Hierarchical and Network have been
successful in developing the database for traditional business applications such as
Banking and Railway reservations. But, when it comes to more complex business
applications such as databases for scientific work, engineering designs,
telecommunications, geographic information system and multimedia, the
traditional database systems cannot handle them because the requirements and
characteristics of these applications are different from the traditional business
applications. These applications require more complex structures for:
Confidential
Oracle10g AS Architecture
Looking into the functional structure, this architecture can be divided into:
Confidential
Oracle10g AS Architecture
Oracle10g AS provides:
Facilities to redefine the business process and publish them into the
enterprise portal, which can be accessed from the internet or wireless
services.
Confidential
A Java enabled thin client tier, where the applications output is presented
by the interface to the user.
The middle tier is the application server or servers, where the application
logic and server software reside.
The database tier is the database server or servers, where enterprise data
is stored.
Forms Services consists of four major components: the Java client (Forms Client),
Oracle Jinitiator, the Forms Listener Servlet, and the Forms Runtime Engine. You
will learn about these components in chapter 2 - Running a Forms Developer
Application.
Process at the client end:
1) Oracle Jinitiator is downloaded on the very first request of the client. This
forms the surface for running the applications.
2) An applet is dynamically loaded into the client machine and cached.
Confidential
The Forms Listener Servlet and Forms Runtime Engine process on the middle tier
of Oracle10g As.
Confidential
Based on the toolset availability, Oracle10g developer suite can be divided into:
Confidential
Database forms and business logic can be created with minimum effort. Wizard
and
Built-in subprograms are responsible for quick development of application.
Application Partitioning:
PL/SQL program units can be created both in the back-end i.e. database server as
well as in the front on i.e. Oracle Forms. It is because of the separate PL/SQL
engine present in both the environments. When needed, this business logic can
be moved between the modules and Oracle10g database.
Flexible Source Control:
Oracle10g Software Configuration Manager (SCM) is integrated directly in Forms
Developer, used to keep a record of version changes, impact of renewed
configuration, parallel development and analyzing dependencies among objects.
Extended Scalability:
The multi-layered environment allows the product to be distributed among a wide
range of users with no further manipulation in the application.
Object Reuse:
It enables centralization of code and pooling of reusable objects by creating
PL/SQL libraries and object libraries, linking the object behavior of different
modules by inheritance and subclassing mechanism.
Confidential
10
Summary
In this chapter, you have learnt that:
Oracle Forms Developer is a front-end tool used to develop enterprisedriven applications with its GUI capabilities.
Key Features of Oracle10g Forms Developer are tools for Rapid Application
Development, Application Partitioning, Flexible Source Control, Extended
Scalability and Object Reuse.
Confidential
managing
unstructured
and
11
Exercise
1. What do you understand by Grid Computing?
2. What are the different Oracle 10g tools for Forms Development?
3. Explain briefly about Oracle Forms Services.
4. What are the different Reporting Tools?
5. List out the key features of Oracle10g Forms Developer.
Confidential
12
Chapter 2
Confidential
13
Objective
At the end of this chapter, you will be able to:
Confidential
14
Application
Server
Database
Three-tier Environment
Let us now discuss the different entities of the architecture individually in detail:
Forms Client:
It includes a thin Java applet embedding all types of Oracle forms application,
which runs within the boundaries of clients Java enabled web browser. This is
also known as thin client as no application logic or enterprise data is stored by it.
It is responsible for:
Application Server:
It is the middle tier where the application logic and the main component for
deployment, the Form Services reside. All processing related to application is
done here.
Confidential
15
Application Server
The main components that reside inside the form services of the Application
Server are:
Forms Listener Servlet: It is a complete Java Servlet that runs in the middle
tier, which works in close proximity with Oracle HTTP Server or OC4J (Oracle
Application Server Container for J2EE).
Responsibilities include:
Acts as a communicating agent between the client and the runtime engine.
Confidential
16
Starting OC4J
Oracle10g AS Containers for J2EE (OC4J) is Oracles Java 2 Enterprise Edition
(J2EE) container that executes on any Java Virtual Machine (JVM), the Java
interpreter that is provided on each operating system and hardware platform. It
is implemented completely in Java, making it lightweight and easy to install. At
the same time, it provides complete support for J2EE applications, including
Servlets, Enterprise JavaBeans, Java Server Pages, and so on.
OC4J is ideally suited to run Forms applications. It is included in Oracle10g
Developer Suite to enable you to test your applications, if desired, on the same
machine where you are running Forms Builder. In other words, you do not need
to install Oracle10g AS to test your applications.
To use OC4J on Windows NT, you start it by executing the provided batch file,
called startinst.bat. This file is located in the j2ee\Oracle10gDS\ subdirectory of
ORACLE_HOME. If you will be testing your applications on your client machine,
then it is a good idea to set up a shortcut to startinst.bat batch file and also
stopinst.bat batch file to start and stop the OC4J instance respectively.
The batch file executes in a separate window. (You can minimize this window if
desired). Do not close this window, or you will abort the OC4J instance.
When you no longer need to run OC4J, you can execute the batch file to stop the
OC4J instance, called stopinst.bat.
Confidential
17
Running of a Form
In order to run the application in a web browser, the users request should be in
the form of a URL. This URL is written in the address bar of the web browser. The
syntax of the URL would be similar to the following format:
http://domain[:port]/forms servlet or html file [parameter]
Where,
http: Protocol
Domain: Server name where the application resides.
Port: Default for HTTP server
8889 default for OC4J
FormsServlet: /forms/frmservlet
Parameter: indicates form, userid=username/password@database
It caches the Java archive files on the client thereby helping reduce the
application startup time.
Confidential
18
returns to the same page, the cached page is restored. This improves
the application performance.
A request is sent from the client to the application server in the form of
URL.
The request is taken up by the Oracle HTTP server or OC4J and passed
further to Forms Servlet.
In response to it, Forms Servlet creates a HTML page containing all the
relevant information for the generation of a forms applet, which is
given to the HTTP server. You can see this in the following diagram:
Confidential
19
Forms applet running within the client browser, displays the application
as per the application logic.
Confidential
20
SDI Window: Form Builder also provides support for a Single Document
Interface (SDI) Window even though the default window is the MDI
Window.
Menu Toolbar: Menu Toolbar contains icons that correspond to the menu
items. It is provided to add functionality and is a short cut to the menu
items.
o Status Line: Displays the state of the form module. It will tell you if
there is a list of values associated with the item and if the block is
Confidential
Boilerplate text
Boilerplate graphics
Prompts
21
Text items
List items
Push buttons
Display items
Radio buttons
Check boxes
Image items
Hierarchical tree items
Chart items
Custom items
UI_ICON_EXTENSION
FORMS_HIDE_OBR_PARAMS
FORMS_BUILDER_CLASSPATH
Confidential
22
FORMS_PATH
Gives path of the Form
being searched by
Forms builder to run it
CLASSPATH
ORACLE_PATH
Specifies path of
Java Class file
required for Forms
FORMS_RESTRICT_ENTER
_QUERY
Set this parameter
to True to invoke
the Query/Where
dialog box. By
default it is set to
False.
Alternatively, you can control the environment variable setting in file known as
\forms\server\default.env
Confidential
23
Summary
In this chapter, you have learnt that:
Forms Client includes a thin Java applet embedding all types of Oracle
forms application, which runs within the boundaries of clients Java
enabled web browser.
In order to run the application in a web browser, the users request should
be in the form of a URL.
One of the benefits of JRE is that it caches the Java archive files on the
client.
Forms Client cannot interact with the database directly. So here, runtime
engine works on behalf of the client.
Forms runtime session components are MDI Parent Window, SDI Window,
Default Menu, Menu Toolbar and Console.
Confidential
24
Exercise
1. What are the main components of Forms Services?
2. What are the different modes of operations?
3. ________ is the default window provided by forms builder.
4. ________ is the default canvas provided by Forms Builder.
5. What are the components of run-time session?
6. What is the default port number in Oracle 10g?
7. Which file is required to start and stop OC4J server?
8. List the forms environment variables available at design time and runtime?
9. _______ gives the path of the Form being searched by forms builder to
run it.
10. _______ specifies the path of java class file required for forms debugger.
11. _______ is set so that forms builder can find java class files during
development and testing process.
12. _______ path of an icon is set here which is used to create iconic images
in the forms builder.
13. Type of the iconic image i.e., gif, jpeg or ico must be specified in _______.
14. In formsweb.cfg change the applet parameter width to 900 and height to
600.
Confidential
25
Chapter 3
Confidential
26
Objective
At the end of this chapter, you will be able to:
Confidential
27
Menu Modules: Form Builder enables users to create their own menus. The
menu of an application is created and stored in a menu module. Users can
customize or replace the default menu provided by Oracle Forms
Developer.
Confidential
28
Confidential
29
Layout Editor: Provides an interface to create and arrange the items and
graphical objects in your application.
Confidential
30
Confidential
31
Canvas: A canvas is the interface where items are placed. A window can
contain more than one canvas. There are four types of canvases:
o Content Canvas
o Stacked Canvas
o Tab Canvas
o Toolbar Canvas
Block: A block is the owner of items in a form; there can be more than
one block in a form. All the items in a block are logically related. There are
two types of blocks:
o Data Blocks: These blocks contain items that are based on the
database tables, views, stored procedures, a FROM clause query, or a
transactional trigger.
o Control Blocks: These blocks are not based on any database tables,
but they are created to enhance the functionality of the application.
Confidential
32
Confidential
33
show detail data block. In either case, records in a data block that are currently
not visible on the screen are stored in a block buffer.
Map each data block to a different database table (You can have one base
table per data block.)
You can create a large form module with many data blocks. Alternatively,
you can create several smaller form modules with fewer data blocks in
each.
Modules are loaded only when their components are required, thus
conserving memory.
Confidential
34
Block 1
Block 1
Block 1
Form C
Block 2
Open Form
Block 3
Block 2
Block 1
Form A
Open Form
Block 4
Form B
Here are some points to consider while grouping data blocks in the application:
Confidential
is
35
A Brief Explanation
Branch table stores the Unique ID number and location of different branches of
the library.
Member stores the details of the members with their details and to which branch
they belong.
Member fee stores the details of the range of age, their fee and the grade.
The Book table stores the details for the books present in each branch with
number of copies.
Transaction table stores the daily transaction of issuing to and receiving the
books back from the members. Only those books are to be issued which are
present in the BOOK table.
Confidential
36
Category stores the details of the category id and the type of books.
Publisherdetails stores the details of the publisher.
Libstaff stores the details of the librarian staff.
Confidential
37
Summary
In this chapter, you have learnt that:
When you run a form, you principally navigate by the way of items and
blocks and not by canvases.
Form modules consist of logical data blocks. A data block is the logical
owner of items. Items in one data block do not need to be physically
grouped. Items in one data block can span several canvases.
Usually, you create a single-record data block to show master data block.
With more than one data block in a Form Builder application you can
separate the navigation cycle of one group of items from another.
Confidential
38
Exercise
1. What are the different Forms builder components?
2. Name the form builder interface components?
3. Explain the different
functionality.
kinds
of
Modules
available
along
with
their
Confidential
39
Chapter 4
Confidential
40
Objective
At the end of this chapter, you will be able to:
Confidential
41
Introduction
In the process of creating a Form Module many form builder components are
used. To start with the Object navigator, it is used to create an Empty Module. It
is only at this stage, you will find a window created by default. Data block, which
holds the actual data, has to be created through wizard or manually. Once this is
done, align the object or layout editor for further fine-tuning. Functionality to the
items is coded using the PL/SQL. Finally, to test the application, the form builder
is executed using the run button on the standard tool bar.
You will look at each of these phases in subsequent pages.
Click the right mouse button and select the Data Block Wizard option
In the Object Navigator, choose the Data Block node, and click the Create
icon in the toolbar. The New Data Block dialog box appears as shown
below.
In the Layout Editor, click the Data Block Wizard icon from the toolbar.
Type screen: To select the object that the data block is based on.
Confidential
42
Table screen: To select the database table on which the data block
should be based
Finish screen: To create the data block and invoke the Layout Wizard
Confidential
43
6. Select the column or columns you want to include in the data block. To
select multiple columns press [Ctrl] and select all the columns and then
release the [Ctrl] key or Click >> or << to include or exclude all the
columns. Including a column will enable the user to see that column in the
data block. If you exclude the column it will not appear in the data block.
Click > or < to include or exclude a single column.
7. Check Enforce data integrity checkbox to enforce data integrity on the
client side. The Form Builder does this by writing triggers. These triggers
are dealt in a later session.
8. In the finish screen, select Create the Data block, then call the Layout
Wizard option and click Finish as shown below.
Confidential
44
The steps to create the layout for the data block are:
Select New Canvas from the list in the canvas screen as shown below
to display the data block items.
Confidential
45
Select Content as the canvas type in the Type list and click Next.
In the data block screen, choose the items from the Available Items
option. Use the [Ctrl] key to select more than one item or click > or <
to include or exclude selected items. Click >> or << to include or
exclude all items. You can also drag and drop items to display in a
certain sequence. Select all the items.
Select the item type from the Item Type list for each item. Form
Builder provides the default type as Item. Click Next to display the
Item screen.
In the Item screen, set the prompt values for every item, set the
name, text display width and height as shown below:
Confidential
46
Select the Form or the Tabular option as shown below and click Next to
view the Frame and rows screen.
Confidential
47
Select the Display scrollbar check box if you want a scroll bar for your
data block (if the data block style selected is Tabular) and now click
Next to view the last screen.
In the finish screen, click Finish to create a frame and layout the items
for the data block.
After you have finished creating the form module and designing its
layout, go to the Object Navigator and:
Confidential
48
NOTE
Re-entrant Mode
When you create a form module, the Form Builder provides the form module with
a default name MODULEXX. This name is displayed in the Object Navigator and in
the Property Palette.
Create a form module and change its default name to frmLib.
To change the name of the form module in the:
Object Navigator:
1. Double-click the Forms node in the Object Navigator or select the object
and select the Property option from the Tools menu
2. Change the name of the form module by typing frmLib in the Name
property as shown below:
Confidential
49
To modify the layout of an existing data block, you have to re-enter the
Layout Wizard. You can re-enter the Layout Wizard by any of the following
two methods:
In the Object Navigator:
Select the form module that you want to customize and click:
Tools menu->Layout Wizard option
You can also invoke the wizard by clicking the right mouse button and
selecting the Layout Wizard.
In the Layout Editor:
Select the frame of the data block and invoke the Layout Wizard either from
the Tools menu or by right-clicking the mouse.
On invoking the Layout Wizard you can change the name of the data block by:
Double-clicking the required data block and changing the name in the
Object Navigator.
Confidential
Invoking the Property Palette by double clicking the node next o the
data block you want to modify.
50
Select the Edit menu and select the Preferences menu option.
Explicitly:
Select the File menu. Select Program Compile Module option. Ensure
that the file is open.
A Web browser
You can run the form module from the Form Builder by clicking one of the four
run methods, or
In the Object Navigator: Choose the Program menu and select the Run Form
option.
Select one of the two run form options:
Web: This option is used to run a form module from a Web previewer.
Debug: This option is used to invoke the debug mode for the current
runtime session.
Confidential
51
.fmb: extension is used for the form design file, it represents form
module binary. This file is portable across platforms
Menu Modules
.mmb: Represents a menu module binary file. It is the menu design file
and is portable.
Confidential
52
PL/SQL Library
.pll: PL/SQL Library Document Binary. Files with this extension are
design files but can be executed as it contains both the source code and
executable code. This file is portable
Object Library
.olb: The object library module binary is a design file and is a portable
file
.olt: The object library module text is a text export file and is portable
Runtime Modes
When you run a form, it is always in one of the two modes:
Normal mode
Retrieve records
You can know the number of rows that match your condition before records are
retrieved by selecting Query Count Hits
Enter Query mode does not allow to:
Insert records
Update records
Delete records
Confidential
53
Normal Mode
Normal mode is used to perform DML operations on the database. In this
mode you cannot retrieve restricted set of records.
Normal mode allows to:
Insert records
Update records
Delete records
Commit
Rollback
Retrieving Data
You can retrieve data from the database to make
modifications or to view data. You can retrieve data by
performing restricted query or an unrestricted query.
UnRestricted Query
You can retrieve all the records from the database by
performing an unrestricted query. You cannot query when
you have an unsaved insert, update or delete. Use one of
the following to query:
In the Forms Runtime, select the Execute option from the Query menu.
Click the Execute Query icon from the Forms Runtime toolbar.
Restricted Query
A Restricted query retrieves records that match your query
criteria. You can use the following wildcards in your search
condition:
Wildcard Character
Uses
%
>
<
<
>,
!
=
>
=
<
=
#
Confidential
54
Wildcard Character
Uses
Select the Query menu, and click the Enter option or choose the Enter
Query icon at the runtime.
For instance: you want to know the book details whose number of
copies is greater than 2.
Now, to Execute the query, select the Query menu and choose
the Execute option or click the Execute Query icon.
Select the Query menu, select Enter option or click the Enter Query
icon.
Select the Query menu, select Execute option or click the Execute
Query icon.
Specify the search condition in the Query/Where dialog box. Use the
Query/Where dialog box to specify a complex search condition using SQL. Also,
use the dialog box to execute queries with OR or the ORDER BY clause.
Click OK.
For example: Enter the following in the Query/Where dialog box, to retrieve all
the member details of all the members whose age is between 18 and 56.
: a between 18 and 56
Confidential
55
2. Enter data
3. Steps to update a record are:
Select the Query -> Execute option to retrieve the records that
match your search condition
Select the record you want to delete and delete the record by doing
one of the following:
If you do not want to make inserts, updates and deletes option permanent, you
should clear the record. You can perform a rollback by choosing Action Clear All
from the menu.
Confidential
56
Click the Create icon or select the Create option from the Navigator menu
The New Data Block dialog box is displayed, choose the Build a new data
block manually option.
Open the Property Palette of the data block you just created and change its
default name to Controlblk.
A control block will not contain any items until you add them
manually.
Deleting a Block
Deleting a data block deletes all the items that are owned by that
particular data block. However, the frame and its title are not deleted. To
delete the frame and its title you have to do it manually in the Layout
Editor. To delete a data block:
In the Object Navigator, select the data block you want to delete
Click the Delete icon in the toolbar or select the Delete option from the
Navigator menu
Click Yes to delete the data block when an alert appears for confirmation
NOTE
A master block can contain more than one detail block. A
detail block can be a master to another detail block. A
detail block can also have more than one master.
Confidential
57
ON-CLEAR-DETAILS
ON-POPULATE-DETAILS
ON-CHECK-DELETE-MASTER
Confidential
58
1.
2.
3.
4.
5.
6.
7.
8.
Control a Relation
The functionality of the relation is enhanced by controlling the block
coordination and deletes. This is done by modifying the relation
properties.
By setting the Delete Record Behavior property you can control the
deletion of a record in the master block when the associated records
exist in the detail block.
The following properties control the master deletes.
Non-Isolated: By setting this property you can prevent the deletion of
master records when corresponding detail records exist. Default
property is set to Yes.
Cascading: By setting this property you can delete all the detail
records when a master record is deleted. But the commit message will
show only the number of master records that were deleted.
Isolated: By setting this property you can delete the master record
even if corresponding detail records exist.
Confidential
59
NOTE
The default setting is Non-Isolated. When you change the
property from the default value to Cascading, Form Builder
replaces the ON-CHECK-DELETE-MASTER trigger .with a PREDELETE trigger. Changing the property from Non-Isolated to
Isolated deletes the ON-CHECK-DELETE-MASTER trigger.
Coordination Property
Set the coordination property to control the display of the detail block records
whenever the master block is queried. The coordination property options are:
Default: When a user or trigger changes the master record,
this property enforces the coordination of the blocks.
Deferred with Auto Query: Processing of the detail query
is postponed until the cursor is in the detail block.
Deferred Without Auto Query: Additional query criteria
can be specified in the detail block before querying.
Confidential
60
Summary
In this chapter, you have learnt that:
You can create a Data Block manually or by using the Data Block Wizard.
After creating the data block, use the Layout Wizard to create a good
visual presentation for the application.
To create the block you need to choose appropriate options on the three
wizard screens: Type screen, Table screen, Finish screen
The Layout Wizard has seven screens to navigate and enter the required
information for designing the Layout.
When you create a form module, the Form Builder provides the form
module with a default name MODULEXX.
To modify the layout of an existing data block, you have to re-enter the
Layout Wizard. After invoking the Layout Wizard you can change the name
of the data block
When you run a form, it is either in enter query mode or normal mode.
A data block that is not associated with the database is known as a control
block.
Confidential
61
Lab Exercise
Choose the Style as Form and show just one record at a time.
3. Rename the canvas name to CV_BOOKS
4. In the layout editor, reposition the items and edit the prompts.
o
Now on the canvas select the frame and remove. Create a rectangle on
the canvas such that it fits the block items.
Confidential
62
Give the details of the books published in the year from 1996 to 1998 .
2. Create a new block by using the data block wizard. Base it on the MEMBER
table and include all the columns.
3. Create a relationship between BRANCH and MEMBER where BRANCH will serve
as a master block and MEMBER will be the detail block.
Confidential
63
When, continuing in the layout wizard make the following changes in MEMBER
block.
o Display all items except CBRANCHID on the CV_BRANCH canvas.
o Use a tabular style of layout.
o Display 5 records in this detail block on the same canvas as the master
block.
After you finish, your form would look as below:
Change the order of the blocks in the object navigator, moving the MEMBER block
after the BRANCH block.
Save the new module as BRANCHXX, where XX is the unique number. Now create
another new block with following specification.
Base it on the TRANSACTION table. Place the items of this block on a new content
canvas called CV_TRANSACTION.
o Use a tabular style layout and include a scroll bar.
o In the object navigator, move the TRANSACTION block after the
MEMBER block.
o Do not create any relationship between blocks at this stage.
The transaction details would be something like this:
Confidential
64
Confidential
65
Chapter 5
Confidential
66
Objective
At the end of this chapter, you will be able to:
Confidential
67
Find field: This field enables you to search for a property name quickly and
easily.
Text field: This field is displayed when the value of the property can be set
by entering the text. If the text that has to be entered is long then an icon
appears, by clicking the icon you can invoke an editor to enter the text.
Poplist: This is displayed when there is a fixed set of values. Click on the
arrow to display the list and choose a value. You can also double-click on
the property name to view the values.
Confidential
68
More button: This is displayed when additional settings are needed. Click
the More button to open a dialog box.
Changed
Default
Overridden
Inherited
Visual Attributes
Font, color, and pattern properties set for form and menu objects are
Visual Attributes. Visual Attributes are created in the Object Navigator.
Once a visual attribute is created it can be used for different forms, menus
and items. Every interface object in a form module has a property named
Visual Attribute Group. By setting this property to DEFAULT or userdefined visual attribute, you can influence the appearance of that
particular item.
Steps to create a visual attribute say vattLib and attach it to the Member
data block in the frmLib form module:
9. Select the Visual Attribute node in the Object Navigator and click the
Create icon.
10. Invoke the Property Palette, change the default name to vattLib and set
the following properties:
Font Size: 10
Confidential
69
11. Invoke the Property Palette for the Member data block, set the Current
Record Visual Attribute Group property to vattLib to highlight the current
record at runtime.
12. Another type of visual attribute is the partial visual attributes. These are
similar to visual attributes. The only difference is that you need to set only
those properties that will be used by objects that use them.
General
Navigation
Records
Database
Advanced Database
Scrollbar
Color
International
Navigation Properties
Invoke the Property Palette of the data block by double clicking the data
block node to the left of the data block. When you set the following
properties, it allows you to control the navigation in a data block:
Navigation Style: When you try to navigate beyond the last item in a
record, the cursor is returned to the first item of the same record. This is
the default setting. You can control the cursor position by setting its
property to any of the following options:
Same Record: This is the default setting. If you try to navigate beyond
the last item in a record the cursor will return to the beginning of the
record.
Change Record: The cursor will move to the next record when you try
to navigate beyond the last item in a record.
Change Data Block: The cursor will move to the next data block in the
form module
Confidential
70
Database Properties
The database properties are important to the application developers.
These properties will enforce integrity constraints. It will also allow query,
insert, update, delete and the number of records that are to be retrieved
on querying. Some of the important database properties that control the
behavior of the data blocks are:
Database Data Block: Set this property to Yes if the data block is based
on a database object and No when the data block is not based on a
database object. For example, a control block.
Enforce Primary Key: Set this property to Yes for the Form Builder to
check that the records are unique and satisfy the primary key condition
before they are inserted into the table.
Query Allowed: Set this property to Yes to allow queries on the data
block.
DML Array Size: Set this property to control the number of records that
will be sent to the server for batch processing.
WHERE Clause: By specifying a WHERE clause for the data block, you
restrict the number of records that are retrieved. If the user gives a search
condition in the Enter Query mode, then this WHERE clause is
automatically appended to the user search criteria.
Enforce Column Security: Items in the data block can be updated only if
the user has the permission to update them. Set this property to Yes to
restrict access to sensitive database columns.
Record Properties
The following are the important record properties:
Query Array Size: This property controls the number of records that will be
fetched from the database.
Confidential
71
Query All Records: Set this property to retrieve all the records that match
the query criteria.
Record Orientation: Set this property to display the records in a data block
vertically or horizontally.
Single Record: This property is specific to a control block. Set this property
to Yes for a data block containing summary calculated item.
Show Scroll Bar: Set this property to Yes to display a scroll bar for the
data block. Set this property to No to delete an existing scroll bar.
Scroll Bar Canvas: Set this property to specify on which canvas the scroll
bar has to be created and displayed.
Scroll Bar Orientation: Set this property to specify if the scroll bar has to
be displayed horizontally or vertically.
Reverse Direction: Set it to Yes to make the scroll bar scroll in the
reverse direction.
All the items within a data block are automatically arranged in a frame
when you associate the frame with a block. Therefore, a data block can be
associated with only one frame. Manipulate the frame properties to design
the arrangement of items within a frame. A few of the frame properties
are:
Layout Data Block: To specify the data block with which the frame should
be associated. All the items of the data block are arranged in this frame.
Update Layout: Its settings are as follows:
Manually: The layout is updated when you use the Layout Wizard to
modify the frame or when you click on the Update Layout in the
Layout Editor. Alternatively you can select the Arrange menu and
choose the Update option in the Layout Editor.
Confidential
72
Raised
Lowered
None
Inset
Outset
Plain
Now open the Property Palette for the second object by using F4. It will
open in a separate window.
Confidential
73
You can set properties for multiple objects in a data block at the same
time. In the Object Navigator select the objects that you want to set
properties for and invoke the Property Palette to display a combination
of properties for all the objects that you selected. To choose a
combination of properties set either of the two options:
Union: You can set the combination to union by clicking the
Union/Intersection button in the Property Palette toolbar. This will
display the common as well as the unique properties of all the objects
that you select.
Intersection: This is the default option. Use this option to display only
the common properties of all the objects that you select.
In the Object Navigator invoke the Property Palette for one of the
objects.
Press the [Ctrl] key and click on the objects whose properties are to be
modified simultaneously.
Holding the [Ctrl] key click the right mouse button and select the
Property Palette option.
Confidential
74
Copying Properties
You can copy properties and apply them to other objects in your form
module by:
Invoking the Property Palette and setting the values for the properties that
are to be copied. The Property Palette can belong to a single object or a
combination of objects.
Selecting All properties:
To copy all the property values, select the Edit menu in the Property Palette
and choose the Select All option.
Selecting specific properties:
To copy some specific properties, press the [Ctrl] key and select each
property individually by:
Clicking the Copy Properties icon in the Property Palette toolbar.
Selecting the object (from the Object Navigator) in which the properties
are to be copied. Invoke its Property Palette.
Clicking the Paste Properties icon in the Property Palette toolbar. All the
properties that you copied will be applied.
Property Classes
A Property Class is a Form Builder object that contains properties and
property values, which can be inherited by other objects. Creating a
Property Class and saving it for future applications will save a lot of
development time, as there will not be a need of defining property values
again for all the objects. More of this will be discussed later in subsequent
chapters.
Confidential
75
Summary
In this chapter, you have learnt that:
There are various Data Block properties and features of Property Palette
and how to invoke a property palette, etc.
To invoke the Property Palette of an object, you can either select the
object or you can select the Property Palette menu option from the Tools
menu given in the Object Navigator:
The Property Palette has Text field, Poplist, LOV window, More button
following property controls with which you can manipulate properties:
The database properties allow query, insert, update, delete and the
number of records that are to be retrieved on querying.
You can copy properties and apply them to other objects in your form
module by invoking the Property Palette and setting the values for the
properties that are to be copied which can belong to a single object or a
combination of objects.
Some of the important record properties are Query array size, Number of
records Buffered, Current record visual attribute group etc.
You can set properties for multiple objects in a data block at the same
time.
Confidential
76
Lab Exercise
1. Create a
specification:
visual
attribute
named
Current_Record
with
following
Confidential
77
Chapter 6
Confidential
78
Objective
At the end of this chapter, you will be able to:
Editors
Confidential
79
Text Items
As you already know a form module consists of data blocks and the data
blocks in turn are made up of objects or items. A text item is a user
interface object, which enables the user to manipulate data. You can
modify the properties to alter the appearance and behavior of the text
items. A text item will allow you to:
Query data
Insert data
Update data
Delete data
NOTE
Confidential
80
NOTE
General Property
Item Type: Select the type of item from the item pop list.
Physical Property
Records Property
Current Record Visual Attribute Group: Specify the visual attribute that
is to be associated with this item.
Font Name: Select the font you require from the font list.
Confidential
81
Foreground Color: Specify the foreground color for the text item
Background Color: Specify the background color for the text item
White on Black: Setting this property will display text in white color on
a black background on a monochrome monitor
Prompt Property:
Prompt is the label associated with the text item. You can manipulate
these labels by modifying the following properties:
Prompt: Set the text label for the text item
Prompt Display Style: Set the display style of the prompt from First
Record, Hidden and All Records.
Convert an existing item by invoking the Property Palette of the item and
setting its Multi-line property.
Confidential
82
Required: Set this property to Yes so that the user would have to
compulsorily enter a value before navigating out of the item or record.
Lowest Allowed Value: Set this property to specify the minimum value for
the text item.
Highest Allowed Value: Set this property to specify the maximum value
for the text item.
Synchronize with Item: Set this property to specify the item from which
the text item will inherit values.
Confidential
83
Copy Value from Item: Set this property to specify the data block and the
item from which the text item will copy values into the text item. This
property can be used to link data blocks. When you create a masterdetail block, Form Builder will automatically set this property for the
foreign key item in the detail block.
You should disable user input in this item to ensure that the foreign key
relationship is not violated
Format Mask: Set this property to specify the format for the text item.
Using the FX format mask in a date value ensures that the user must
enter the date exactly as specified in the mask. You can use the standard
SQL formats for dates and numbers. For example, DD/MM/YY and
$999.99. Enclose embedded characters like hyphen (-) and brackets () in
double quotes.
Initial Value: Set this property to specify a default value for the text item.
These values can be changed at runtime. The initial value has to be
compatible with the data type of the item. The initial value should be
within the range, if the Lowest Allowed Value and the Highest Allowed
Value are specified. To set an initial value use any of the following
values:
3. Raw
Example: 01ADLNJ
4. System variable
Use the following variables to give the operating system date and
time
Variable
Format
$
$
D
A
T
E
$
$
$
$
D
A
T
E
T
I
M
E
S
$
$
Confidential
D
D
M
O
N
Y
Y
D
D
M
O
N
Y
Y
Y
Y
h
h
:
m
i:
84
[
s
s
]
H
h
:
m
i:
[
s
s
]
$
$
T
I
M
E
S
$
$
Use the following variables to give the current database date and time
Variable
Format
$
$
D
B
D
A
T
E
$
$
$
$
D
B
D
A
T
E
T
I
M
E
S
$
$
$
$
D
B
T
I
M
E
$
$
DDMON
-YY
DDMON
YYYY
hh:
mi:[
ss]
Hh:
mi:[
ss]
Confidential
85
Previous Navigation Item: Set this property to specify from which item
the user should navigate to the current item.
Next Navigation Item: Set this property to specify the item to which the
user should navigate to from the current time.
Set the Keyboard Navigable and Enabled properties to
navigate and interact with the item.
Keyboard Navigable
Enabled
YES
NO
YES
NO
You can modify and enhance the relationship between a text item and its
associated database column by modifying the Database group properties.
The following are the important Database properties:
Database Item: Set this property to specify if the item is based on a
database table or a control block.
Primary Key: Set this property to specify that the item corresponds to
the primary key column in the database table.
Query Only: Set this property to specify that the item can be queried but
insertion and updation are not allowed.
Confidential
86
Case Insensitive Query: Set this property to determine the case where
a user can query.
Update Only If NULL: Set this property to specify that the item should
allow update only if the current value of the item is null.
Lock Record: Set this property to specify that the record should be
locked during an update. This property does not apply for the base table
items.
You can enhance the functionality of a text item by setting its Functional
properties. The important Functional properties are:
Enabled: Set this property to allow navigation and manipulation of a text
item with the mouse.
Case Restriction: Set this property to force the user input into Upper,
Lower or Mixed Case.
Conceal Data: Set this property to hide the value in a text item.
Popup Menu: Set this property to display the popup menu for the current
form module.
Hint: Use this property to display item-specific help text in the message
line of the console.
The values in the pick list change automatically when there is a change in
the source data.
The user can invoke the LOV from any text item.
Confidential
87
LOVs can be created to use data that is already in the form, instead of
accessing the database.
Auto reduction feature in the LOVs help the user to access a particular
value easily and efficiently with a minimum number of keystrokes.
Defining a LOV
LOV: It displays the values of the columns that are stored by the record
group in the popup window.
Text Items: The text item is the one, which receives the values returned
by the LOV. You can have the same LOV associated to several text items.
Creating LOVs
You can create an LOV using the LOV Wizard. The LOV Wizard can be
invoked by one of the following methods in the Object Navigator:
Selecting the LOV Wizard option from the Tools menu
Selecting the LOV node and after clicking the right mouse button, select
the LOV Wizard option
Confidential
88
3. Specify the query to create a record group by any of the following methods:
Clicking the Build SQL Query button to use the Query Builder.
Clicking the Import SQL Query button to import a query from a file.
Entering a query in the SQL Query Statement field. Click the Check
Syntax button.
Confidential
89
Click Next
4. Select the columns that you require for the LOV. Select the cBranchID and
the cBranchName columns. Click Next to display the column properties
screen.
Confidential
90
5. Specify the title as Branch ID and Branch Name, width and return value for
all the updation columns that you have selected.
6. Click the Lookup Return Item button and select the Member.cBranchID
column to store the value returned by the LOV. Click Next to display the LOV
display screen.
Confidential
91
7. Specify the LOV title as Branch Details, width and height of the LOV popup
window. Click Next.
8. In the next screen the options are:
Specify the number of records that are to be retrieved at a time from the
database.
Confidential
92
Click Next .
9. Click Finish to create the lvBranch LOV.
Discuss the LOV Properties
Filter Before Display: Set this property to display a dialog box that
enables the user to enter a search condition before invoking the LOV.
Automatic Refresh: Set this property to Yes if you want the record
group to execute the query every time the LOV is invoked.
Automatic Skip: Set this property to Yes if you want to navigate to the
next item once a value is selected from the LOV.
Confidential
93
Return Item: Specify the form item or variable to which the value of
the LOV should be returned. Use any of the following:
block_name.item_name
GLOBAL.variable_name
PARAMETER.parameter_name
Display Width: Set this property to specify the width of the column
display. If you want the column to be hidden, but the value to be
returned then set this field value to 0.
Confidential
94
Confidential
95
Editors
An Editor is a dialog box associated with a text item. An editor not only provides
the space to type in large text but it also provides the functionality to find and
replace text. The following are the two types of editors in the Forms Developer:
Form Builder default editor
Creating an Editor
Click the Create icon from the toolbar. A new editor is created, which
you can see in the Object Navigator.
Select the editor in the Object Navigator and invoke the Property
Palette.
Editor Properties
None
Character
Word
Show Vertical Scroll Bar: Set this property to display a scroll bar for the
editor.
Confidential
96
Editor_Name: The text item will use the user created editor.
Invoking an Editor
Steps to use an editor at runtime are:
Place the cursor in the text item that you want to edit.
Press the function key ([Ctrl] + E) to invoke the editor or from the Edit
menu select the Edit option, the editor is displayed.
Confidential
97
Summary
You can use Object Navigator, Layout Editor, wizards, etc to create a text
item.
You can control the appearance of a text item by changing the general,
physical, records, font and color property etc.
You can create a multi-line text item to display large text values like
addresses and description.
When you create a text item manually the text item will not have a default
prompt. You can specify a prompt for the item by creating a boilerplate
text.
You can modify the appearance and behavior of a text item by setting its
properties in the Property Palette.
You can control the navigation of a text item by setting its Navigation
properties such as Keyboard navigable, previous navigation Item and Next
navigation Item.
You can modify and enhance the relationship between a text item and its
associated database column by modifying the Database group properties.
An LOV can be accessed by any text item within the form module, as it is
defined at the form level.
LOV displays the values of the columns that are stored by the record
group in the popup window.
You can create an LOV using the LOV Wizard by clicking on the create icon
in the object navigator and, can also be invoked by selecting the LOV
Wizard option from the Tools menu in the main menu.
Confidential
98
Lab Exercise-6
1. Create a Text item, Label it as Member name; place it on the right top
corner in the CV_BRANCH canvas of BRANCHXX form module
set the property to this text item so that the text item will act as a
non-navigable item
Save, compile and run the form, see and test the changes.
2. Specify the properties for the nfine column of Transaction table to
Display 0 as the default value before any values are displayed and
The format of the amount should be some thing like this for
example:$3.00
Check out the changes in the output.
3. Change the following properties of the following Text items:
CBRANCHID:
Set the property so that the text item should be navigable only
through mouse.
CBRANCHNAME:
CBRANCHLOCATION:
Save, compile and run the form and check out the changes.
4. In BRANCHXX form module, create an LOV. Base the record group on
Branch table. Include the columns cbranchid and cbranchname in the
LOV.
Now attach this LOV to the cbranchid text item of the BRANCH data
block.
A Record group is created under the section Record Group with a default
name.
Confidential
99
5.
To query the records go to enter query mode, select the existing values of
cbranchid from BRANCH_LOV
Now Create a Record Group manually and name it as TRANSACTION_RG.
6.
Create an LOV, while creating this LOV, and select the existing
Record group as TRANSACTION_RG.
BRANCH_LOV:
Set the Property to display a dialog box the enables the user to
enter a search condition before populating the LOV
Confidential
100
Chapter 7
Confidential
101
Objective
At the end of this chapter, you will be able to:
Know about List Item, how to create and change its properties
Confidential
102
Check box
List item
Radio group
Insert records
Update records
Delete records
Query records
Check Box
A check box is a user interface object that allows user input. A check box is
always in one of the two states, checked or unchecked. It can be used for Yes or
No status fields. You can create a check box using one of the following methods:
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
Confidential
103
Confidential
104
2. Select the data block in which you want to create the check box
3. Click the Check Box tool button
4. In the canvas click at the place you want the check box to be displayed. A
check box appears
5. Invoke the Property Palette for the check box
6. Set the properties specific to the check box
Change the Item Type property to Check Box and set the check box
specific properties
Properties to be changed
Handling Null Values
You can handle null values with one of the following methods:
Ignore the check box in the Enter Query mode using [Shift] + [click].
List Item
List Item is a user interface object that displays a list of choices from which the
user has to make a selection. The user can only make a single selection. It
displays a predefined set of choices without using a large area of the canvas.
There are three types of list items, they are:
14. Poplist: It is a field with a down arrow on the right side. You can
display the list by clicking the down arrow. It does not accept input
values.
15. Tlist: It is a rectangular box with a scroll bar. You can view the entire
list by scrolling up and down.
16. Combo box: Like poplist, combo box too is a field with a down arrow
on the right side, which displays the list when clicked. It, however,
accepts input value.
Confidential
105
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
Accept all other values to one of the predefined list element values
Confidential
106
Selecting the canvas on which you want to display the list item
Selecting the data block in which you want to create the list item
Clicking on the canvas at a place you want to display the list item
Invoking the list item Property Palette by double-clicking the list item
Confidential
107
Poplist
Tlist
Combo Box
Elements in List: Click the More button to open the List Item
Elements window and specify:
List Item Value: With the value associated with each of the list
elements.
Confidential
108
POP LIST
T-List
Combo List
Radio Group
A radio group consists of a group of radio buttons. Each of these radio buttons
has a definite value associated with it. No two radio-buttons in a group will have
same values associated with them. Use a radio group when an item has two or
more possible values but only one of these values can be true at a given time. It
is advisable to use a radio group when the choice is less.
Confidential
109
Confidential
110
dialog box is displayed asking you if the new radio button should appear in
the same group or a new one.
5. Invoke the Property Palette of the new radio button.
6. Set the radio button with specific properties.
Mapping of Other Values: Set this property to specify how other values
should be handled.
Assign a null value to a radio button by leaving the Radio Button Value
property blank.
Associate other values to one of the radio buttons using the Mapping of
Other Values property.
Confidential
111
Label: Set this property to specify a text that describes the radio button.
Radio Button Value: Set the value of the radio button, which will be used
to insert or query the block.
Non-input Items
Non-input items as the name suggests, do not allow user input. However noninput items add functionality to your application by displaying data or by initiating
actions. There are two types of non-input items:
Display items
Image items
Calculated items
Hierarchical Tree
Push Buttons
Display Item
Display item as the name suggests is an item that displays data. It is similar to a
text item except that it cannot be navigated or manipulated at runtime. The data
in a display item can be derived either through calculation or from a database
table.
Here is the toolbox display item:
Confidential
112
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
In the Object Navigator, open the frmLibTrans form module and select the
Transaction data block.
Select the canvas on which you want the display item to be displayed.
Select the data block in which you want to create the display item.
Click the canvas at the position where you want the display item. A new
display item is displayed.
Specify the name as diTotalFine for the display item and set the display
item specific properties.
We will use the display item created later in the session and see how it displays
data.
Change the Item Type property to Display Item and set the display item
specific properties.
Confidential
113
Calculated Items
A calculated item is a display item. It is a very useful way to keep users updated
about important information. Calculations can be based on a formula or on a
summary. Use a display item to create a calculated item. The following are the
two types of calculation modes:
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
NOTE
Restricted Built-in subprograms are dealt in a later session.
Confidential
114
Set Data Type property to Number unless the summary function is MAX
or MIN.
Image Items
Image items are items that can be used to store and display images. An image
item displays automatically and it cannot be manipulated at run time. Images can
Confidential
115
be imported from the database or the file system. You can populate an image
item by one of the following methods:
Importing the image from the database columns (LONG RAW or BLOB).
Cutting and pasting an image to the clipboard and selecting the image
item at runtime, invoke the Edit menu and select the Paste option.
File
Description
BMP
CALS
GIF
Compuserve
JPEG
JPEG
PICT
RAS
Sun Raster
TPIC
TIFF
Image Format: Set this property to specify the storage format of the
image items.
Image Depth: Set this property to specify the image depth setting for the
image items.
Display Quality: Set this property to specify the resolution that is used to
display the image item.
Sizing Style: Set this property to specify how much of the image should
be displayed if the image size and the item size do not match.
Confidential
116
Show Palette: Set this property to display the image manipulation tools.
The tools are:
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
In the Object Navigator, open the frmLibTrans and select the Book data
block
Select the canvas on which you want to display the image item
Select the data block in which you want to create an image item
Click on the canvas at the position, you want to display the image item. A
new image item is displayed.
Set the name as imgBooks and other image item specific properties
We will populate this image item in the later session using triggers.
Push Buttons
A push button is an object that initiates an action when a user clicks it. Push
buttons cannot store or display values. There are two types of push buttons. They
are:
1. Text button: It is a rectangular button with a descriptive text label.
Confidential
117
Invoke an editor
Commit data
Perform a query
Perform calculations
Label: To specify the label that you want on the push button at the
runtime
Default Button: To make a button the default button for your block
Clicking the Create icon in the Object Navigator and setting the Item
Type property.
Confidential
118
Select the canvas on which you want to display the push button.
Select the control block Controlblk, in which you want to create the push
button.
Click the canvas at the position where you want the push button to be
displayed. A new push button is displayed.
Specify the name as pbout and label as Out, set the other push button
specific properties.
We will add functionality to this push button in a later session using triggers.
Confidential
119
NOTE
To display an item at runtime, you must assign it to a
canvas.
Confidential
120
A JavaBean is a component written in Java that can plug in to any applet or Java
application. The bean area item enables you to extend Forms functionality by
adding a JavaBean to your form.
With JavaBeans, you can interact with the client machine, performing such
functions as:
Displaying a progress bar, clock, calendar, or color picker with which the
operator may be able to interact and select values
Some of this functionality, such as the calendar, is possible using Forms native
functionality. However, using a JavaBean enables to interact with client without
generating network traffic.
Although JavaBeans can be used to input data, as in the case of the Calendar
JavaBean, the bean area item itself does not accept user input.
Confidential
121
Confidential
122
Summary
In this chapter, you have learnt that:
You can create Input Items such as Check box, list item, radio group and
input items that allow you to insert records, update records and Query
records.
A check box is a user interface object that allows user input which is
always in one of the two states, checked or unchecked.
To specify the list item style, you can select from Poplist, Tlist and Combo
Box.
You can create a display item by converting an existing item, using the
Layout Editor and by using the Object Navigator.
Image items are items that can be used to store and display images. You
can populate an image item by importing the image from the database
columns.
Push buttons like text button and iconic button cannot store or display
values.
A Java Bean is a component written in Java that can plug in to any applet
or Java application.
Confidential
123
Lab Exercise
1. In the BRANCHXX form module, Create an image item called CIMAGE in
the CONTROL block and place it below the member name label.
Note: For all the questions see the screenshot given below in the next
page and do it accordingly.
2. Convert the existing CBranchLocation text item to a pop-list.
3. Change the existing cmaritalstatus column in the MEMBERS block to a
checkbox such that
If the person is married the checkbox should be checked and if
unmarried the check box should be displayed unchecked.
Display values other than married or unmarried as Checked.
4. Convert the existing CGRADE column of Member table into a Radio group
with four radio Buttons namely A, B, C and D.
o
5. Create one Iconic push button, name it as PB_LOV and place it beside the
CbranchId text item of the CV_BRANCH canvas. (Functionality will be
added to this button in the subsequent chapters)
6.
Confidential
124
8. Convert the existing text item which was placed beside the label member
name to display item and name it as IMAGE_DESCRIPTION and
synchronize the current records CFIRSTNAME value with the display
item. This should appear as in the screen shot given in the following
figure:
9. Create display item for calculating the total fine of all the members who
are payable in the library (Display should be included in Transaction
block).
Confidential
125
10. Now create a java bean and name it as color picker in the CONTROL block
that will enable a user to choose a color from a color picker. ( this bean
area is invisible to the users)
The
path
to
the
oracle.forms.demos.beans.ColorPicker
sensitive).
bean
(this
is
is
case
Confidential
126
Chapter 8
Confidential
127
Objective
At the end of this chapter, you will be able to:
Create a Window
Create Canvases
Confidential
128
Window
A window is the outermost boundary of a form. It is like an empty picture frame.
Form Builder automatically generates a Multiple Document Interface (MDI)
window for your Forms applications. All the other windows that you create should
be within the MDI window. There are two types of windows:
Document or Modeless window: Is not necessarily active when it is displayed.
This is the default window type, which allows:
Dialog or Modal window: Dialog windows are used to display messages to the
user. A dialog window:
Requires user input to exit or dismiss the window. For example, File
dialog window is displayed in most of the GUI platforms, where as an
LOV is a native Form Builder object, which requires user input to either
exit or dismiss the LOV window.
Modeless
Modal
Confidential
129
New Window
A window is automatically created when you create a form module. The user can
change the default name of the window (WINDOW1) or can delete the default
window and create a new one. You can create additional windows to:
Creating a Window
The steps to create a window say winBookTrans in frmLibTrans form module,
in the Object Navigator are:
1. Select the Windows node
2. Click the Create icon from the toolbar
3. A new window is displayed, double-click it and invoke the Property
Palette
4. Change the default name to winBookTrans and set the other window
specific properties
Window Properties
The important window properties are:
y General Properties
y Functional Properties
Title: Specify the title that should appear in the title bar at runtime. If
you do not specify a title then the window name will appear by default.
Confidential
130
Minimized Title: Specify the title that should appear below the
iconified window when it is minimized.
Creating Canvases
As you already know a canvas is a Form Builder object that displays the user
created objects at runtime. The visible portion of a canvas is known as the
viewport. There are four types of canvases. They are:
y Content canvas
y Stacked canvas
y Toolbar canvas
y Tab canvas
y Implicitly:
Use the Layout Wizard: It enables you to select a new canvas in the
Canvas screen. A canvas is created with a default name (CANVAS1).
Use the Layout Editor: If a form module does not contain a canvas,
Form Builder will automatically create a canvas when the user invokes
the Layout Editor.
Confidential
131
In the Object Navigator, select all the items in the Branch data
block and invoke the Property Palette
y Window: Specifies the window in which you want the canvas to display.
For example, to display canBookTrans, set its Window property to
winBookTrans.
132
No causes the Form Builder to raise the canvas to the front of the
window only when the item to be navigated, is hidden behind another
canvas in the same window.
Yes causes the Form Builder to raise the canvas to the front of the
window, only when the user navigates to an item on that canvas.
Stacked Canvases
A stacked canvas is always displayed or stacked on top of a content canvas. It
hides whatever is beneath it. It can share a window with a content canvas and
multiple numbers of stacked canvases. Stacked canvases are smaller than the
window in which they are displayed and are determined by viewport size. Stacked
canvases are useful to:
y Display static information such as, the name of the company, its logo,
etc., by creating a stacked canvas that would always appear in front of the
current content canvas. Even when the current content canvas is replaced,
the stacked canvas would remain visible in the window.
y Display items or graphic images that users need to see only in certain
conditions, such as the help text.
y Create a scrolling region, if the block created contains more items than
that can fit in a window.
When users tab to items that are outside the windows frame, Form Builder
automatically scrolls the window. This however causes important field values to
be scrolled out of the users view. For instance, in the block based on the
Transaction table, the transaction ID, Book ID, and Member ID should be visible
for all transactions. Therefore, these fields could be placed on the content canvas
and other fields can be scrolled out of sight on a stacked canvas. By doing so, the
stacked canvas becomes the scrolling region and not the window.
y Show Vertical Scroll Bar: To display the canvas with a vertical scrollbar.
Creating a Stacked Canvas Using the Object Navigator
The steps to create a stacked canvas using the Object Navigator are:
Confidential
133
Set the Canvas Type property to Stacked and set the other stacked
canvas specific properties as required.
23.
Content
canvas
Stacked
Canvas
Click the stacked canvas tool button in the toolbar and drag and place on
the canvas.
Invoke the stacked canvas Property Palette and set the Name property
as cv_help.
Write text into the canvas and place a button on the stacked canvas to
hide the stacked canvas.
In the later session, we will deal with how to view stacked canvas only when it is
required. So for this, you have to create a button whose functionality will be
defined to invoke the stacked canvas, as and when clicked by the user.
In the Layout Editor, select Stacked Views option from the View menu.
A Canvases dialog box opens.
Confidential
134
Toolbar Canvases
A toolbar canvas unlike other canvases is not designed to display data. But it
enhances the functionality of your application by allowing you to create your own
toolbars to hold buttons. There are three types of toolbars, they are:
y Vertical toolbar: You can create a vertical toolbar, which contains all your
buttons and is displayed on the left or right of the window.
y MDI toolbar: Use an MDI toolbar to use only one toolbar for multiple
windows in your application.
Use a toolbar canvas to:
y Provide a uniform look to all the canvases displayed in the same window.
y Provide alternative to the default menu.
y Enhance the functionality of your applications.
Toolbar Properties
The important toolbar properties are:
Select the window from the Object Navigator in which you want to
display the canvas and invoke its Property Palette.
Select the form module from the Object Navigator that you will associate
the canvas with and invoke its Property Palette.
24.
Confidential
135
Horizontal Toolbar
Tab Canvas
A tab canvas is a special type of canvas, which can be used to display a large
amount of data by breaking them into smaller logical groups. Tab canvases are
displayed on top of a content canvas. Information is displayed on tabs. The tabs
on a tab canvas are like a group of stacked canvases.
A tab canvas consists of one or more tab pages. Each tab page occupies equal
space and has a labeled tab by which the user can access information.
Enhance the functionality of your application by using a tab canvas to:
y Hide data
Creating a tab canvas involves:
Confidential
Chamfered
136
Square
Rounded
y Width Style: Set the property to vary the width of the tab
y Active Style: Set the property to determine if the tab page label is
displayed as bold or normal.
y Tab Attachment Edge: Set the property to specify the location of tabs.
After setting the tab canvas properties, invoke the tab page Property Palette
and set its Label property to specify the text that should be displayed on the tab
pages tab at runtime.
Confidential
137
Confidential
138
cPublisherName,
Confidential
139
Summary
In this chapter, you have learnt that:
The user can change the default name of the window (WINDOW1) or can
delete the default window and create a new one.
The visible portion of a canvas is known as the viewport. The four types of
canvases are Content canvas, Stacked canvas, Toolbar canvas and Tab
canvas.
Confidential
140
Lab Exercise
1.
2.
3.
Create one more stacked canvas in the BRANCHXX form module, Include
horizontal and vertical scrollbars to the canvas.
o
Confidential
141
(Purpose of this stacked canvas is, when the show help push button is
clicked, this help should be displayed. We will add the functionality in the
next chapter.)
4.
5.
6.
Create Tab canvas in the BOOKXX form module and include 3 tabs
namely
o
Attach TOOLBAR_BRANCH canvas with the MDI at form level that is;
make this toolbar as the standard toolbar.
Confidential
142
Chapter 9
Triggers
Introduction to Triggers
Trigger Characteristics
Trigger Components
Create Triggers
Trigger properties
Trigger Editors
Writing the Trigger Code
Built-in Subprograms in Triggers
Built-in Definitions in the Form Builder
Debugging Triggers
Confidential
143
Objective
At the end of this chapter, you will be able to:
y Describe triggers
y Know about the characteristics of Trigger
y Learn different Trigger components
y Create Triggers
y Understand Trigger properties
y Describe Trigger editors
y Write the Trigger code
y Know built-in subprograms in Triggers
y Learn about built-in definitions in the Form Builder
y Debug Triggers
Confidential
144
Introduction to Triggers
Triggers are one of the most important features of forms. They are used to
add functionality to forms. A trigger is a PL/SQL code that is executed
when an event occurs. This PL/SQL code adds functionality to your
application.
Trigger Characteristics
The trigger name defines what event will invoke it. For example, a WHENBUTTON-PRESSED trigger executes its code each time the user clicks the
button to which the trigger is attached. The Form Builder defines a wide
range of events with which you can associate a trigger. These events can
be classified as:
Query related events
y Validation events
y Navigation events
y Mouse related events
y Key related events
y Error and message events
The Triggers you write in the Form Builder are different from those that
you write in the database. The trigger attached to a particular form
module belongs only to the same form module (any event in other forms
will not invoke that trigger).
Trigger Components
Trigger components comprise the following:
y Scope
y Type
y Code
Trigger Scope
Triggers work depending on the scope they have. The scope of the trigger
depends on its position in the form object hierarchy, that is, the type of
object under which you create the trigger. The three levels in form
hierarchy are:
Form Level
y Block Level
y Item Level
Depending on the levels of hierarchy, we have following triggers:
Confidential
145
Trigger Types
Fire when
An event occurs
across the entire
form.
An event occurs
in the current
block.
An event occurs
in the current
item
Confidential
146
Form Level
Event
Block Level
txtMemID
dbMember
txtFirstName
txtLastName
txtAddress
Event
Block Level
dbBook
Event
Description
Confidential
147
Description
The trigger will fire after firing the same trigger at the
next higher level
On-Message
Form
Level
On-Message
Item
Level
On-Message
Even
Trigger types
Triggers are divided according to their type and scope. The
trigger type defines the type of event that fires it.
According to their availability, triggers are classified as:
y Built-in
y User-named
Confidential
148
NOTE
All
Allthe
thebuilt-in
built-intrigger
triggernames
namesalways
alwayscontain
containaahyphen
hyphen((-).
).For example:
For example:
WHEN-BUTTON-PRESSED
WHEN-BUTTON-PRESSED
Trigger prefix
Description
KEYON-
PREPOSTWHEN-
Trigger code
The trigger code defines the action to be performed when the trigger fires.
Trigger code is an anonymous PL/SQL block in the PL/SQL Editor.
When writing a trigger you could:
y Make a call to the built-in subprograms and packages, which are part of
Forms Developer.
Points to remember while using SQL statements in a trigger are:
Confidential
149
Create Triggers
The purpose of creating a trigger is to add functionality to
the existing triggers.
Selecting Triggers in the Form Builder
The built-in list of the triggers are selected by:
Confidential
150
Confidential
151
2. Select Program-> Smart trigger. This creates icon on the toolbar. The list
of triggers is displayed as shown in the following figure.
3. Choose the appropriate trigger from the list of triggers that has been
invoked.
4. The PL/SQL Editor is invoked, where you can write the trigger code.
Using the Layout Editor
The steps to access the trigger from the Layout Editor are:
1. In the Layout Editor, select the object and right click the mouse to display
the popup list. Select PL/SQL from the popup list.
2. This will invoke a list of triggers. Choose the appropriate trigger in it.
3. This will invoke a PL/SQL Editor where you can write the trigger code.
Confidential
152
Trigger properties
Triggers have relatively few properties. The trigger name defines when it
is invoked and the trigger code defines its functionality. The screen grab
given below, shows you the trigger Property Palette.
The properties of the trigger are categorized into mainly two types:
y General
y Functional
The table below gives you the General properties of the trigger and their
functionality:
Property Name
Na
Function
To give an internal name to the trigger.
Subinformation
Cts
Confidential
153
Property Name
Function
Trigger style
Trigger text
Execution Hierarchy
Trigger Editors
The Trigger Editor is a tool to edit the code of a trigger. It can be used to
add, modify or delete the trigger code. There are two types of editors that
are available with the Forms Builder.
PL/SQL Editor
y Automatic indenting
y Syntax highlighting
y Text manipulation by dragging and dropping
y Unlimited undo and redo
Confidential
154
y Creation of four views of the current program unit in the PL/SQL Editor
by using split bar buttons as shown below
y Display and copy the PL/SQL constructs and built-in subprograms into the
editor using the Syntax Palette. This reduces coding time.
The diagram below shows you the Syntax Palette and the use of it:
Confidential
155
The above diagram shows the working of the Syntax Palette. When you click
on Insert button of the Syntax Palette, the basic PL/SQL construct that you
select will be copied on to your PL/SQL Editor. Similarly, you can make use of
the Built-in subprograms.
y You can do the global search and replace the text string or expressions in
your PL/SQL Editor. Steps involve in searching and replacing the text strings
and expressions are:
1. Invoke the Find and Replace in Program Units dialog box by selecting Edit> Find and Replace PL/SQL from the menu.
2. Type the character string that you need to search in the PL/SQL Editor in
Find What text field.
5. Type the character string that is to be replaced with the old text in
Replace With text field.
a. Click on the Find All button to find text strings that are there in the code
mentioned in the Find What text field.
b. Click on the Replace All button to replace the old text with the new text
mentioned.
c. The following screen grab shows you the Find and Replace functionality
provided in the Program Units dialog box:
Confidential
156
NOTE
Modified text in triggers needs to be recompiled.
Compiling triggers with SQL statements need to have
database connection.
Confidential
157
5. Select the Trigger node under it and click the Create icon. The Database
Trigger Editor will be displayed on your screen.
6. In the Database Trigger Editor, click the New button to create the new
trigger. Write the code of the trigger in the trigger body pane of the
Database Trigger Editor.
Given below is the database trigger editor:
y An executable section
y An exception handling section
The declaration and exception handler sections are optional. If your trigger code
does not require the defined variables, you need not include the BEGIN and END
keywords.
Variables in Form Builder
Two types of variables used for storing values are:
y Form Builder variables: The Form Builder variables are not declared in the
DECLARE section. The Form Builder maintains them. They are known as
external variables and need to be prefixed with a colon (:) to distinguish
them from PL/SQL objects.
Types of Form Builder variables are listed below in the following table:
Confidential
158
Form Builder
Variable Types
Syntax
Scope
Use
Item
:block_name.item_name
Global
:GLOBAL.variable_name
All modules in
current session.
Storing session-wide
character data.
System
:SYSTEM.variable_name
Parameter
:PARAMETER.name
y Restricted built-ins: These built-ins are allowed only in certain triggers and
subprograms.
Confidential
159
Package
Use
DDE
DEBUG
EXEC_SQL
OLE2
ORA_FFI
ORA_NLS
ORA_PROF
TEXT_IO
TOOL_ENV
TOOLS_ERR
TOOL_RES
VBX
WEB
trigger or
The following table shows the useful built-ins for adding functionality to items:
Confidential
160
Built-in Subprograms
Description
EDIT_TEXTITEM procedure
ENTER_QUERY procedure
EXECUTE_QUERY procedure
EXIT_FORM procedure
GET_ITEM_PROPERTY function
GO_BLOCK procedure
GO_ITEM procedure
HIDE_VIEW procedure
LIST_VALUES procedure
MESSAGE procedure
SET_ITEM_PROPERTY
procedure
SHOW_ALERT function
SHOW_EDITOR function
SHOW_LOV function
SHOW_VIEW procedure
Confidential
161
Debugging Triggers
Triggers are checked for errors in logic and syntax like any
other PL/SQL blocks.
Debugging Process
You can debug the triggers in the following ways:
y Compiling: Syntax errors and object reference errors are recorded when
you compile the trigger. These errors can be rectified or corrected in the
PL/SQL Editor before you run the trigger.
Click the Run Form Debug button in the Object Navigator, or select
Debug->
Debug Module from the main menu. This builds and also runs the form
module automatically.
The PL/SQL Debugger is used to:
The following screen shows the PL/SQL Debugger and its components:
Confidential
162
Confidential
163
6. PL/SQL Packages Panel: This panel is used only to browse and examine
the PL/SQL packages which are been instantiated while executing the
form.
7. Global and System Variables Panel: This Panel displays the current
system and global variables and their values used in the form module.
Running the Form Module using the Debugger
1.
2. As it encounters the breakpoint set in the executable part of the code, the
debug
console blinks at the bottom of the task bar in your system.
3. PL/SQL debugger enables us to step the program unit using various
buttons:
Step out: Complete the current subprogram and steps to the next
calling program.
Step Over: Takes the control to the next statement without stepping
into a nested subprogram.
Confidential
164
Summary
In this chapter, you have learnt that:
The trigger type defines the type of event that fires it. According to their
availability, triggers are classified into built-in and User-named triggers.
Smart triggers are the one, which are more appropriate to the specific
level.
The trigger name defines when it is invoked and the trigger code defines
its functionality.
The Trigger Editor is a tool to edit the code of a trigger that can be used to
add, modify or delete the trigger code.
The PL/SQL Editor has Automatic indenting and syntax highlighting, etc.
The Database Trigger Editor is used to edit and create a database trigger.
You can debug the triggers by compiling and invoking the PL/SQL
Debugger etc.
Confidential
165
Lab Exercise
Perform the following on BRANCHXX Form
1. Add functionality to the push buttons created in the TOOLBAR_BRANCH
canvas.
When the Image button is clicked it should work as Toggle button i.e;
o
When the button is clicked, the image item should disappear and the
label of button should change to Image on; when the button is clicked
again, the image item should appear and the label should change to
image off dynamically.
3. Make a Provision for the user to exit the form using close button on window.
4. Write functionality such that
o
IF GET_ITEM_PROPERTY('CONTROL.image',VISIBLE)='TRUE' THEN
SET_ITEM_PROPERTY('CONTROL.image', VISIBLE, PROPERTY_FALSE);
SET_ITEM_PROPERTY('CONTROL.image_off',LABEL,'Image On');
ELSE
SET_ITEM_PROPERTY('CONTROL.image', VISIBLE, PROPERTY_TRUE);
SET_ITEM_PROPERTY('CONTROL.image_off',LABEL,'Image Off');
END IF;
Confidential
166
Compile and run it. Press the Image button and test that Image is
not displayed.
Now run the form in Debug mode by setting a break point in the
When-Button Pressed trigger of the IMAGE button.
Test the importance and how much it is helpful to identify the errors
of running the form in debug mode
Confidential
in
the
code
to
Images
of
167
Chapter 10
Confidential
168
Objective
At the end of this chapter, you will be able to:
Confidential
169
Confidential
170
Confidential
171
Check Boxes
When a checkbox gets selected or deselected, the value associated with that
checkbox is changed. CHECKBOX_CHECKED function gives a Boolean value
indicating the state of the given check box.
The trigger used to provide additional functionality to check boxes is WHENCHECKBOX-CHANGED trigger. This trigger fires when the state of a check box is
changed, either by using the keyboard or clicking it with the mouse. This trigger
can be defined at item, block or form level. For example, create a non-database
display item diStatus labeled Status in ControlBlk of frmLib. Write a WHENCHECKBOX-CHANGED trigger that would display the value Married in diStatus
when the checkbox is checked and the value Unmarried when the checkbox is
unchecked.
Radio Buttons
In a radio group, only one radio button can be selected. The trigger used to
provide additional functionality to radio buttons is WHEN-RADIO-CHANGED
trigger. This trigger fires when a radio button is selected or deselected in a radio
group, either by using the keyboard or by clicking with the mouse. This trigger
can also be defined at item, block or form level.
For example, by selecting a radio button, the user can change the value of the
radio group item.
Example for When-Radio-changed:
declare
n number;
begin
if :member.nage between 5 and 13 and :member.cgrade !='A' then
n:=show_alert('Grade');
:MEMBER.CGRADE:='A';
ELSIF :member.nage between 14 and 20 and :member.cgrade !='B'
then
n:=show_alert('Grade');
:MEMBER.CGRADE:='B';
ELSIF :member.nage between 21 and 50 AND :member.cgrade !='C'
then
n:=show_alert('Grade');
:MEMBER.CGRADE:='C';
Confidential
172
Confidential
173
Record Group
When a LOV is defined, it gets associated with a named record group by default.
A record group consists of rows and columns that are very much similar to the
database table. Using LOV, the user can scroll, select records that are stored in
the underlying record group.
An LOV can be invoked in two ways:
LIST_VALUES Built-in
SHOW_LOV Built-in
LIST_VALUES Built-in
LIST_VALUES built-in displays the list of values for the item with which an LOV is
associated. This built-in by default uses the NO_RESTRICT parameter. Form
Builder cannot use the automatic search and complete feature if the
NO_RESTRICT parameter is used. By automatic search and complete feature, we
mean that an LOV evaluates the current value of the text item (to which an LOV
is attached) as a search value. Form Builder automatically uses that value as if
the user had entered the value into the LOVs search field and pressed [List] to
narrow the list.
If the item value would narrow the list to only one value, Form Builder does not
display the LOV, but automatically reads the correct value into the field.
To see its usage, create a button pbListDisplay in ControlBlk of frmLib module
and label it as Display List of Values. Write the following code in the WHENBUTTON-PRESSED trigger to invoke lvBranch LOV:
LIST_VALUES;
Points to remember while using LIST_VALUES built-in are:
SHOW_LOV Built-in
SHOW_LOV displays the LOV at the specified coordinates
SHOW_LOV (lov_id LOV);
SHOW_LOV (lov_id LOV, x NUMBER, y NUMBER);
SHOW_LOV (lov_name VARCHAR2,x NUMBER, y NUMBER);
Where,
lov_id is the unique ID assigned to the LOV. FIND_LOV built-in is used to
return the ID to an appropriately typed variable.
lov_name is the name given to the LOV. The data type of the name is
VARCHAR2.
x specifies the x coordinates of the LOV.
y specifies the y coordinates of the LOV.
Confidential
174
:=
POPULATE_GROUP_WITH_QUERY('MEMBER_RG','SELECT
cmemberid
cfirstname NAME FROM member where nage between 35 and 70');
ID,
SYNCHRONIZE;
LIST_VALUES;
IF :global.id IS NOT NULL THEN
:member.cmemberid := :global.id;
:member.cfirstname := :global.name;
ELSE
:global.id := NULL;
END IF;
END;
Confidential
175
Format
Image Item
BMP
Read/Write
JFIF
Read/Write
PCX
Read Only
PICT 1 & 2
Read/Write
GIF
Read/Write
CALS
Read/Write
PCD
Read Only
RAS
Read/Write
TIFF 4, 5 & 6
Read/Write
y Graphic Objects: A graphic object is a static image imported from the file
system or database. Such objects are generally used as background
pictures.
y WHEN-IMAGE-ACTIVATED
y WHEN-IMAGE-PRESSED
READ_IMAGE_FILE Procedure
Reads an image of the given type from the given file and displays it in the form
builder image item.
The syntax is:
READ_IMAGE_FILE (file_name VARCHAR2,file_type VARCHAR2, item_id
ITEM);
READ_IMAGE_FILE(file_name VARCHAR2,file_type VARCHAR2,item_name
VARCHAR2);
Where,
file_name is the valid file name.
file_type is the valid image file type:
RAS, TIFF, or TPIC.
item_id is assigned to the image item when the Form builder creates it.
Use the FIND_ITEM built-in to return the ID to an appropriately typed
variable.
Confidential
176
Confidential
177
SET_TREE_PROPERTY Procedure
This procedure sets the value of the indicated hierarchical tree
property.
Confidential
178
Methods
Properties
Events
To communicate with the Java Beans we use a package called FBEAN package.
This package contains Forms built-ins that are used to communicate with
JavaBeans in PL/SQL.
Most of the built-ins take some common arguments:
y Item Instance: It acts like a reference to which instance of item should the
bean contain. This is applied only where the Bean Area is part of a
multirow block and more than one instance of the Bean Area is displayed.
You can use the value ALL_ROWS (or FBEAN.ALL_ROWS) for the Item
Instance value to specify that command is to be applied to all of the
instances of this Bean Area in the block.
Confidential
179
Parameters
GET_PROPERTY
ITEM,INSTANCE,PROPERTY_NAME
returns VARCHAR2
SET_PROPERTY
ITEM,INSTANCE,PROPERTY_NAME, VALUE
INVOKE
ITEM,INSTANCE,METHOD_NAME[,ARGUMENTS]
ENABLE_EVENT
ITEM,INSTANCE,EVENT_LISTENER_NAME,
SUBSCRIBE
REGISTER_BEAN
ITEM,INSTANCE,BEAN_CLASS
(The last argument is the full class name of the bean,
such as 'oracle.forms.demos.beans.ColorPicker')
Bean Deployment:
As the bean itself is a Java class or set of Java class files separate from the form
module, you need to know where to put these files.
Confidential
180
CODEBASE
and
ARCHIVE
parameters
are
set
in
the
Respond to an Event:
At run-time when the user tries to communicate with a Java Bean, an event error
occurs. In order to escape from this error, forms will fire When-Custom-ItemEvent trigger if we use FBEAN.ENABLE_EVENT to register a listener for the event.
The code to be written in this trigger is:
:SYSTEM.CUSTOM_ITEM_EVENT and :SYSTEM.CUSTOM_EVENT_PARAMETERS
These two variables contain name of the event and information the bean is
sending to the form.
The steps involved to communicate with the bean are:
1. The user clicks the bean area for a Calendar bean. This bean area has a
visible component on the form that looks like a button. The label is set
to the hire date for an employee.
2. The Calendar bean is invoked and displays a calendar initially set to the
employees hire date.
3. The user changes the date on the bean by picking a new month and
year, and then clicking on a day, which initiates the DateChanged
event.
4. The When-Custom-Item-Event trigger obtains the changed date and
assigns it back to the employee hire_date item, also changing the label
on the bean area button.
Confidential
181
newDateVal varchar2(80);
newDate date := null;
begin
hBeanEventDetails := get_parameter_list
(:system.custom_item_event_parameters);
eventName := :system.custom_item_event;
if (eventName = 'DateChange') then
get_parameter_attr(hBeanEventDetails,
'DateValue', ParamType, newDateVal);
newDate := to_date(newDateVal,'DD.MM.YYYY');
end if;
:employees.hire_date := newDate;
end;
The preceding example is for a bean that uses hand-coded integration. If you use
the FBEAN package to integrate the bean, the name of the value passed back to
the form is always called DATA.
For example:
get_parameter_attr (:system.custom_item_event_parameters,
'DATA', paramType, eventData);
(Where paramType and eventData are PL/SQL variables you declare in the WhenCustom-Item-Event trigger, like paramType and newDateVal in the preceding
example).
y Working message: This message informs the user that the form is
currently processing. Such type of message is displayed on the message
line. The system variable used to suppress this message is
SUPPRESS_WORKING.
y Error message: This message informs the user of the error that prevents
the current action. It is displayed on the message line by default. These
errors can be suppressed using the ON-ERROR trigger.
y Informative message: This message informs the user of the current state
of processing or context sensitive information. These messages can be
suppressed using the ON-MESSAGE trigger.
y Application alert: These alerts are designed as part of application and are
issued to the user for a response using the SHOW_ALERT built in.
Confidential
182
y Application message: These are the messages that are built into an
application using the MESSAGE built-in.
Built-in Function
FORM_SUCCESS
Returned Value
True: When action is successful
False: Occurrence of an error or a fatal error
FORM_FAILURE
True: Action is not successful and some error that is not fatal
has occurred
False: Either action is successful or some fatal error has
occurred
FORM_FATAL
To understand how the built-ins mentioned above could be used, consider the
following example:
In the ControlBlk of frmLibTrans module, a button pbGoBranch labeled
Branch is created. The following code is written in the WHEN-BUTTON-PRESSED
trigger:
GO_BLOCK (BRANCH);
EXECUTE_QUERY;
This trigger works fine so long as Branch block exists. However, if Branch block
does not exist or is not enterable then GO_BLOCK built-in procedure would fail.
Confidential
183
to
Branch
Block
failed
due
to
an
END IF;
Built-in
Functions
Returned Value
ERROR_TYPE
ERROR_TEXT
Description of an error
ERROR_CODE
Number of an error
Suppressing Messages
To control the messages while using the form builder applications, use:
Confidential
184
Level
Description
10
15
20
25
>25
Confidential
185
Identify both Form Builder and Oracle server errors and take
corrective actions based on the errors that have occurred.
ERROR_CODE
ERROR_TEXT
ERROR_TYPE
DBMS_ERROR_TEXT
DBMS_ERROR_CODE
For example, to customize the standard system message for error 40202
(field must be entered), write the following code:
If ERROR_CODE = 40202 THEN
MESSAGE (Fill the field Tran ID for a transaction);
ELSE
MESSAGE (ERROR_TYPE || - || TO_CHAR (ERROR_CODE) || : ||
ERROR_TEXT);
END IF;
RAISE FORM_TRIGGER_FAILURE;
2. ON-MESSAGE trigger: This trigger suppresses informative messages with
customized messages. This trigger is used to:
To get the information about why the specific message occurs use the
following built-in functions:
MESSAGE_CODE
MESSAGE_TEXT
MESSAGE_TYPE
Confidential
186
Alerts
An alternative method used to communicate with users is Alerts. Since alerts are
displayed in a modal window, they force users to respond to the message before
processing can continue.
Alerts are used to:
Create the alert at design time and set its required properties
y STOP
y CAUTION
y NOTE
Each style denotes a different level of message severity. A unique icon that
displays in the alert window represents message severity visually.
The following screens show the STOP, CAUTION, and NOTE alert styles:
Confidential
187
There are numerous built-in alerts that display pre-defined messages. The user
can create custom alerts that display in response to application-specific events.
When an alert displays a message due to the occurrence of some event, the user
should respond by selecting any one of the predefined alert buttons. If any of
the buttons is selected then the alert is immediately dismissed.
Creating an Alert
To create an alert:
1. Click the Alerts node of frmLib module in the Object Navigator
2. Click the Create button in the Toolbar.
3. Double-click the alert object icon to display the Property Palette.
4. Define the name in the Property Palette say alExit.
5. Set the Alert Style property either to STOP, CAUTION, or NOTE.
6. Set the Message property by entering the message you want the alert to
display at runtime such as Do you want to close this form.
7. Give the names to one or more buttons by entering a text label in the
Button1 Label, Button 2 Label, and Button 3 Label fields.
8. Choose the Default Alert Button, either Button 1, Button 2, or Button
3.
Confidential
188
NOTE
The default text labels are OK for Button 1 and Cancel for Button.
At least one button must have a label. Buttons that do not have
labels are not displayed. Buttons are displayed in the alert in the
order that they appear in the Property Palette.
SHOW_ALERT Function
This function describes how to display an alert at run time and get the user
response to the calling trigger. It gives a number that indicates which of the
button the user has pressed in response to the alert.
The syntax is:
SELECTED BUTTON: = SHOW_ALERT (ALERT_NAME);
Where,
ALERT_NAME: The name of an alert. An ALERT_ID can also be used in
place of ALERT_NAME.
For example when the user attempts to close the form the alert alExit created in
frmLib can be invoked. If the user says OK then the EXIT_FORM is called to
close the form
IF SHOW_ALERT ('alExit') = ALERT_BUTTON1 THEN
EXIT_FORM;
END IF;
Confidential
189
Controlling Alerts
At run time, using the SET_ALERT_PROPERTY built-in procedure, you can change
an alert message. Once an alert message is changed, the user can reuse the
same Alert object, but display a different message each time it is invoked.
SET_ALERT_PROPERTY Procedure
This procedure changes the message text for an existing alert.
The syntax is:
SET_ALERT_PROPERTY (alert_id ALERT, property NUMBER, message
VARCHAR2);
SET_ALERT_PROPERTY
(alert_name
message
VARCHAR2);
VARCHAR2,property
NUMBER,
Where,
alert_id is assigned to an alert when the Form Builder creates it.
alert_name is the name of an alert.
property is the specific alert property that the user set:
SET_ALERT_BUTTON_PROPERTY Procedure
This procedure replaces the label of one of the buttons in an alert.
The syntax is:
PROCEDURE
NUMBER,
SET_ALERT_BUTTON_PROPERTY(alert_id
ALERT,
button
Confidential
190
Confidential
191
Summary
In this chapter, you have learnt that:
o
There are various item interaction triggers that are fired when
users interact with input items.
There are two types of triggers to use list items, like WHEN-LISTACTIVATED trigger and WHEN-LIST-CHANGED trigger.
A LOV is a scrollable window that consists of a single or a multicolumn selection list cannot be dismissed unless the user selects a
value from the list or chooses the Cancel button. When a LOV is
defined, it gets associated with a named record group by default.
Two types of triggers are fired when the user interacts with an
image item are WHEN-IMAGE-ACTIVATED and WHEN-IMAGEPRESSED.
Some
system
variables
for
suppressing
messages
are
SYSTEM.MESSAGE_LEVEL, ON-ERROR and ON-MESSAGE triggers
and SYSTEM.SUPPRESS_WORKING.
Confidential
an
action
performed
is
192
Lab Exercise
Write a trigger for Image item such that when the image item is
clicked an image should be displayed.
Populate the library staff data into the hierarchical tree item.
Populate the values into the LOV of cbranchid of Branch block and
cmemberid of Transaction block using the show_lov built-in and
list_values built in respectively.
Use only the above alert for save and exit, write code such that this
single alert is used for both actions. The information displayed by
the alert should vary respectively.
Alter
the
WHEN-BUTTON-PRESSED
trigger
on
CONTROL.Exit_Button that uses Alert to ask the operator to
confirm saying Exit from the application?.
Alter
the
WHEN-BUTTON-PRESSED
trigger
on
CONTROL.Save_button to use the same alert to ask operator to
confirm saying Do you want to save the changes?.
Confidential
193
Chapter 11
Confidential
194
Objective
At the end of this chapter, you will be able to:
Confidential
195
Validation of Items
When performing the default validation on any item, the Form Builder makes sure
that the item follows all the rules of validation for that item. Defining appropriate
triggers can enhance the default validation. When we define the Validation Unit
form property, the user can also control the extent and frequency of validation in
a form.
Item level: The status of each item is recorded by the Form Builder to
ascertain whether they are currently valid or not. In case an item has been
changed without being yet marked as valid, then to ensure that the items
value confirms to the items properties, the Form Builder performs
standard validation checks. These checks are performed before the firing
of any validation triggers defined for the items. Following are the standard
checks performed:
Data type.
Format mask.
Record level: Record validation consists of validating all the items in the
record after leaving the record. If the record is not valid, then the status of
each item in the record is checked for their validity after which a validation
trigger defined for the record (if any) fires. Only when a record passes
these checks, its status is set to valid.
Confidential
196
Form Level
Block Level
Record Level
Item
Level
The above diagram represents the four levels at which the validation occurs. The
item level is the lowest level.
Control Validation
Validation occurs when the user navigates out of the validation unit by pressing
certain function keys or when a trigger executes certain built-in subprograms
such as:
Double-click the Form Module icon in the Object Navigator to display the
Property Palette.
Under the Database node, set the Validation Unit to the desired status,
as shown below.
Confidential
197
Validation Unit
The Validation Unit property determines the scope of validation. It defines the
maximum amount of data that can be entered in the form before Form Builder
starts validation. The validation unit corresponds to a unit of data in the forms. It
can be set to any of the following values in the Property Palette:
Default
Item
Record
Block
Form
The property is set as Item by default. Item level validation unit indicates that
changes are validated when the user navigates out of the changed item. This
ensures that both standard validation and firing of the validation triggers can be
done immediately.
Confidential
198
At other levels (record, block, and form), these checks are put off until user
navigates out of that unit. Validation unit is set above the item level:
Under the List of Values (LOV) node, set the Validate from List
property to Yes.
When Validate from List property is set to Yes, Form Builder compares
the current value of the text item with the values in the first column that
are displayed in the LOV.
Following are some of the events that occur, depending on the circumstances:
By default, if any one of the values of first column of the LOV matches
with the value of the text item, then the validation succeeds, else the LOV
is not displayed and the processing is continued.
If the value of the text item matches a partial value of the LOV value,
then the full column value of the LOV is returned to the item (if the item is
defined as the return item in the LOV) and the item passed through the
validation phase.
If the value of the text item matches multiple records in the LOV, then the
LOV is displayed to enable the users to choose the appropriate value.
If the value in the text item does not match with one of the values, which
are there in the first column of the LOV, then the Form Builder displays
the LOV and considers the text item value as the search criteria to reduce
the list.
If the user selects a value from the LOV, then Form Builder dismisses
the LOV and specifies the selected value to their corresponding return
items.
Whenever an LOV is used for validation, Form Builder marks the text
item as valid if the end user selects a value from the LOV.
Confidential
199
Confidential
200
END IF;
It is a common practice to process input to an item using a When-Validate-Item
trigger. The trigger itself is processed on the Forms Services. Even validation that
occurs with a format mask on an item involves a trip to the middle tier.
You should consider using Pluggable Java Components (PJCs) to replace the
default functionality of standard client items, such as text boxes. Then validation
of items, such as the date, maximum or minimum values, is contained within an
item. This technique opens up opportunities for more complex, applicationspecific validation, such as automatic formatting of inputfor example, telephone
numbers with the format (XXX) XXX-XXXX. Even a simple numeric format is
enforced instantly, not allowing alphabetic keystrokes to be entered into the item.
This validation is performed on the client without involving a network round trip,
thus improving performance. For example, the Key Filter PJC does not allow the
operator to enter an alphabetic character into the Quantity item. The only
message that is displayed on the message line is the items Hint.
Pluggable Java Components are similar to JavaBeans, and in fact, the two terms
are often used interchangeably. Although both are Java components that you can
use in a form, there are the following differences between them:
Use
ENTER
GET_ITEM_PROPERTY
of
an
item
with
SET_ITEM_PROPERTY
of
an
item
with
Confidential
201
Built-ins
Use
CLEAR_BLOCK
CLEAR_FORM
EXIT_FORM
SET_FORM_PROPERTY
VALIDATE
Validation
is
performed
for
the
NOTE
If the default scope is changed using SET_FORM_PROPERTY
(Validation Unit) and the VALIDATE built-in (DEFAULT_SCOPE) is
called, then the default scope is overridden. In this case, Form
Builder will not validate at the default scope but validates at the
scope defined by SET FORM PROPERTY built-in.
Confidential
202
SELECT CBOOKNAME
INTO
:TRANSACTION.CBOOKNAME
FROM
BOOK
WHERE
CBOOKID = :TRANSACTION.CBOOKID;
While entering the Book ID, if the value is not found in the Book table, the
NO_DATA_FOUND exception is raised. As a result, the trigger fails as there is no
exception handler to handle it. In such a case, the user receives the following
message:
FRM-40735: <trigger type> trigger raised unhandled exception <exception>
Validation Status
The first step in validating items and records is checking the status. Status
checking means whether the form should perform any other additional validation,
such as standard validation checks.
New: When a record is created, Form Builder marks every item in that
record as a new item. This is true even if Form Builder populates an item
with a default or copied value
When any item in a new record is altered, the Form Builder marks all
items in the record as changed records.
Confidential
203
NOTE
If an item status is New or Changed, then the validation
continues. If an item's status is valid, then the item
validation stops.
When the Form Builder successfully validates all the changed items in a
changed record (changing their statuses to Valid). The record remains
as changed record if all items in a changed record do not pass
validation.
When the Form Builder successfully validates all new items in a new
record.
NOTE
If a record status is changed, validation continues. If a
record's status is New or Valid, record validation stops.
Query Processing
Triggers are linked with a query in any one of the following ways:
Queries Triggers fire due to the query. (PRE-QUERY trigger and POSTQUERY trigger, are the two such types of trigger)
Triggers that fire in the Enter Query mode if the Fire in Enter Query
Mode property of the trigger is enabled.
For example, WHEN-VALIDATE-ITEM, WHEN-VALIDATE-RECORD, ONERROR, ON-MESSAGE, etc. are initiated, either by the user or by any
built-in subprogram, the following events take place:
28. A PRE-QUERY trigger (if defined) fires in the Enter Query mode.
Confidential
204
Base_Column,
INTO
: Base_Item,
FROM
Base_Table
WHERE
Default_Where_Clause
AND
(Query_Where_Condition)
ORDER BY
Default_Order_By_Clause | Query_Where_Order_By
(This | vertical bar indicates that either of the two can be present).
Confidential
205
NOTE
A base table block is a block that is related with a specific
database table or view. An item, which is directly related
to a base table column, is a base table item.
Trigger
Built-ins
ON-CLOSE
A query is closed.
ON-COUNT
COUNT_QUERY
ON-SELECT
SELECT_RECORDS
ON-FETCH
FETCH_RECORDS
PRE-SELECT
POST-SELECT
Confidential
206
Set preferences:
Set properties:
Double click the Data Block icon to display the Property Palette.
Under the Records category, set the Query Array Size property to a
number that represents the number of records in the array for array
processing.
This property describes whether all records matching the query condition
should be retrieved or not.
PRE-QUERY trigger
POST-QUERY trigger
Confidential
207
Check the query conditions, and if the conditions are not fulfilled then the
query fails.
Add more conditions to the query for assigning values to the base table
items.
For example, place the PRE-QUERY trigger on the Book block in the
frmLibTrans that permits queries only if there is a restriction on the
cBookID, cBookName or cAuthorName.
IF (:BOOK.CBOOKID) ||(:BOOK.CBOOKNAME) ||(:BOOK.CAUTHORNAME) IS
NULL
THEN
MESSAGE
RAISE FORM_TRIGGER_FAILURE;
END IF;
=:
Confidential
208
KEY_triggers
ON-ERROR
ON-MESSAGE
WHEN-triggers
WHEN-DATABASE-RECORD
WHEN-IMAGE-ACTIVATED
WHEN-NEW-BLOCK-INSTANCE
WHEN-NEW-FORM-INSTANCE
WHEN-CREATE-RECORD
WHEN-REMOVE-RECORD
WHEN-VALIDATE-RECORD
WHEN-VALIDATE-ITEM
ENTER QUERY MODE indicates that the form is currently in Enter Query
mode.
Confidential
209
ORDER_BY
QUERY_ALLOWED
QUERY_HITS
CASE_INSENSITIVE_QUERY property determines whether the caseinsensitive queries on the text item can be performed or not.
CASE_INSENSITIVE_QUERY
QUERYABLE
QUERY_ONLY
Confidential
210
ELSE
ENTER_QUERY;
END IF;
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
y
Confidential
ABORT_FETCH
BLOCK_MENU
CALL_INPUT
CLEAR_BLOCK
CLEAR_FORM
COMMIT_FORM
CREATE_QUERIED_RECORD
CREATE_RECORD
DELETE_RECORD
DOWN
DUPLICATE_RECORD
FETCH_RECORDS
FIRST_RECORD
GO_BLOCK
GO_RECORD
INSERT_RECORD
LAST_RECORD
LOCK_RECORD
LOGON
LOGON_SCREEN
LOGOUT
NEW_FORM
NEXT_BLOCK
NEXT_RECORD
NEXT_SET
POST
PREVIOUS_BLOCK
PREVIOUS_RECORD
SCROLL_DOWN
SCROLL_UP
SELECT_RECORDS
UP
211
Summary
In this chapter, you have learnt that:
y When we define the Validation Unit form property, the user can also control
the extent and frequency of validation in a form.
y The Validation Unit property determines the scope of validation, which is the
maximum amount of data that can be entered in the form before Form Builder
starts validation.
y Validation triggers are fired when Form Builder validates data in an item or
record. Form Builder performs validation checks during navigation that occurs
due to operator input, programmatic control, or default processing, such as a
commit operation.
y If the user enters an invalid value in the item, while populating other items, a
matching row with the corresponding result will not be found and the SELECT
statement would raise some exception.
y The three states for an item validation are new, changed and valid.
y Form Builder processes one record at a time where as array processing group
of records can be processed at one time to increase the performance by
reducing the network traffic.
y Query triggers are fired just before and after the query is executed in a block.
The two types of query triggers are PRE-QUERY trigger and POST-QUERY
trigger.
y Fire in Enter Query Mode property checks that whether a trigger is fired when
a related event occurs in Enter Query mode.
y System variables and built-ins can be used to get control over the queries that
are given by you.
y There are certain built-ins used for obtaining query information like the
GET_BLOCK_PROPERTY, RECORDS_TO_FETCH property etc.
Confidential
212
Lab Exercise
1. Ensure that no data is allowed other than the values present in the LOV
associated with cbranchid.
2. In BRANCHXX module write a trigger such that when the user enters return
date less than the issue date into the TRANSACTION table, the field must
display the error message that Return date cannot be less than the issue
date.
3. Write trigger codes such that the Grade should get selected accordingly to the
age entered in the MEMBERS block.
Lowerage
Upperage
Grade
13
14
20
21
50
50
100
4. Create two display items in the TRANSACTION block and name them as
firstname and lastname.
5. Write a trigger at TRANSACTION block level such that the names of the
members executed in the MEMBERS block are to be displayed in the display
items according to the current cursor record.
6. Write a trigger in BOOKXX at the Book block to query the record by bookid or
bookname or authorname.
Confidential
213
Chapter 12
Navigation
Navigation and Navigational Unit
Navigation Properties
Types of Navigation
Using Navigation Triggers
Built-in Subprograms
Confidential
214
Objective
At the end of this chapter, you will be able to:
Confidential
215
Navigational Unit
An invisible internal object that determines the navigational state of a form is
known as a navigational unit. The navigational unit helps keep track of the object,
which is currently the focus of a navigational process. The navigational unit could
be any object occurring in the following hierarchy:
Navigation Properties
Navigation can be controlled at form, block and item levels by setting the
following navigation related properties:
y Mouse Navigation Limit: Specifies how far the user can navigate to with
the mouse. Mouse Navigation Limit property can be set to the following
levels:
Confidential
Form level allows the user to navigate to any item in the current
form (default setting).
SQL Star International Ltd.
216
Block level allows the user to navigate to only those items that are
within the current block.
Record level allows the user to navigate only to those items that
are within the current record.
Item level prevents the user to navigate out of the current item.
The following screen shows the default setting of Mouse Navigation Limit
property:
Same Record
Change Record
y Next Navigation Data Block: Specifies the block as the next navigation
block with respect to the current block.
217
The following screen shows the setting of Next Navigation Data Block
property:
y Enabled: Specifies whether an end user can use the mouse to manipulate
an item. The item gets grayed out when the property is set to No.
Confidential
218
y Next Navigation Item: Specifies the item as the next navigation item
with respect to the current item.
Confidential
219
Types of Navigation
Following are the two types of navigation:
y External Navigation: This navigation occurs when the user clicks any
item due to which a trigger is fired or by using function keys, due to which
the focus is moved from one object to another.
For instance, in frmLibTrans module, we have the input focus on the
Branch block and if the user clicks an item in the Book block, then the
focus moves to that block. This is called external navigation.
INTERNAL NAVIGATION
EXIT ITEM
EXIT RECORD
Next Record
EXIT BLOCK
ENTER BLOCK
ENTER RECORD
ENTER ITEM
Confidential
220
y Pre- and Post- triggers: These triggers fire as the Form Builder navigates
through different levels. These triggers fire in response to navigation
initiated by the user.
Pre-navigation Triggers
Pre-navigation triggers fire during navigation, that is, just before the entry to the
object specified. Following are the types of Pre-navigation triggers in the
sequence in which they fire:
y PRE-FORM trigger: It fires before the form starts up. This trigger is defined
at the form level. This trigger can be fired to perform the following tasks:
For example, to prevent the library clerk from entering any book issue
transaction details in the Transaction block before 10:00 a.m. and after 7:00
p.m., write the following code in the PRE-FORM trigger at form level of
frmLibTrans module:
IF USER= Clerk AND
BETWEEN 10 AND 19 THEN
MESSAGE
(Cannot
TO_CHAR
enter
(SYSDATE,
transaction
HH24)
details
at
NOT
this
hour.);
RAISE FORM_TRIGGER_FAILURE;
END IF;
y PRE-BLOCK trigger: This fires during navigation from one block to another.
This trigger is defined at block or form level. This trigger can be fired to
perform the following tasks:
Confidential
221
Obtain a value based on other items that are previously entered into
the same record.
For future references, record the current value of the text item.
(:SYSTEM.CURRENT_ITEM,
VISUAL_ATTRIBUTE,
Post-navigation triggers
Post-navigation triggers fire during navigation, that is, just after exiting the
object specified. Following are the types of Post-navigation triggers in the
sequence in which they fire. POST-FORM trigger fires when a form exits. This
trigger is defined at form level. This trigger can be fired to perform the following
tasks:
POST-BLOCK trigger: This fires when the focus moves off the current
block. This trigger can be defined at block or form level. This trigger
can be fired to validate the current record of the block.
For example, the following code written in POST_BLOCK trigger (for
Transaction block of frmLibTrans module) calculates the average
fine and the number of members who have paid fines when users leave
the block: (To do so, create two non-database items and label them as
Avg Fine and Count Fine and place them in ControlBlk)
SELECT AVG (nFine)
INTO :AvgFine
FROM Transaction;
SELECT COUNT(nFine)
INTO :CountFine
FROM Transaction;
POST-TEXT-ITEM trigger: It fires during the exit from a text item. This
trigger can be defined at item, block or form level. This trigger is used
to calculate or change item values. For example, when you exit the
current item of Member block in frmLib module, its visual attribute
should be set to vattLibTrans as follows:
Confidential
222
SET_ITEM_PROPERTY
(:SYSTEM.CURRENT_ITEM,
VISUAL_ATTRIBUTE, vattLibTrans);
When-New-Object-Instance trigger
When-New-Object-Instance triggers fire immediately on navigating to the object
specified. Following are the types of When-New-Object-Instance triggers:
(Transaction,
INSERT_ALLOWED,
SET_BLOCK_PROPERTY
PROPERTY_FALSE);
(Transaction,
DELETE_ALLOWED,
SET_BLOCK_PROPERTY
PROPERTY_FALSE);
(Transaction,
UPDATE_ALLOWED,
END IF;
SET_BLOCK_PROPERTY
vattLib);
(Transaction,
CURRENT_RECORD_ATTRIBUTE,
ELSE
Confidential
223
SET_BLOCK_PROPERTY
vattLibTrans);
(Transaction,
CURRENT_RECORD_ATTRIBUTE,
END IF;
END IF;
Navigation Trap
When the Pre- and Post- navigation triggers fail, the internal cursor attempts to
return to the current item (SYSTEM.CURSOR_ITEM).
Navigation trap occurs when a Pre-navigation trigger fails and attempts to return
the logical cursor to its initial item. However, if the initial item has a Pre-TextItem trigger that also fails, then the cursor has nowhere to go, and a fatal error
occurs and the form exits.
Built-in Subprograms
There are certain built-ins that are used to initiate navigation programmatically.
They are:
Confidential
224
GO_FORM built-in navigates from the current form to the indicated target
form.
The syntax is:
GO_FORM (form_id FORMMODULE);
GO_FORM (form_name VARCHAR2);
Where,
form_id: specifies the ID assigned to the form when it is
instantiated at runtime.
form_name: specifies the name of the target form.
NEXT_SET built-in retrieves another set of records from the database and
navigates to the first record.
The syntax is:
NEXT_SET;
DOWN built-in navigates to the instance of the current item in the next
record.
The syntax is:
Confidential
225
DOWN
Confidential
226
Summary
In this chapter you have learnt that:
y Navigation occurs when the user or a trigger moves the input focus from
one object to another. You came to know about its properties along with
types of Navigation.
y You can navigate an object to either by the user-using [Tab] key during
default navigation, or by executing a navigational built-in procedure.
y Navigation can be controlled at form, block and item levels by setting the
following navigation related properties. First Navigation Block specifies
the block that the Form Builder navigates at form startup and Mouse
Navigation Limit specifies how far the user can navigate to with the
mouse.
y There are the two types of navigation called the External Navigation and
Internal Navigation.
Confidential
227
Lab Exercise
In BRANCHXX form module:
1. Dynamically set the navigation of the form such that if BRANCH block is the
default block, then change the navigation to TRANSACTION and revert back
the changes.
2. Assign functionality to the form such that except Scott if any other user logs
in, he should not be able to manipulate the data.
3. Create two visual attribute, name them as CURRENT_RECORD and VATTLIB.
o
Write functionality such that VATTLIB visual attribute is applicable for even
number of
record and CURRENT_RECORD visual attribute is applicable for
odd number of record.
4. Write a trigger such that the hierarchical tree item is populated that we have
created in the previous chapters.
5. Write functionality for cmemberid column such that when current cursor
position is in the cmemberid, the corresponding member image should be
displayed. ( gather some images and give them the memberid as names)
6. Prevent the library clerk from entering any book issue transaction details in the
Confidential
228
Chapter 13
Confidential
229
Objective
At the end of this chapter, you will be able to:
y Describe key triggers
y Redefine function keys
y Know various types of key triggers
y Define mouse-event key triggers
y Associating function keys with interface controls
y Understand mouse event triggers
Confidential
230
y Key triggers cannot be used to redefine function keys that are managed by
the terminal or Window Interface Manager (instead of Forms). Example of
such function keys is Clear Item, Left, Right, and Toggle Insert/ Replace.
y Key triggers can be defined at all the three levels: form, block, and item
level.
y Key triggers can include SELECT statements and built-in functions (both
restricted and unrestricted).
Confidential
231
Function
Key
Help
Display Error
Show Keys
Count Matching
Records
Duplicate Field/Item
Next Primary Key
Duplicate Record
Clear Record
Block Menu
Clear Block
New Record
Delete Record
Enter Query
Clear Form
Execute Query
Print
List Of Values
Accept
Cancel
Clear Field/Item
Delete Backward
Down
Edit
Exit
Left
[F1]
[Shift +F1]
[Control+F1]
[Shift+F2]
Next Block
[Shift+Pagedown]
[Down]
[Tab] or [Control+Tab]
Shift+F8
[Shift+Page Up]
[Up]
[Shift+Tab] or
[Shift+Ctrl+Tab]
[Enter]
[Page Down]
[Page Up]
[Ctrl+F1]
[Up]
Next Field/Item
Next Set of Records
Previous Block
Previous Record
Previous Field/Item
Return
Scroll Down
Scroll Up
Show Keys
Up
[F3]
[Shift+F3]
[F4]
[Shift+F4]
[F5]
[Shift+F5]
[F6]
[Shift+F6]
[F7]
[Shift+F7]
[F8]
[Shift+F8]
[F9]
[F10]
[Esc]
F5
[Del] or [Backspace]
[Control+L] or [Down]
[Control+E]
F4
[Left]
Confidential
232
The built-in functions and function key triggers associated with the above
mentioned function keys are:
Function keys
Built-in Functions
Function Key
Triggers
Accept
COMMIT_FORM
KEY-COMMIT
Enter Query
ENTER_QUERY
KEY-ENTQRY
Execute Query
EXECUTE_QUERY
KEY-EXEQRY
Block Menu
BLOCK_MENU
KEY-MENU
Clear Block
CLEAR_BLOCK
KEY-CLRBLK
Next Block
NEXT_BLOCK
KEY-NXTBLK
Previous Block
PREVIOUS_BLOCK
KEY-PRVBLK
Clear Form
Clear Record
Insert Record
Delete Record
CLEAR_FORM
CLEAR_RECORD
CREATE_RECORD
DELETE_RECORD
DUPLICATE_RECORD
KEY-CLRFRM
KEY-CLRREC
KEY-CREREC
KEY-DELREC
KEY-DUPREC
Confidential
233
Function keys
Built-in Functions
Function Key
Triggers
Duplicate Record
Next Set Of
Records
Previous Record
NEXT_RECORD
NEXT_SET
KEY-NXTREC
KEY-NXTSET
PREVIOUS_RECORD
KEY-PRVREC
Duplicate Item
DUPLICATE_ITEM
KEY-DUP-ITEM
Next Item
Previous Item
Scroll Down
Scroll Up
Down
Up
List of Values
Edit
Print
Exit
Help
NEXT_ITEM
PREVIOUS_ITEM
SCROLL_DOWN
SCROLL_UP
DOWN
UP
LIST_VALUES
EDIT
PRINT
EXIT_FORM
HELP
KEY-NEXT-ITEM
KEY-PREV-ITEM
KEY-SCRDOWN
KEY-SCRUP
KEY-DOWN
KEY-UP
KEY-LISTVAL
KEY-EDIT
KEY-PRINT
KEY-EXIT
KEY-HELP
Write a KEY-EXIT trigger at form level in frmLib module that will display the alert
alExit showing the message DO YOU WANT TO CLOSE THIS FORM?
SET_ALERT_PROPERTY ('alExit', ALERT_MESSAGE_TEXT,'DO YOU WANT
TO CLOSE THIS FORM?');
IF SHOW_ALERT ('alExit')=ALERT_BUTTON1 THEN
EXIT_FORM;
END IF;
The alert message is displayed as follows at runtime when the user tries to close
a form:
Confidential
234
A form level KEY-EXEQRY trigger execute queries sorted according to the library
members ages is written as follows:
Key-Fn Triggers
The triggers defined to supplement or change the functionality associated with
the logical runtime keys (F0 through F9) are known as Key-Fn triggers.
Confidential
235
Before Key-Fn triggers are defined, the database administrator must map the
logical keys to physical keys or key sequences. These triggers fire when the
physical key or key sequence is pressed.
Key-Others Trigger
The trigger used to disable function keys that are not relevant to your application
is known as KEY-OTHERS trigger. It can be associated with any key that can have
key triggers associated with them, but whose functionality is not currently
reprogrammed by any function key trigger.
y KEY-NEXT-ITEM
y KEY-PREV-ITEM
y KEY-NXTREC
y KEY-PRVREC
y KEY-UP
y KEY-DOWN
y KEY-SCRUP
y KEY-SCRDOWN
y KEY-NXTBLK
y KEY-PRVBLK
KEY-NEXT-ITEM (or KEY-PREV-ITEM) trigger is a mouse-event key trigger
because its functionality can be achieved directly by clicking the item you want to
navigate. In such a case KEY-NEXT-ITEM trigger will not fire.
However, KEY-CREREC trigger is not a mouse-event key trigger. This is because a
record cannot be inserted simply by clicking the mouse. The mouse can achieve
the creation of a record only if a trigger defined to create records fires due to the
action of the mouse.
Confidential
236
Property Name
Description
Display in Keyboard
Help
Specifies the text that is to appear in the runtime Keys window if the Display in keyboard
Help property is set to Yes.
Confidential
237
NOTE
Platform specific resource files are available for key mapping.
For Microsoft Windows platform, the key definition file is FRMUSW.RES.
Oracle Terminal should be used to edit Client Server resource file.
For Web application, the key definition file is FRMWEB.RES. This Java
resource file can be edited with any suitable operating system editor.
When the properties are set, the Keys window is displayed at runtime as shown
below:
Confidential
238
NOTE
Among the capabilities mentioned above, disabling
default function and performing multiple actions
cannot be duplicated by a menu command.
y Check if child records exist before deleting a parent record using KEYDELREC trigger
Confidential
239
y Pressing [ctrl+q]
y Clicking the Exit icon
y Selecting Exit menu item from Action menu
y Clicking
In such a case, where the same functionality can be achieved in various ways,
you can specify the PL/SQL code to be executed only once. This is made possible
using the DO_KEY built-in function.
DO_KEY built-in function executes the key trigger corresponding to the built-in
subprogram specified as its parameter. If no such key trigger exists then the
specified built-in subprogram is executed. The syntax to use the DO_KEY built-in
function is:
DO_KEY (<Built-in_name>);
For example, you can exit a form by selecting a menu item for exiting or clicking
a button defined for exiting a form. The functionality for either is set by:
Defining a KEY-EXIT trigger
36. Using DO_KEY in:
On the button
Mouse Events
Mouse events can be classified into the following two types:
Confidential
240
Click
Double click
Up
Down
Trigger
Fires in Response to
WHEN-MOUSE-ENTER
WHEN-MOUSE-LEAVE
WHEN-MOUSE-MOVE
Button
When-Mouse-Enter
Button
When-Mouse-Leave
When-Mouse-Move
Mouse movement triggers can be defined at:
Confidential
241
System Variables
Returns
SYSTEM.MOUSE_FORM
SYSTEM.MOUSE_CANVAS
SYSTEM.MOUSE_ITEM
SYSTEM.MOUSE_RECORD
SYSTEM.MOUSE_RECORD_OFFSET
SYSTEM.MOUSE_X_POS
SYSTEM.MOUSE_Y_POS
NOTE
Mouse movement triggers do not fire when users enter the
canvas using menu commands.
Use mouse movement triggers sparingly in client server
applications because they have the potential to fire frequently.
These triggers are disabled in Web-deployed forms. MASTER
trigger.
The following diagram depicts the various mouse position system variables:
Confidential
242
In order to obtain the exact position of the mouse within forms application, use
WHEN-MOUSE-MOVE in association with SYSTEM.MOUSE_X_POS and
SYSTEM.MOUSE_Y_POS.
To do so, write the following WHEN-MOUSE-MOVE trigger at form level to
populate the two display items namely dsXPos and dsYPos in control block
ControlBlk of frmLib module with the X and Y position values:
: dsXPos:=:SYSTEM.MOUSE_X_POS;
: dsYPos:=:SYSTEM.MOUSE_Y_POS;
To understand the usage of WHEN-MOUSE-ENTER and WHEN-MOUSE-LEAVE,
write a WHEN-MOUSE-ENTER trigger that would change the button label of
pbOut in ControlBlk of frmLib module to In and write a WHEN-MOUSE-LEAVE
trigger to change its label back to Out as follows at item level:
WHEN-MOUSE-ENTER trigger
SET_ITEM_PROPERTY (pbOut, LABEL, In);
WHEN-MOUSE-LEAVE trigger
SET_ITEM_PROPERTY (pbOut, LABEL, Out);
Confidential
243
NOTE
The Mouse-Event triggers can be used to provide context
sensitive help to the end users
Trigger
Fires in Response to
WHEN-MOUSE-DOWN
WHEN-MOUSE-UP
WHEN-MOUSE-CLICK
WHEN-MOUSE-DOUBLECLICK
NOTE
Mouse button action triggers can be defined at the form,
block, and item level.
For click and double click mouse button actions to work, the
mouse must be on the item or the canvas.
Confidential
244
When users click or double click an item or canvas, they cause triggers that
precede WHEN-MOUSE-CLICK and WHEN-MOUSE-DOUBLECLICK to fire in the
following sequence:
1. WHEN-MOUSE-DOWN
2. WHEN-MOUSE-UP
3. WHEN-MOUSE-CLICK
4. WHEN-MOUSE-UP
5. WHEN-MOUSE-DOUBLECLICK
The following WHEN-MOUSE-DOUBLECLICK trigger invokes lvBranch LOV on
double clicking cBranchID text item in the MEMBER data block:
DECLARE
X BOOLEAN;
BEGIN
X: = Show_Lov ('lvBranch');
END;
TIP
In a Web-deployed form, when a mouse button action is initiated, the Java
user interface refers to the Forms Server to identify its corresponding
mouse button trigger.
In case the relevant mouse button trigger is not defined, the user interface
generates the required event if at least one mouse button trigger has been
defined in the form. Therefore, mouse button triggers should be used
sparingly.
Confidential
Returns
245
System Variables
Returns
SYSTEM.MOUSE_BUTTON_PRESSED
SYSTEM.MOUSE_BUTTON_MODIFIERS
The mouse cursor style can be changed dynamically using the built-in procedure
SET_APPLICATION_PROPERTY as follows:
SET_APPLICATION_PROPERTY (CURSOR_STYLE, value);
y Default symbol
y Busysymbol
y Crosshairsymbol
y Helpsymbol
y Insertionsymbol
WHEN-MOUSE-DOWN and WHEN-MOUSE-UP triggers could be used in association
with SET_APPLICATION_PROPERTY built-in procedure to change the cursor style
at runtime.
The following PL/SQL Editor screen shows the code written in WHEN-MOUSEDOWN trigger:
Confidential
246
Similarly, WHEN-MOUSE-UP trigger can be written to bring the cursor style back
to Default as follows:
SET_APPLICATION_PROPERTY (CURSOR_STYLE,'DEFAULT');
Confidential
247
Summary
In this chapter, you have learnt that:
Key triggers cannot be used to redefine function keys that are managed by
the terminal or Window Interface Manager.
Key triggers can be classified into Function key triggers, Key-Fn triggers
and KEY-OTHERS trigger.
Key triggers are commonly used to disable and enable function keys,
replace the default functionality of function keys etc.
Key triggers should not be used to carry out or modify validation etc.
To obtain the exact position of the mouse within forms application, use
WHEN-MOUSE-MOVE in association with SYSTEM.MOUSE_X_POS and
SYSTEM.MOUSE_Y_POS.
Confidential
button
action
events
are
two
248
Lab Exercise
1. The cursor style should get changed when it is placed on the execute
button in BRANCHXX and to cursor shape dumble when the execute button
is clicked.
2. Write a trigger to invoke an LOV dynamically for cmemberid and nage
columns such that the same LOV is used to populate the list of values but
the values populated for the cmemberid should vary from nage according
to the queries specified.
Ex: List of values for cmemberid should contain all the values of the table.
List of values for nage should contain the age values between 35 and
70.
3. Write a trigger at form level to close the form. Modify the existing code to
achieve the task.
Hint: Use a key trigger and built-in responsible to simplify this code.
Confidential
249
Chapter 14
Transaction Triggers
Control Transaction Processing
Commit Triggers
Obtaining Cursor Information in PL/SQL
Life of an Update
Commit Sequence of Events
Keeping an Audit Trail
Running against a non-oracle database
Transactional Triggers
Array DML
Getting and Setting the Commit Status
Using Built-in Subprograms
Confidential
250
Objective
At the end of this chapter, you will be able to:
y Control Transaction Processing
y Understand about commit triggers
y Know to obtain cursor information in PL/SQL
y Learn about the life of an update
y Commit sequence of events
y Learn to keep an audit trail
y Running against a non-oracle database
y Know what are Transactional triggers
y Work on array DML
y Get and set the commit status
y Use built-in subprograms
Confidential
251
y Applying the changes to the base tables. This is the default Form Builder
transaction processing.
y Clicking Save
y Calling of COMMIT_FORM built-in procedure within a trigger code.
In both the above-mentioned cases, the transaction processing involves two
stages:
Commit Triggers
During the normal flow of commit processing the commit triggers are fired.
Following are the types of commit triggers:
PRE-COMMIT trigger: This trigger is fired before Form Builder starts processing
the records for change. This trigger is fired after Form Builder determines that
there are inserts, updates, or deletes in the form. This trigger is defined at form
level and is fired only once. This trigger can be fired to perform an action like
setting up special locking requirements, at any time the database commit is
occurring. For example, to prevent any user from adding, deleting, or modifying
records in frmLibTrans after or before library hours, write the following code:
IF TO_CHAR (SYSDATE,'HH24') NOT BETWEEN 10 AND 19 THEN
MESSAGE ('You are not permitted to add, delete, or update
any records in this form');
END IF;
Confidential
252
For example, the following code could be written in the PRE-DELETE trigger of
Branch block in frmLibTrans module so as to disallow the user from deleting
those records of the Branch block that have members:
DECLARE
vCountMembers NUMBER;
BEGIN
SELECT COUNT (*)
INTO
vCountMembers
FROM Member
WHERE cBranchID=:Branch.cBranchID;
IF vCountMembers > 0 THEN
MESSAGE ('Members exist in this Branch ID. Hence, the
branch details cannot be deleted');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
For example, to prevent duplicate Member IDs from being inserted, write
the following code in PRE-INSERT trigger defined for Member block of
frmLib module:
DECLARE
vMemID CHAR (9);
BEGIN
SELECT cMemberID
INTO vMemID
FROM Member
WHERE cMemberID=:Member.cMemberID;
IF vMemID=:member.cMemberID THEN
MESSAGE ('Duplicate Member IDs not allowed');
RAISE FORM_TRIGGER_FAILURE;
Confidential
253
END IF;
END;
Confidential
254
Attribute
Values
SQL%ROWCOUNT
SQL%FOUND
SQL%NOTFOUND
Life of an Update
To explain how and where certain trigger actions can be performed, consider an
example:
The address of a Branch is updated in a form. When the user queries the record,
following are the events that occur:
37. The user updates the Branch address.
38. The user saves the change, initiating the transaction process.
39. The PRE-INSERT trigger is fired. At this stage the form item value and
database column value both are different, as the base table has not been
updated.
40. Form Builder applies the user changes to the database row. Now both the
item and column are same.
41. Then the POST-UPDATE trigger is fired.
42. Form Builder issues the database commit, denying the rollback data and
releases the locks, making the changes permanent. Then the following
message is displayed: Transaction is completed
Delete Validation
The non-isolated deletion rule is linked to the Master-detail blocks by a relation,
which automatically avoids deletion of master records in the form only if the
matching detail rows exist.
Confidential
255
Finally, to make sure that since the master record was marked for deletion in the
form, no dependent detail rows have been inserted by another user.
NOTE
If you select the Enforce data integrity check box in the Data
Block Wizard, then Forms Builder automatically creates the
related triggers to implement constraints.
If it is an updated record:
There are 5 rules that are used for issuing DML statements at commit time for
each database record.
Confidential
256
y Form Builder uses the ROWID construct only when the Key Node Block
property is set to Automatic (default).
y If Form Builder inserts a row in the database, it retrieves the ROWID for
that row.
y If the Enforce Column Security block property is set to Yes then Oracle
Forms enforces the update privileges that are defined in the database for
the current end user.
Confidential
257
Transactional Triggers
Transactional triggers are related to accessing a data source. Commit triggers are
a subset of these triggers. They fire in response to a wide variety of events.
Following are the six transactional triggers used during Commit Processing:
12) ON-CHECK-UNIQUE trigger: This trigger is fired when Form Builder checks
that values are unique for primary key. It fires once for each record that has
been inserted or updated.
This trigger can be defined at block or form level.
13) ON-COLUMN-SECURITY trigger: This trigger is fired when Form Builder
enforces the column-level security for each block that has the Enforce
Column Security block property set On. It can be defined at block or form
level.
14) ON-COMMIT trigger: This trigger is fired when Form Builder issues a commit
statement to finalize a transaction. It can be defined at form level.
15) ON-ROLLBACK trigger: This trigger is fired when Form Builder issues a
rollback statement, to roll back a transaction to the last savepoint that was
issued. It can be defined at form level.
16) ON-SAVEPOINT trigger: This trigger is fired when Form Builder issues a
savepoint statement. It can be defined at form level.
Array DML
Confidential
258
The default forms behavior is to process one record at a time. To alter the
process of records we have an option in forms builder called Array Processing.
You can process bulk of records at a time by enabling array processing. This is
mostly used in web applications. This leads to reduction in traffic and increase in
performance. Here, an array containing groups of records are sent to or returned
from the server.
Forms Builder supports both array fetch processing and array DML processing.
For both DML operations and querying, you can specify the array size to optimize
performance for your needs.
Array processing is not supported for blocks based on transactional triggers.
The following are the steps to implement Array DML:
1) To set preferences:
-Select Edit > Preferences.
-Click the Runtime tab.
-Select the Array Processing check box.
2) To set properties:
Under the Advanced Database category, set the DML Array Size
property to a number that represents the number of records in the
array for array processing. You can also set this property
programmatically.
New: Indicates that none of the item in the record has been changed.
Insert: Indicates that one or more of the items in the record have been
changed.
Confidential
259
Query: Indicates that the block contains only those records that have
been retrieved from the database.
Changed: Indicates that the form contains at least one block with a
changed record.
VARCHAR2, property
NUMBER);
Where,
block_id: is the ID assigned to the block when the Form Builder creates
it.
block_name: is the name of the block.
Confidential
260
Confidential
261
Summary
In this chapter, you have learnt:
During the commit sequence, some of the events that occur are like
validation of the form, processing of the savepoint and firing of the PRECOMMIT trigger etc.
There are two ways to run against data sources other than Oracle. You can
use Oracle transparent gateway products or write the appropriate set of
transactional triggers.
The commit status of a record identifies how the record will be processed
at the time of the next commit process.
The three system variables that are used to get and set the commit status
are
SYSTEM.RECORD_STATUS,
SYSTEM.BLOCK_STATUS
and
SYSTEM.FORM_STATUS.
Confidential
262
Lab Exercise 14
1. Write a trigger in BRANCHXX such that if the time is between 10 and 19
hours, the transactions done after these business hours should not be
allowed.
2. Write a trigger in BRANCHXX module such that an exception should be
raised if a duplicate value is entered into the cmemberid column.
3. Set property such that if master record is deleted an exception should be
raised that a detail record exists and master record cannot be dropped.
4. Write a trigger on MEMBER block such that when a duplicate record is
getting inserted, this trigger fires.
Confidential
263
Chapter 15
Flexible Code
System Variables for Flexible Coding
System Variables to Determine the Form Status
Built-in Subprograms for Flexible Coding
Using Objects Internal IDs for Flexible Coding
Extending the scope of the Object Ids
Confidential
264
Objective
At the end of this chapter, you will be able to:
Confidential
265
Function
System variables
SYSTEM.CURSOR_BLOCK
SYSTEM.CURSOR_RECORD
SYSTEM.CURSOR_ITEM
SYSTEM.CURSOR_VALUE
You can use the above system variables in the following way:
IF:SYSTEM.CURSOR_BLOCK= Book THEN
MESSAGE (You are in the Book Data Block);
END IF;
The code mentioned above will give you the message when you enter the Book
data block. Similarly you can use the other system variables as mentioned above
in the code to find the status of the form module. There are other system
variables used for locating the trigger focus. They are:
System Variable
TRIGGER_BLOCK
TRIGGER_RECORD
TRIGGER_ITEM
Confidential
Function
Gets the name of the block that the
input focus was in when the trigger
initially fired.
Gets the number of record that Form
Builder is processing.
Gets the name of the item and block
that the input focus was in when the
trigger initially fired.
266
y SYSTEM.RECORD_STATUS
y SYSTEM.BLOCK_STATUS
y SYSTEM.FORM_STATUS
The table below shows you the list of the system variables and their
corresponding values that are used for determining the form status.
SYSTEM.RECORD_STATUS
Function
CHANGED
INSERT
NEW
QUERY
SYSTEM.BLOCK_STATUS
Description
CHANGED
NEW
QUERY
SYSTEM.FORM_STATUS
Description
CHANGED
NEW
QUERY
Confidential
267
45. Before you run the form, create the alExit Alert. Open the Property
Palette of the alExit and set the Message and Alert Style
properties to Do you want to exit? and Caution respectively.
46. The screen grab below shows the Property Palette of alExit with
the properties Message and Alert Style set.
47. Compile the KEY-EXIT trigger and run the form module.
48. When you try to close the window of the form, the trigger fires and
saves the changes to the database if there are any modifications.
49. It also invokes the alExit Alert and prompts you with Do you want
to exit?. If you choose Yes button then the form will exit from the
forms run time environment.
Confidential
268
The GET_ built-in subprograms are used for getting the values from the specified
item, block or a form at runtime. Following are some of the GET_ built-in
subprograms.
GET_APPLICATION_PROPERTY subprogram:
The GET_APPLICATION_PROPERTY subprogram returns information about the
current Form Builder application. The GET_APPLICATION_PROPERTY subprogram
is used in following ways:
:GLOBAL.username := get_Application_Property(USERNAME);
:GLOBAL.password := get_Application_Property(PASSWORD);
The above code is used to capture the database username and password of the
current user.
GET_BLOCK_PROPERTY subprogram:
Confidential
269
SET_ITEM_INSTANCE_PROPERTY
(:
SYSTEM.CURSOR_ITEM,
VISUAL_ATTRIBUTE, CURRENT_RECORD, vattFonts);
The above code is used to set the visual attribute vattFonts for the current record
of the current item.
The built-in is used for changing the properties of the alert at run time. For
example to change the alert message at runtime write the following lines of code
in the WHEN-WINDOW-CLOSED trigger written above:
SET_ALERT_PROPERTY (alExit, ALERT_MESSAGE_TEXT,do you want
to exit the form?);
Confidential
270
NOTE
Use the FIND_ built-in subprogram only when the object is
being referred frequently in the same trigger code or PL/SQL
program unit.
DECLARE
al_id
Alert;
al_button NUMBER;
BEGIN
al_id := Find_Alert('alExit');
IF Id_Null(al_id) THEN
Message (' alExit alert does not exist');
RAISE Form_Trigger_Failure;
ELSE
al_button := Show_Alert(al_id);
. . . . . . . . . . . . . .
. . . . . . . . . . . . . .
END;
You can also use object IDs to set the properties for specified objects. The code
below shows you how to set the property of the Alert using its object ID.
SET_ALERT_PROPERTY(al_id, ALERT_MESSAGE_TEXT, Do you want to
exit the Form);
Alert;
BEGIN
al_var:=FIND_ALERT(alExit);
:GLOBAL.ALERT:= al_var.id;
Confidential
271
END;
The following example shows the conversion of the global variable back to its
original PL/SQL data type:
DECLARE
al_var
Alert;
BEGIN
al_var :=TO_NUMBER(:GLOBAL.ALERT);
SHOW_ALERT(al_var);
END;
Direct Reference
Indirect Reference
ITEM A
VALUE A
ITEM B
VALUE A
ITEM A
VALUE A
. . . . . . . . . . . . . . . . . . ..
Using the COPY Built-in Procedure
The COPY built-in procedure copies a value from one item or variable to another
item or global variable. The COPY built-in procedure is similar to PL/SQL
Confidential
272
assignment statement, the only difference is that it is used to copy a value to the
variable or item using indirect referencing.
The syntax below shows the direct referring:
COPY (value,Book.cBookName);
The syntax below shows the indirect referring:
COPY (value1,:GLOBAL.Book_name);
We can use COPY built-in with the NAME_IN built-in to assign the values. The
syntax below shows you how to assign the value to an item whose name is stored
in the global variable:
COPY(value, NAME_IN(GLOBAL.Book_name);
Confidential
273
Summary
In this chapter, you have learnt that:
y Flexible code is a reusable code where we use the system variables in the
flexible coding which on the other hand increases the productivity.
y SYSTEM.RECORD_STATUS,
SYSTEM.BLOCK_STATUS
and
SYSTEM.FORM_STATUS are the three system variables through which you
can know the form status.
y GET_ built-in functions and SET_ built-in procedures are the sets of builtins used to reduce the hard coded values in programming.
y To use the object ID, you need to declare the variable of the same type as
the object ID.
y To refer an object ID outside the initial PL/SQL block, you need to convert
the ID to a numeric format using a .id extension for your declared PL/SQL
variable, and then assign it to a global variable.
Confidential
274
Lab Exercise
1. Determine in which record the cursor is currently placed in?
2. Create an alert, which specifies grade should not be other than the
specified range of age.
3. Display the name of the user you are currently working in.
4. Write a trigger for Branch block such that when the cursor is placed in an
item, the font should zoom and when the cursor is navigated to other item
then that item font should zoom, the item which lost focus should get back
to its original font size.
5. Write a procedure named p_close_window to capture which window is
getting closed. Call this procedure to check which window is closed.
Confidential
275
Chapter 16
Confidential
276
Objective
At the end of this chapter, you will be able to:
Use Smartclass.
Confidential
277
Property Class
While developing an application, there is the need for reusing objects and code to
improve:
in
1. In the Object Navigator, click the object whose Properties you need to
copy into a Property Class.
Confidential
278
2. Hold the [Shift] key on the keyboard and select the properties you want
to copy.
3. Click the Create Property Class button
in the Property palette
toolbar. An information alert is displayed with the property class name.
The screen grab of which is shown below:
Property Class
Add
Property
Delete
Property
Property
Class
Inherit
Property
Confidential
279
The inherited property can be overridden by changing the value associated with
it. Such a property is known as a variant property. A variant property is displayed
with a red cross over an arrow. The diagram below shows the variant property
that is obtained by overriding the inherited property:
You can convert a variant property to an inherited property by clicking the inherit
property icon in the Property Palette.
The steps to inherit the properties from a Property Class are:
50. In the Object Navigator, double click the object you want to apply the
properties from the Property Class. This opens the Property Palette of the
object.
51. Click the Subclass Information
Information dialog box.
property
to
invoke
the
Subclass
52. The diagram below shows you the Subclass Information dialog box:
53.
Select the Property Class whose properties you want to use from the
Subclass Information dialog box. Click OK to inherit the properties of
the Property Class to the current object.
Confidential
280
You need to consider the following when working with object groups:
y When you copy a block into an object group, all the item level triggers,
block level triggers, and relations that come under it are also copied.
Confidential
281
Copying Objects
Subclassing Objects
If you click the Subclass button of the alert box then all the characteristics are
inherited to the target module. Similarly if you click the Copy button of the alert
box, then the exact copy of the objects in the object group are made in the target
module.
The diagrams below show the difference between the copying and subclassing of
objects:
Add to
object
Makes exact
copy of object
Confidential
Makes exact
copy of object
Added
part
SQL Star International Ltd.
282
Subclassing of Objects
Once an object is subclassed you can:
y Add elements to the object: You can create an exact copy of the object, as
with referencing the parent class, and add additional items to the
subclassed object.
y Alter the properties of the object: Subclassing the object creates an exact
copy of the parent class. If you change the parent class properties, the
changes are reflected in the subclassed object. However the properties that
are overridden in the subclassed object will remain overridden.
y Override the changes made in the parent class: When you change the
properties of a parent object, all the objects inherit these properties if they
are not already overridden.
Object Libraries
Object Library is a collection of common Oracle objects that can be used in any
form where appropriate. Object Libraries store objects like property classes,
visual attributes and triggers.
The advantages of using the Object Libraries are:
y They are automatically opened when the form referencing the object library
is opened in Form Builder so that the reusable objects can be accessible
immediately.
NOTE
An Object Library does not allow creation or modification of its
objects.
The valid Oracle forms objects that can be placed inside an object library are:
y Alerts
y Blocks
y Canvases
y Property classes
y Visual attributes
y Windows
Confidential
283
3. Select the Object Library node in the Object Navigator, Click the
Create icon. A new Object Library with the default name is created, as
shown in the following diagram:
Confidential
284
6. Set the Name property and the Label property to of the Tab Page to
vattrLib and vattr respectively.
The Property Palette for the Library Tab is shown in the diagram below:
Confidential
285
2. Select the Visual Attribute object in the form module and drag
and drop it in the vattr tab. The vattr tab with the added object is
shown in the following diagram:
Confidential
286
3. Save the object library to hard disk with .olb (Object Library
Binary) extension.
Smart Class
A smart class is a member of the Object Library. Smart class is used to subclass
existing objects in a form using the SmartClass option from the pop up menu,
which gets invoked when you right click the object. If you have certain frequently
used objects in your forms such as buttons, data items, and alerts, then you can
make them as smart classes. Once the object is made a smart class, you can
reuse the object. For example, if a button B1 in form module FM1 is made into a
smart class, then when button B2 of form module FM2 is assigned to the smart
class B1 gets all the properties including the label of button B1.
To create a smart class you need to:
1. Expand the Object Library node in the Object Navigator.
2. Open the Library tab by double clicking it.
3. Select the object from the list of objects in the library tab.
4. Choose the Object SmartClass form the menu to make the object a
smart class.
Confidential
287
PL/SQL Library
A PL/SQL Library is a collection of program units including user-defined
procedures, functions and packages. PL/SQL Library provides you the convenient
means of storing client-side program units and sharing them among multiple
applications.
The PL/SQL Library has the following features:
y It also provides dynamic loading of program units. That means the program
units are loaded into memory only when the application needs it.
The bind variables in forms, menus and reports are outside the scope of the
library as it is compiled independently of the Oracle Forms Developer modules.
This means you cannot refer directly to the variables that are local to another
module, because the compiler does not know them when you compile the library
program units.
There are two ways to refer to the bind variables indirectly:
Confidential
288
Creating a Library
You must first create a library in the forms builder before you add any program
units to it. To do this:
1. In the Object Navigator, select FileNewPL/SQL Library from the
main menu. A new entry for the PL/SQL Library appears under PL/SQL
Library node. Select the PL/SQL Libraries node in the Object
Navigator, and click the Create icon.
2. To create the program unit, expand the library node, select the Program
Units node and then click Create icon. The Program Units dialog
appears. The Program Units dialog box is shown the following figure:
3. Specify the name of the program unit and select its type from the given
radio button options and click OK.
Confidential
289
4. In the PL/SQL Editor, define the appropriate program units and then click
the Compile button to compile and apply the modifications. Click the
Close button to close the editor.
The PL/SQL Library can be saved as follows:
1. Select FileSave
2. Choose the destination folder and name by which the library is to be saved
with .pll extension.
Expand the module and select the Attached Libraries node. Click the
Create icon to attach a library. The Attach Library dialog box appears as
shown in the following diagram:
3. Specify the name of the library to be attached as shown in the screen above.
4. Click the Attach button to attach the PL/SQL Library to the current form
module. Save the module to complete the process.
(:cMemberID,
:cFirstName,
:cLastName,
:vAddress);
The function with name fnFineCal can be referred as follows:
Fine: = fnFineCal (:MemberID);
Similarly the package with name pkMemberInfo can be referred as follows:
Confidential
290
PkMemberInfo.
prMemberDetails(:cMemberID,
:cFirstName,
:cLastName, :vAddress);
When several libraries are attached to the same form module, references are
resolved by searching through the libraries in the order in which they occur in the
attachment list. If two program units of the same name and type occur in
different libraries in the attachment list, the program unit which is higher in the
library will be executed, since it is located first.
Summary
In this chapter, you have learnt that:
The valid Oracle forms objects that can be placed inside an object library
are alerts and blocks etc.
A smart class can be invoked by invoking the pop-up menu and selecting
SmartClasses option.
Confidential
291
Lab Exercise:
1. Create a Property Class based on the nage column.
2. In the new form module, create a property class called ClassA. Include the
following properties and settings:
Font Name: Arial
Format Mask: 99,999
Font Size: 8
Justification: Right
Delete Allowed: No
Background Color: blue
Foreground Color: Gray
3. In the BRANCHXX Create an object group and name as objgroup
consisting of Transaction block, cv_Transaction, win_Transaction window.
o
Now create a new form module Demo and copy this form level
trigger into the new module.
Create five tab pages in it, name and label them as Text, Triggers,
Canvas, Window and Buttons.
5. Create a smart class object for COLOR_BUTTON. Check how smart class is
used.
6. Create a PL/SQL library, in that library create a procedure Disp just to
display Hello from the Display and attach this library.
o
Confidential
292
Chapter 17
Confidential
293
Objective
At the end of this chapter, you will be able to:
Confidential
294
Introduction to WebUtil
The middle-tier application server calls Forms built-in subprograms.
Sometimes if you want to communicate with the client you can do with JavaBeans
and PJCs, but with the utility called WebUtil, which has much prewritten
functionality for client interaction. This chapter deals with how to use WebUtil to
interface with the client machine.
Overview of WebUtil
Generally, Forms built-ins are executed on the application server machine. Some
Forms built-ins communicate with the machine to read an image file, create or
read a file, or execute operating system commands. Sometimes, it is desirable to
execute such built-ins on the application server machine. So to perform such
functionality on the client, you can very well use a JavaBean or PJC. For this,
either you have to write or locate prewritten components and integrate each into
Forms applications.
WebUtil consists of a set of Java classes, Forms objects, and a PL/SQL API that
enables you to execute many Java functions of WebUtil without knowing Java.
NOTE
The middle-tier architecture can be of any platform on which
WebUtil is installed with supported Forms Services but the client
machine must be Windows 32-bit platform.
Advantages of WebUtil
To perform complex tasks any Forms developer can use WebUtil on client
browser machines by simply coding PL/SQL.
Using its Object group and PL/SQL Library, it is very easy to integrate WebUtil
into your Forms applications, and you can easily extend it by adding your own
custom functionality while leveraging its basic structure.
Confidential
295
There is rich functionality available in the utility that includes the following:
Client/server parity APIs: This enables you to retrieve a file name from the
client, read or write an image to or from the client, get information about
the client machine, or perform HOST, TEXT_IO commands and OLE
automation on the client (These built-ins execute on the application server
machine without the WebUtil functions).
NOTE
There are some of these functions may duplicate other WebUtil
functions, but if you use d2kwutil, then it is easy to migrate
code.
Function
GET_DATE_TIME
GET_FILE_SEPARATOR
GET_HOST_NAME
GET_IP_ADDRESS
GET_JAVA_VERSION
GET_LANGUAGE
GET_OPERATING_SYST
EM
Confidential
obtain
Returns:
Date and time on client machine
Character used on client as file separator
(\ on Windows)
Name of client machine
IP address of client (string)
JVM version that is running the Forms
applet
Language code of the client machine,
such as de for German
Name of OS running the browser
296
Function
IsSupported
RegisterFunction
DeregisterFunction
Create_Parameter_List
Destroy_Parameter_List
Add_Parameter
Get_Parameter_Number
Get_Parameter_Ptr
Get_Parameter_String
Rebind_Parameter
Purpose:
Returns True if the client is a valid
platform
Returns a handle to a specified C library
function
Deregisters function and frees client
resources
Creates a parameter list to pass to C
function
Deletes a parameter list and frees its
resources
Adds a parameter to the parameter list
Typed functions to return parameter
values
Changes parameter values of the
existing parameter list to reuse it
Confidential
297
Function
COPY_FILE
RENAME_FILE
DELETE_FILE
Purpose
Copy, rename, or delete a file and return
a Boolean value to indicate success
CREATE_DIRECTORY
DIRECTORY_ROOT_LIST
DIRECTORY_FILTERED_LIS
T
FILE_SELECTION_DIALOG
FILE_MULTI_SELECTION
_DIALOG
GET_FILE_SEPARATOR
GET_PATH_SEPARATOR
Function
GET_PATH_SEPARATOR
GET_SYSTEM_PROPERT
Y
GET_TIME_ZONE
GET_USER_NAME
Returns:
Character used on client to separate
directory locations on paths (; on
Windows)
Any Java system propery
Time zone of client machine
Name of user logged in to the client
Function
URL_TO_CLIENT
URL_TO_CLIENT_WITH
_PROGRESS
Purpose:
Transfers a file from a URL to the client
machine (and displays a progress bar)
CLIENT_TO_DB
CLIENT_TO_DB_WITH
_PROGRESS
DB_TO_CLIENT
DB_TO_CLIENT_WITH
_PROGRESS
CLIENT_TO_AS
CLIENT_TO_AS_WITH
_PROGRESS
AS_TO_CLIENT
AS_TO_CLIENT_WITH
_PROGRESS
Confidential
298
Purpose
Enables the time-out monitor and the
specification of a redirection URL
DISABLE_REDIRECT_ON
_TIMEOUT
holds
the
Function
HOST
Purpose
Runs the specified command in a
BLOCKING mode on the client and
optionally returns the return code
Runs the specified command in a
BLOCKING mode on the client and
optionally returns the process ID
Runs the specified command in a NONBLOCKING mode on the client and
optionally returns the process ID
Kills the specified process on the client
BLOCKING
NONBLOCKING
TERMINATE_PROCESS
GET_RETURN_CODE
GET_STANDARD_OUTPUT
GET_STANDARD_ERROR
Confidential
299
Purpose
Checks whether the last WebUtil call
succeeded
ErrorCode
ErrorText
Utility functions: There are some useful functions that are not related to
client integration, as shown in the following table:
Function
DelimStr
Show_WebUtil_Information
WebUtil_Util
Purpose:
Provides interaction with delimited
strings
Calls the hidden WebUtil window to show
the version of all WebUtil components
Provides the BoolToStr() function for
converting Boolean to text
There are some internal APIs that you should never call directly.
Confidential
300
Lib
Alert
Step 3: Move the WEBUTIL
block after all other blocks.
Object library
Object group
Window
Confidential
301
A data block with items, including a button and several bean area
items to implement the JavaBeans (the bean area items are hidden
because there is no visual component).
NOTE
If you receive an FRM-92101 error while running the form, be
sure that you have followed exactly the above steps.
Configuring WEBUTIL
1. Download and unzip webutil_106.zip to c:\Devsuitehome\forms
2. Download and Unzip jacob_18.zip to C:\Devsuitehome\forms\java
3. Add the following in C:\Devsuitehome\forms\server\default.env
WEBUTIL_CONFIG= C:\DEvsuitehome\forms\server\webutil.cfg
Append to existing CLASSPATH
CLASSPATH= C:\DevsuiteHome\forms\java\frmwebutil.jar;
4. Append the configuration of C:\DevSuiteHome\forms\server\formsweb.cfg
archive_jini=f90all_jinit.jar, frmwebutil.jar, jacob.jar
WebUtilArchive=frmwebutil.jar, jacob.jar
5. Add C:\DevSuiteHome\jdk\bin to Environment variable PATH
6. Copy Jacob.jar to C:\DevSuiteHome\forms\webutil\
Open a Command window and change to the
ORACLE_HOME\forms\webutil
directory. With it write the below signature in command prompt
7. sign_webutil.bat C:\Devsuitehome\forms\webutil\jacob.jar-- press enter.
Confidential
302
WebUtil Equivalents
CLIENT_HOST
CLIENT_GET_FILE_NAME
READ_IMAGE_FILE
CLIENT_IMAGE.READ
WRITE_IMAGE_FILE
OLE2
TEXT_IO
(WRITE)_IMAGE_FILE
CLIENT_OLE2
CLIENT_TEXT_IO
CLIENT TOOL ENV
TOOL ENV
CLIENT_HOST
CLIENT_GET_FILE_NAME
Confidential
303
READ_IMAGE_FILE: You can use this on the client by calling the WebUtil
equivalent contained in a package known as CLIENT_IMAGE.READ_IMAGE_FILE.
In addition to this, there are certain Forms packages that you can use on the
client with WebUtil:1
CLIENT_OLE2
CLIENT_TEXT_IO
CLIENT_TOOL_ENV
IN
IN
IN
VARCHAR2,
VARCHAR2,
NUMBER,
FILE_NAME: This specifies the name of the file you want to open.
MESSAGE: This specifies the title of the file upload dialog box
DECLARE
v_file VARCHAR2 (250):= CLIENT_GET_FILE_NAME ('','',
Bmp Files|*.bmp|'Gif Files|*.gif|JPEG
Files|*.jpg|',
'Select a photo to upload', open_file, TRUE);
Confidential
304
FILE_NAME (Valid file name): The file name designation can include a
full path statement appropriate to your operating system.
FILE_TYPE (The valid image file type): BMP, CALS, GIF, JFIF, JPG,
PICT, RAS, TIFF, or TPIC.
NOTE
As Oracle Forms will attempt to deduce it from the source image
file, File type is optional but you should specify the file type to
optimize performance.
Confidential
305
ITEM_ID: The unique ID that Oracle Forms assigns to the image item
when it creates it.
ITEM_NAME: The name you gave the image item when you created it.
DECLARE
v_file VARCHAR2(250):=
CLIENT_GET_FILE_NAME('','',Bmp Files|
*.bmp|'Gif Files|*.gif|JPEG Files|*.jpg|',
'Select a photo to upload',open_file,TRUE);
it_image_id ITEM := FIND_ITEM
('members_photos.photo');
BEGIN
CLIENT_IMAGE.READ_IMAGE_FILE(v_file,' ',it_image_id);
END;
Confidential
306
Summary
In this chapter, you have learnt that:
There are steps to integrate WebUtil functionality into a form and different
triggers used to add webutil functionality.
There are some useful functions that are not related to client integration.
You can integrate WebUtil into a form by attaching the WebUtil Library,
subclassing WebUtil forms objects and ensuring in the object navigator
that webUtil is the last block.
You should not use the WebUtil functionality in triggers such as WhenNew-Form-Instance, When-New-Block-Instance and Pre-Form for the first
block in the form.
ITEM_ID is the unique ID that Oracle Forms assigns to the image item
when it creates it.
Confidential
307
Lab Exercise 17
1. Select the image of the member by invoking the file image dialog box.
Confidential
308
Chapter 18
Working with
Multiple Form Applications
Invoking Multiple Form Modules
The OPEN_FORM Built-in Procedure
The CALL_FORM Built-in Procedure
The NEW_FORM Built-in Procedure
Form Parameters
Built-in Subprograms to create and manipulate parameter lists
Creating Record Groups
Confidential
309
Objective
At the end of this chapter, you will be able to:
y Identify ways of invoking multiple form modules
y Learn about the OPEN_FORM built-in procedure
y Know about the CALL_FORM built-in procedure
y Discuss about the NEW_FORM built-in Procedure
y Describe the need for form parameters
y Prepare built-in
parameter lists
subprograms
to
create
and
manipulate
Confidential
310
y OPEN_FORM
y CALL_FORM
y NEW_FORM
Forms Runtime
Form
C
Open
Form
A
Open
Form
B
(Parameters)
(Parameters)
Open
(Parameters)
Form
D
Global variables
Global record groups
PL/SQL variables
The OPEN_FORM Built-in Procedure
OPEN_FORM built-in procedure opens an additional form module in a modeless
window. This implies the invoking form remains displayed allowing you to switch
between opened forms. However, it may be difficult to keep multiple open forms
synchronized. For instance, if frmLib module invokes frmLibTrans module the
current transaction in frmLibTrans module may not always belong to the current
member in the frmLib module.
The syntax of OPEN_FORM built-in procedure is:
Confidential
311
NOTE
To share PL/SQL variable data between forms, create a package containing the
PL/SQL variables to be shared and place it in the library. Attach the library to
the forms that need to share data. In the OPEN_FORM built-in procedure, set
the DATA_MODE property as SHARE_LIBRARY_DATA. This makes changes
made by one form visible to another.
y Trigger statements that follow the call to OPEN_FORM built-in are never
executed when a form is opened with the parameter specified as
ACTIVATE. However, trigger statements following the call to OPEN_FORM
Confidential
312
Built-in Subprogram
Description
NEXT_FORM
Shifts the input focus to the open form with the next
highest sequence number. In the absence of a form
with a higher sequence number, the built-in navigates
to the form with the lowest sequence number.
PREVIOUS_FORM
Shifts the input focus to the open form with the next
lowest sequence number. In the absence of a form with
a lower sequence number, the built-in navigates to the
form with the highest sequence number.
GO_FORM
NOTE
Forms are sequenced in the order in which they were invoked at
runtime.
The following navigation and validation aspects need to be kept in mind while
navigating between forms:
Confidential
313
y When you click a non-current item of an open form, triggers that would
fire at the time of navigating from a current item to a target item, get
fired. In this case, validation occurs and navigational triggers fire.
Same Session
The following issues need to be considered when forms are opened within the
same session:
y Savepoint and rollback processing: When forms are opened within the
same session, Form Builder does not issue a savepoint for the form. For
instance, if frmLib opens frmLibTrans within the same session, then
when frmLibTrans executes CLEAR_FORM built-in procedure, all changes
made in frmLibTrans as well as frmLib are rolled back.
Different Sessions
It is appropriate to open forms in different sessions, when they access different
tables and manage logically independent transactions. For example, frmLib form
module invokes frmLibTrans form module. If frmLibTrans is opened in the
same session, you will have to commit changes made to both the forms
simultaneously. However, if it is opened in a separate session, you can enter a
new transaction detail in frmLibTrans and save it independently to the database
without having to commit frmLib.
NOTE
To execute OPEN_FORM with SESSION_MODE parameter set to
SESSION, Forms Runtime must set the Session option to On. If set to
Off, Form Builder issues an error and does not open the form.
To set the Session option to On, the FORMS50_SESSION environment
variable must be set to True.
Confidential
314
OPEN_FORM
Form
Form
Open_Form
Form
y It cannot be used to close a form that has opened another form with
CALL_FORM built-in procedure.
TIP
Confidential
315
DISPLAY,
SWITCH_MENU,
QUERY_MODE,
Where,
form_name is the name of the file containing the executable version of the form
to be invoked.
DISPLAY parameter has the following values:
HIDE (default): It specifies that the calling form be hidden while the called
form is running.
Confidential
316
You can invoke frmLibTrans form module from frmLib form module by writing
the following code within WHEN-BUTTON-PRESSED trigger:
CALL_FORM (c:\Form10g\Modules\Transaction);
y Commit processing: When changes made in the calling form are not
explicitly posted or committed, Form Builder invokes the called form in
post-only mode. In post-only mode, DML statements can be submitted to
the database, but cannot be committed or rolled back. This is to prevent
losing locks in the calling form. Any form called from a form running in
post-only mode will also be in post-only mode.
The characteristics of post-only mode are:
17) Changes in the called form are not committed, only posted (that is, changes
are written to the database). Any attempt to commit changes returns the
message: A calling form has unapplied changes. Save not allowed. When
you exit the form, a prompt asking whether the changes that were made
needs to be applied (posted) rather than saved (committed) is displayed as
follows:
The runtime screen of frmLibTrans shows the message displayed when attempt
is made to save changes, while there are unsaved changes in frmLib:
Confidential
317
y Only one call form stack is allowed per run form session. That is, an open
form Form3 cannot execute CALL_FORM if a call form stack has been
initiated by another open form. Form2.
The following diagram depicts the restrictions involved in using OPEN_FORM with
CALL_FORM:
CALL_FORM
Form1
OPEN_FORM
Form2
OPEN_FORM
Form3
CALL_FORM
CALL_FORM
Form6
Confidential
Form4
Form5
318
Form Parameters
The form variables defined at design time to supply values of inputs required by a
form at startup are known as parameters. They are of type CHAR, NUMBER, or
DATE.
y In the Object Navigator, select the Parameters node and click the
Create icon.
Confidential
319
y When you start a form from the command line using the standard
command line syntax, the default values specified for the parameter at
design time is overridden by the parameter value entered on the
command line. In the following example, MODULE and USERID are
predefined command line parameters, PARAMMEMBERID is the user
defined parameter created in frmLibTrans module:
Ifrun90.exe
MODULE=frmLibTrans
PARAMMEMBERID= PP039601
USERID=scott/tiger
y When a form is invoked from another form module, you can pass
parameter values by assigning them to parameter lists in the call to
OPEN_FORM, CALL_FORM, or NEW_FORM built-in subprograms. This is
illustrated later in this session.
Form parameters are referenced within codes in a way similar to how form
variables are referenced. That is:
Confidential
320
NOTE
A parameter list named DEFAULT or an already existing
parameter list cannot be created. Check whether a parameter list
exists by using GET_PARAMETER_LIST and ID_NULL built-in
subprograms.
Parameter List
Key
Type
paramMemberID
TEXT_PARAMETER
PP039601
paramMemID
DATA_PARAMETER
rgMemberID
Confidential
Value
OPEN_FORM
CALL_FORM
NEW_FORM
321
NOTE
Every form includes a built-in parameter list known as DEFAULT.
All the form parameters defined at design time are contained
within the DEFAULT parameter list. It can be specified in the call to
the built-ins that invoke form modules.
Confidential
322
key VARCHAR2,
paramtype NUMBER,
value VARCHAR2);
Where,
paramtype is an OUT parameter of type NUMBER. The parameter you
specify must be a variable of NUMBER, and not an expression. The
value it sets for the variable is either DATA_PARAMETER or
TEXT_PARAMETER.
Value is an OUT parameter of type VARCHAR2. The value is the name
of a record group if the parameter is a data parameter and the value is
an actual text if the parameter is a text parameter.
Confidential
323
EXECUTE_QUERY;
Next write a PRE-QUERY trigger at the Transaction block level as follows to
pass the parameter value:
: cMemberID:=:PARAMETER.PARAMMEMBERID;
You can also pass data between forms using global variables. In such a case the
above WHEN-BUTTON-PRESSED trigger would have the following code:
: GLOBAL.MemberID: =: cMemberID;
OPEN_FORM ('c:\Form10g\Modules\Transaction');
The WHEN-NEW-FORM-INSTANCE trigger would be the same, however,
Transaction block PRE-QUERY trigger code would be as follows:
: cMemberID:=:GLOBAL.MemberID;
The major points of distinction between form parameters and global variables
are:
Confidential
324
Form Parameters
Global Variables
Confidential
325
NOTE
While creating a record group, you do not specify its type explicitly. The type
is implied by when (design time or runtime) and how the record group is
defined.
A query record group is created implicitly when a LOV based on a query is
created. SET_LOV_PROPERTY built-in function can be used to replace the
default record group of a LOV. Use GROUP_NAME property in
SET_LOV_PROPERTY to do so.
Confidential
326
In frmLib form module, select the Record Groups node in the Object
Navigator and click the create icon. A New Record Group dialog box
is displayed.
Click OK. The dialog box is closed after Forms validates the SELECT
statement.
Click Static Values radio button and click OK. The Column
Specification dialog box is displayed.
Specify the Data Type, Length, and Column Values properties for
each of the column names as shown in the screen below:
Confidential
327
After creating the query record group, you can modify the column definition of a
record group by:
Opening the editor from the Record Group Query property and
modifying the SELECT statement as desired.
Clicking OK.
Confidential
328
Select the column whose properties you desire to change and then
click OK.
Confidential
329
Name
Description
Syntax
CREATE_GROUP
Creates a non-query
record group with the
name specified and
returns the ID
assigned to it. The
record group created
has no columns and
rows until added
explicitly
CREATE_GROUP
CREATE_GROUP_FROM_QUERY
Creates a query
record group of the
name specified based
on the given SELECT
statement. It returns
the ID assigned to the
record group.
(Recordgroup_name
VARCHAR2,
scope NUMBER
array_fetch_size
NUMBER);
CREATE_GROUP_FROM_
QUERY
(Recordgroup_name
VARCHAR2,
query VARCHAR2,
scope NUMBER,
array_fetch_size
NUMBER)
DELETE_GROUP
Deletes a
programmatically
created record group
DELETE_GROUP
(Recordgroup_name|Rec
ordgroup_ID VRACHAR2|
RECORDGROUP)
Confidential
330
Description
Syntax
ADD_GROUP_
ADD_GROUP_
COLUMN
COLUMN
(Recordgroup_name|Rec
ordgroup_ID VARCHAR2|
RECORDGROUP,
Groupcolumn_name
VARCHAR2,
Column_type NUMBER,
Column_width NUMBER);
ADD_GROUP_
ROW
ADD_GROUP_
ROW
(Recordgroup_name|Rec
ordgroup_ID VARCHAR2|
RECORDGROUP,
row_number NUMBER)
DELETE_GROUP_
ROW
DELETE_GROUP_ROW
(Recordgroup_name|Rec
ordgroup_ID VARCHAR2|
RECORDGROUP,
row_number NUMBER)
Confidential
331
NOTE
You can specify the column_type to be CHAR_COLUMN,
NUMBER_COLUMN, or DATE_COLUMN.
Column_width is specified only when column_type is CHAR_COLUMN
If you want to delete all the rows, specify row_number value as
ALL_ROWS. All the rows get deleted, but the group continues to exist.
Name
Description
Syntax
POPULATE_
POPULATE_
GROUP
POPULATE_
GROUP_WITH_
Confidential
GROUP
(Recordgroup_name|Recordgro
up_ID VARCHAR2|
RECORDGROUP);
POPULATE_
GROUP_WITH_
332
Name
Description
Syntax
QUERY
QUERY
(Recordgroup_name|Recordgro
up_ID VARCHAR2|
RECORDGROUP,
query VARCHAR2)
SET_GROUP_
CHAR_CELL,
SET_GROUP_
DATE_CELL,
SET_GROUP_
NUMBER_CELL
SET_GROUP_
CHAR_CELL| SET_GROUP_
NUMBER_CELL| SET_GROUP_
DATE_CELL
(groupcolumn_ID
GROUPCOLUMN,
row_number NUMBER,
cell_value VARCHAR2)
NOTE
A non-query record group can be converted into a query record
by using POPULATE_GROUP_WITH_QUERY built-in function.
The built-in functions used to obtain record group cell values are:
Name
Description
Syntax
GET_GROUP_
GET_GROUP_
CHAR_CELL,
GET_GROUP_
NUMBER_CELL,
GET_GROUP_
DATE_CELL
CHAR_CELL|
GET_GROUP_
NUMBER_CELL|
GET_GROUP_
DATE_CELL
(groupcolumn_ID
GROUPCOLUMN,
row_number
NUMBER)
Confidential
333
Name
Description
Syntax
GET_GROUP_
GET_GROUP_ROW_COUNT
ROW_COUNT
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP)
SET_GROUP_
SELECTION
SET_GROUP_
SELECTION
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP,
row_number NUMBER)
RESET_GROUP_
SELECTION
RESET_GROUP_
SELECTION
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP)
UNSET_GROUP_
SELECTION
UNSET_GROUP_
SELECTION
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP,
row_number NUMBER)
GET_GROUP_
SELECTION_
COUNT
GET_GROUP_
SELECTION_
COUNT
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP)
GET_GROUP_
SELECTION
GET_GROUP_
SELECTION
(Recordgroup_name|Record
group_ID VARCHAR2|
RECORDGROUP,
selection_number NUMBER)
Confidential
334
Name
Description
Syntax
FIND_GROUP
FIND_GROUP
FIND_COLUMN
FIND_COLUMN
(recordgroup_name
VARCHAR2)
(recordgroup_groupc
olumn_name
VARCHAR2)
The following code illustrates how to create and populate a query record
group programmatically:
DECLARE
vRgID RECORDGROUP;
vSuccessCode NUMBER;
BEGIN
-- Ensure the record group does not exist
vRgID:= FIND_GROUP (rgMember);
IF ID_NULL (vRgID) THEN
-- Create a query record group
vRgID:=CREATE_GROUP_FROM_QUERY (rgMember,
SELECT cMemberID, cFirstName, dMembershipDt FROM Member);
END IF;
--populate the record group
VSuccessCode: =POPULATE_GROUP (vRgID);
END;
The following code illustrates how to create and populate a non-query
record group programmatically:
DECLARE
vRgID RECORDGROUP;
vGc1ID GROUPCOLUMN;
vGc2ID GROUPCOLUMN;
BEGIN
--Ensure the record group does not exist
vRgID:=FIND_GROUP(rgMember);
Confidential
335
Confidential
336
Name
Description
Syntax
ADD_LIST_ELEMENT
CLEAR_LIST
DELETE_LIST_
ELEMENT
DELETE_LIST_
ELEMENT
(list_ID ITEM|list_name
VARCHAR2,
list_index NUMBER)
GET_LIST_ELEMENT_C
OUNT
GET_LIST_ELEMENT_L
ABEL
GET_LIST_
ELEMENT_COUNT
(list_ID ITEM|list_name
VARCHAR2)
GET_LIST_
ELEMENT_LABEL
(list_ID ITEM,
list_name VARCHAR2,
list_index NUMBER)
or
GET_LIST_ELEMENT_LABEL
(list_name VARCHAR2,
list_index NUMBER)
GET_LIST_ELEMENT_V
ALUE
Confidential
GET_LIST_
ELEMENT_VALUE
(list_ID ITEM|list_name
337
Name
Description
Syntax
specified position.
VARCHAR2,
list_index NUMBER)
POPULATE_LIST
POPULATE_LIST
(list_ID ITEM|list_name
VARCHAR2,
recordgroup_ID
RECORDGROUP|recordgroup
_name VARCHAR2)
RETRIEVE_LIST
(list_ID ITEM|list_name
VARCHAR2,
recordgroup_ID
RECORDGROUP|recordgroup
_name VARCHAR2)
POPULATE_LIST and RETRIEVE_LIST built-in functions make use of record groups, which are covered, in a later sess
Confidential
338
Summary
In this chapter you have learnt that:
Trigger statements that follow the call to OPEN_FORM built-in are never
executed when a form is opened with the parameter specified as
ACTIVATE.
There are two issues that you need to consider when forms are opened
within the same session. They are Commit Processing and Savepoint and
rollback processing.
Form Parameters can be used only as input parameters. This means the
invoked form cannot modify parameter values. Global Variables are
invoked form can modify global variable values.
Query record, Non-query record and Static record group are the three
types of record groups from which Query record and the Static record
groups are groups defined at design time.
Confidential
339
Lab Exercise
1. What are the different ways of calling a form?
2. Create a PRE-FORM to ensure that a global variable exits.
3. Create one new form module called TRANSACTION where Transaction
details are displayed.
4. Create a button called OPEN in the BOOKXX form module in Book tab.
5. Now call this Transaction form from BOOK form when the user clicks
on the OPEN button.
6. Save, compile and run the form.
7. Achieve the same functionality above by passing parameters between
the modules.
Confidential
340
Chapter 19
Managing Menus
Introduction to Menu Modules
The Menu Editor
Creating Menu Modules
Menu Module Properties
Menu Item Properties
Menu Item Types
Magic Items
Command Types
Menu Toolbars
Pop-up Menus
Controlling Menus Programmatically
Menu Security
Confidential
341
Objective
At the end of this chapter, you will be able to:
y Identify the components of the Menu module
y List various tools and functionality of Menu editor
y Create Menu modules
y Set Menu module properties using the property palette
y List various Menu item properties
y Learn about the Menu item types
y Know what are Magic items
y Describe Command types
y Create Menu toolbars
y Create Pop-up Menus
y Use menu built-ins for controlling Menus programmatically
y Implement Menu security
Confidential
342
y Menu
Menu exhibits as a pull-down menu, which consists of various options
horizontally displayed under the application window title.
In Forms, you can create the following three types of menus:
y Menu Item
A menu item is defined as an option that can be chosen from a menu.
Menu items have associated code to enable users to perform particular
actions.
y Menu Toolbar
Confidential
depicts
how
the
menu
module
components
are
343
Main Menu
Menu
Individual Menu
Menu
Menu
Item
Menu
Item
Menu
Item
Menu
Item
Menu
Item
Menu
Item
Menu
Item
Menu
Item
Submenu
Menu
Item
y Is not a separate menu module. That is, it is not a workable file. A readymade menu module (menudef.mmb) having same menu items as the
default form menu is shipped along with Oracle Forms Developer. You can
modify menudef.mmb menu module without worrying about changing the
default form menu permanently because default menu is an internal
component and not a file.
Confidential
344
Individual Menus
Menu Items
Action
Edit
Query
Block
Record
Field
Help
y A design area, which is similar to the one provided in the Layout Editor
y A drop down list to choose the object to be viewed
y A toolbar of icons to provide quick access to frequently used functions
The tools provided in the Menu Editor toolbar are as follows:
Tools
Functionality
Display Menu
Create Down
Create Right
Switch Orientation
Confidential
345
Tools->Menu Editor
NOTE
Invoking the Menu Editor causes the View and Navigator Form
Builder menus to be replaced with a single menu, Menu.
In the Menu Editor as shown below, you can expand or collapse individual
menus by clicking the arrow, which is to the right of the menu names. You can
drag the entire menu by using the menu handle, which is a gray tab to the left of
each menu name.
When an item is selected in the Menu Editor (Save) , it causes that item to be
selected in the Object Navigator (mnitSave). Similarly, an item selected in the
Object Navigator causes it to be selected in the Menu Editor.
Select the Menus node in the Object Navigator and click the
create icon or select File->New->Menu option
After creating the module mnLib, you need to create menus and menu items
within it. This is done in the Menu Editor.
Confidential
346
single
menu
item
MENU1
with
label
y Action
y Edit
y Query
y Sort By
The following Menu Editor screen shows the above-mentioned menu items
created within the main menu mnMainMenuLib.
After creating the main menu, you need to create individual menus for each of
the menus.
y In the Menu Editor select the parent item in the main menu.
Confidential
347
y Click the Create Down icon. Doing this creates an individual menu with the
name ACTION_MENU in the Object Navigator.
y Click the Create Down icon to add three more menu items to the Action
menu, namely Clear, Separator, and Exit.
y Similarly create menu items for Edit, Query, and Sort By repeating step
2 to step 5.
You can also specify the menu access key in the following way:
The following screen of the Object Navigator shows the mnLib created along
with its main menu mnMainMenuLib and individual menus ACTION_MENU,
EDIT_MENU, QUERY_MENU and SORT_BY_MENU.
Confidential
348
Creating Submenus
To create a submenu, you need to:
y Select the menu item from an individual menu for which a submenu is
required. For example,
SORT_BY_MENU.
select
mnitNames
menu
item
from
the
y Click the Create Right icon and rename the default label as Member
Names.
y Click the Create Right icon to create another item to the submenu, and
rename the label as Book Names.
The form module frmLib continues to use the default menu. In order to use the
customized menu, you need to first save it and then attach it to the form module.
Confidential
349
Either of these actions creates a file with .mmb extension. However, to use
mnLib you need to create an executable version of the saved file. This is done by
selecting the File menu->the Administration option->the Compile File option.
This creates a file with extension .mmx. Then it is this file that you will attach to
the form module. This executable file is not portable between operating systems.
Confidential
350
y Main Menu: Specifies the individual menu name in the menu module that
is the main or starting menu.
In case of a pull-down menu, the name of the first menu you create is
specified automatically as the main menu. In the menu hierarchy, you
cannot navigate above this menu.
y Startup Code: Specifies the PL/SQL code that gets executed when the
menu module is loaded in memory.
Confidential
351
y Module Roles: Displays the Menu Module Roles dialog box. You can list
the roles assigned to the menu module.
The roles listed must be assigned to individual menu items in the Menu
Editor. Assigning of module roles is covered in a later section.
On invoking the Property Palette of the individual menus created, such as
ACTION_MENU, the following properties are displayed:
The only functional property of a menu is Tear-Off Menu property. This property
is set to enable the menu to be repositioned (that is, change its positioning) on
the screen. However, this property is functional only if your window manager
supports this feature.
Confidential
352
Property Name
Enabled
Confidential
Used to:
Determine whether the menu item is available and can
be manipulated by mouse or is it disabled.
353
Property Name
Used to:
Label
Magic Item
Command Type
Submenu Name
Keyboard
Accelerator
Icon in Menu
Icon Filename
Function
Plain
Check
Boolean menu item having two states, i.e. the user can
check the item ON or OFF. Its functionality is defined
using PL/SQL
Radio
Separator
Confidential
354
Function
Magic
The menu item Property Palette displays the above mentioned item types as
follows:
Magic Items
Magic items provide the standard Graphical User Interface (GUI) actions. Most of
the magic items include default functionality. Therefore, actions such as copy or
paste are already defined. Users need to only set the item type to Magic and
specify the required action to be performed.
Confidential
355
The menu item Property Palette displays the following magic items:
The default functionality and the associated command types of the various magic
items are as follows:
Magic Items
Confidential
Command Type
Default Functionality?
356
Magic Items
Command Type
Default Functionality?
Cut
Null
Help
Menu
Quit
Null
Window
Null or Menu
Copy
Paste
Clear
Undo
About
Command Types
Menu items perform actions based on the commands specified for them. The
command type of most of the menu items is PL/SQL, as they execute PL/SQL
commands. A valid command type must be associated with every menu item.
The different command types available to choose from are as follows:
Confidential
357
NOTE
Plus, Macro, and Form command types are available only
for backward compatibility.
Confidential
358
54. PL/SQL: Executes a PL/SQL block including the use of built-in or userdefined subprograms
y Clicking the Menu Item Code in the menu item Property Palette.
y Selecting PL/SQL Editor from the pop-up menu by right clicking the
menu item in the Object Navigator or Menu Editor.
y Now that you are familiar with the various menu item types and command
types, you can set these properties for the menu items created within
mnLib menu module in the following way:
Invoke the PL/SQL Editor for any menu item, say mnitSave
Confidential
359
Similarly enter the code for all the remaining menu items.
Confidential
360
Menu Item
PL/SQL Code
Save
do_key(Commit_Form);
Exit
do_key(Exit_Form);
Clear
do_key(Clear_Form);
do_key(Clear_Item);
do_key(Clear_Field);
do_key(Clear_Block);
Editor
do_key(Edit);
Display List
do_key(List_Values);
Enter Query
do_key(Enter_Query);
Execute Query
do_key(Execute_Query);
Insert
do_key(Create_Record);
Remove
do_key(Delete_Record);
Help
do_key(Help);
do_key(Show_Keys);
Menu Toolbars
A set of buttons with icons representing menu items is known as a menu toolbar.
Menu toolbars enable developers to create shortcuts to menu commands without
duplicating code.
You can decide the menu toolbar orientation, i.e. whether to assign menu items
to a horizontal or vertical menu toolbar. A horizontal menu toolbar is located
beneath the main menu and a vertical menu toolbar is located to the left of a
form.
The following menu item properties need to be set in order to create a menu
toolbar:
Confidential
361
Property Name
Function
Visible in Horizontal
Menu Toolbar
Icon Filename
For example, to set the above properties for the following menu items perform
the following steps:
Similarly, set the above properties for the remaining menu items.
In addition to creating menu modules, you can also create pop-up menus.
Confidential
362
Pop-up Menus
Pop-up menus also known as context-sensitive menus belong to a form module,
unlike form menus that belong to a separate menu module. Pop-up menus (like
alerts, blocks, canvases, etc) are also top-level objects in the Object Navigator.
Pop-up menus enable users to access commonly used functions and commands.
Pop-up menus appear at the location on the screen where they were invoked and
can be accessed by:
Attach the pop-up menu to any of the data block items or canvas
by specifying the pop-up menu name in the Pop-up Menu
Property.
NOTE
In order to show the pop-up menu for the canvas; the mouse
must be on the canvas.
You can use PRE-POPUP-MENU trigger to provide dynamic
control of pop-up menus prior to their display.
The following screen displays the frmLib form module runtime environment with
the pop-up menu:
Confidential
363
Confidential
364
y Use DO_KEY built-in to fire the corresponding trigger from a menu item.
Since menu modules are built independently of form modules, there are certain
restrictions involved in using PL/SQL codes in menu item commands. They are:
y Do not set form module object values using direct assignment. Instead,
use the COPY built-in procedure. For instance,
: MEMBER.cFirstName: = Anninvalid
COPY (Ann, MEMBER.cFirstName)valid
Confidential
365
Built-in Subprograms
Description
FIND_MENU_ITEM
GET_MENU_ITEM_PROPERTY
SET_MENU_ITEM_PROPERTY
ITEM_ENABLED
MENU_SHOW_KEYS
Using the above mentioned built-in subprograms, you can write the following
PL/SQL code to find the ID of mnitImage of the mnQuery menu and check if its
CHECKED property is True. If so, then set it as False and vice versa.
DECLARE
idMenuItem MenuItem;
BEGIN
idMenuItem:=FIND_MENU_ITEM(mnQuery.mnitImage);
IF GET_MENU_ITEM_PROPERTY (idMenuItem, CHECKED)= TRUE
THEN
SET_MENU_ITEM_PROPERTY
PROPERTY_FALSE);
(idMenuItem,
CHECKED,
(idMenuItem,
CHECKED,
ELSE
SET_MENU_ITEM_PROPERTY
PROPERTY_TRUE);
END IF;
END;
The built-in subprograms used to replace, hide, and show the current menu are
as follows:
Confidential
366
Built-in Subprograms
Description
REPLACE_MENU
HIDE_MENU
SHOW_MENU
MENU_REDISPLAY
Menu Security
When you build a form module, it is automatically limited by the security enforced
by you on the Oracle server. However, you can also enforce client application
security. Therefore, Menu security implies setting up access rights on menu
items. There are two security policies to choose from:
Security Roles
The menu module property Use Security helps determine whether menu security
is implemented or not. This property enables menu security to be disabled
temporarily without altering menu setting for each item.
Setting this property On is the first step in implementing menu security.
To set this property:
y Invoke the Property Palette of the menu module, say mnLib in the
Object Navigator.
y In the Menu Security node, locate the Use Security property and set its
value to Yes.
If this property is set as No,
y No security is enforced
y All menu items can be accessed by users
y Application can be tested without being a member of all roles
Confidential
367
NOTE
You must recompile the menu module in case Use Security
property is modified.
After having enabled the menu module security function, you need to define
security roles.
For example, create roles to insert, delete and select, update and select, and
select as follows:
CREATE ROLE Ins;
CREATE ROLE DelSel;
CREATE ROLE UpdSel;
CREATE ROLE Sel;
Grant privileges to the roles created and grant the roles to users such as:
Enter the names of the roles that should be able to access this menu
Confidential
368
You will be presented with the list of roles you had assigned in the
menu Module Roles property.
Select the desired role from the list to access the menu item
Confidential
369
Confidential
370
Summary
In this chapter, you have learnt that:
y A menu item is defined as an option that can be chosen from a menu with
Menu items having associated code to enable users to perform particular
actions.
y Startup Code, Share Library with Form, Use Security and Module Roles are
to be specified if the menu module is saved to the database.
y Startup Code specifies the PL/SQL code that gets executed when the menu
module is loaded in memory.
y Magic items provide the standard Graphical User Interface (GUI) actions
out of which most of them include default functionality.
y The command type of most of the menu items is PL/SQL, as they execute
PL/SQL commands. Null, Menu etc. are different command types available
to choose from.
y Menu toolbar is a set of buttons with icons representing menu items and it
enables developers to create shortcuts to menu commands without
duplicating the code.
y You can also hide, display and replace the current menu by using built-in
menu subprograms in the PL/SQL codes written for each menu item.
y Menu security implies setting up access rights on menu items. The two
security policies, you have to choose are granting users access to all the
menu items in a module and granting users access to only specific menu
items in a module.
Confidential
371
Lab Exercise
1. Create a menu module with Action, Edit, Query, Block, Record, Field and
About as the menu items.
2. Under the FILE_MENU, create two items namely Save and Exit.
3. Under the EDIT_MENU, create three items namely Cut, Copy and Paste.
4. Under the QUERY_MENU, create three items namely Enter, Execute and
Cancel.
5. Under the BLOCK_MENU, create three items namely Previous, Next and
Clear.
6. Under the RECORD_MENU, create five items namely Previous, Next,
Insert, Remove, Clear.
7. Under the FIELD_MENU, create four items namely Previous, Next, Clear,
Duplicate.
8. Under the ABOUT_MENU, create only one item namely forms10g.
9. Now after creating the menu write functionality to each and every item.
10. Now compile the menu and attach this menu module to the form module.
Save, compile and run the form.
Confidential
372