Build Forms II - Volume 1 - Instructor Guide
Build Forms II - Volume 1 - Instructor Guide
Build Forms II - Volume 1 - Instructor Guide
Build Forms II
.......................................................................................
44112GC10
Production 1.0
May 1999
M08751
Author Copyright Oracle Corporation, 1999. All rights reserved.
Mark Doran If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Rights,” as defined in
Gillian Elias
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Tushar Gadhia
The information in this document is subject to change without notice. If you find
Stephen Gramann any problems in the documentation, please report them in writing to Education
Nancy Greenberg Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Ursula Hovy Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Uwe Jentzsch
Oracle Developer, Oracle Server, and PL/SQL are trademarks or registered
Leta A. Johnson
trademarks of Oracle Corporation.
Jan Keuben
All other products or company names are used for identification purposes only,
Steve Lirette and may be trademarks of their respective owners.
Jayne Marlow
Rita Morin
Daphne Nougier
Christin Nowakowski
Bryan Roberts
Bert Salyga
Helene Schwann
Hiroyuki Sugiyama
Pal Tarcsay
Bart Van der Laar
Jack Walsh
Publisher
Kelly Lee
Sherry Polm
Contents
.....................................................................................................................................................
Preface
Profile xv
Related Publications xvi
Typographic Conventions xvii
.....................................................................................................................................................
Oracle Developer: Build Forms II iii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
iv Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Forms II v
Contents
.....................................................................................................................................................
.....................................................................................................................................................
vi Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Forms II vii
Contents
.....................................................................................................................................................
.....................................................................................................................................................
viii Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................
.....................................................................................................................................................
Oracle Developer: Build Forms II ix
Contents
.....................................................................................................................................................
.....................................................................................................................................................
x Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................
Summary C-35
.....................................................................................................................................................
Oracle Developer: Build Forms II xi
Contents
.....................................................................................................................................................
.....................................................................................................................................................
xii Oracle Developer: Build Forms II
Preface
.................................
Preface
.....................................................................................................................................................
Instructor Note
General course information for instructors:
PowerPoint Slides The slide show provides many builds to facilitate your
explanation. Of course, you can modify these builds if you prefer, depending
upon your familiarity with PowerPoint.
All slides include a small arrow at the bottom of the screen that is displayed
on the final build, so that you know when one slide finishes and the next
slide begins. On the last slide of a lesson the arrow points to the left instead
of the right.
If you modify a build, make sure that this arrow is the last object in the build
order.
Practice Sessions Students might want to view the form that they are
asked to produce in each question. Solution files of all forms are available in
the LAB_SOL directory. You can also launch them from Project Builder.
See Appendix J “Instructor Note” for additional information.
.....................................................................................................................................................
xiv Oracle Developer: Build Forms II
Profile
.....................................................................................................................................................
Profile
Before You Begin This Course
Before you begin this course, you should have the following qualifications:
• Thorough knowledge of:
- Creating simple applications with Oracle Developer Form Builder
- Creating SQL query statements
• Working experience of:
- Creating PL/SQL constructs, including conditional statements,
procedures, and functions
- Creating PL/SQL stored (server) procedures and functions
• Knowledge of using a graphical user interface (GUI)
Prerequisites
The following instructor-led training (ILT) course: Oracle Developer: Build
Forms I
.....................................................................................................................................................
Oracle Developer: Build Forms II xv
Preface
.....................................................................................................................................................
Related Publications
Oracle Publications
Title Part Number
Oracle Developer Guidelines for Building Applications, A50994-1
Release 6
Oracle Developer Getting Started, Release 6 A50995-1
Additional Publications
• read.me file
• relnotes.pdf file
.....................................................................................................................................................
xvi Oracle Developer: Build Forms II
Typographic Conventions
.....................................................................................................................................................
Typographic Conventions
Typographic Conventions in Text
Convention Element Example
Bold italic Glossary term (if The algorithm inserts the new key.
there is a glossary)
Caps and lowercase Buttons, Click the Executable button.
check boxes, Select the Can’t Delete Card check box.
triggers,
Assign a When-Validate-Item trigger . . .
windows
Open the Master Schedule window.
Courier new, Code output, Code output: debug.seti(’I’,300);
case sensitive directory names, Directory: bin (DOS), $FMHOME (UNIX)
(default is filenames,
Filename: Locate the init.ora file.
lowercase) passwords,
pathnames, Password: Use tiger as your password.
URLs, Pathname: Open c:\my_docs\projects
user input, URL: Go to http://www.oracle.com
usernames User input: Enter 300
Username: Log on as scott
Initial cap Graphics labels Customer address (but Oracle Payables)
(unless the term is a
proper noun)
Italic Emphasized words Do not save changes to the database.
and phrases, For further information, see Oracle7 Server
titles of books SQL Language Reference Manual.
and courses,
Enter [email protected], where
variables
user_id is the name of the user.
Quotation marks Interface elements Select “Include a reusable module
with long names component” and click Finish.
that have only This subject is covered in Unit II, Lesson 3,
initial caps; lesson “Working with Objects.”
and chapter titles in
cross-references
Uppercase SQL column Use the SELECT command to view
names, commands, information stored in the LAST_NAME
functions, schemas, column of the EMP table.
table names
.....................................................................................................................................................
Oracle Developer: Build Forms II xvii
Preface
.....................................................................................................................................................
.....................................................................................................................................................
xviii Oracle Developer: Build Forms II
1
................................
Managing Projects
with Project Builder
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Objectives
After completing this lesson, you should
be able to do the following:
• Define Project Builder terminology
• Identify the uses of Project Builder
• Recognize the components of the
Project Builder user interface
• Create projects and subprojects
Objectives
• Invoke actions associated with entries
• Create entries from files and
subdirectories
• Establish dependencies among project
entries
• Build files and projects
• Deliver a project by using the Delivery
Wizard
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 25 minutes
Total 65 minutes
......................................................................................................................................................
1-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
One of the most difficult aspects of application development is managing the files that
make up an application. Large applications can consist of hundreds of files and
millions of lines of code. In addition, files that are important to the project as a whole
but that are not compiled into the application itself, such as design specifications, test
scripts, and documentation, must also be tracked and maintained. This lesson explains
how to use Oracle Developer Project Builder to help you manage application
development.
Additional Project Builder features are covered in Appendix C, “Project Builder
Addendum.”
Objectives
After completing this lesson, you should be able to do the following:
• Define Project Builder terminology
• Identify the uses of Project Builder
• Recognize the components of the Project Builder user interface
• Create projects and subprojects
• Invoke actions associated with entries
• Create entries from files and subdirectories
• Establish dependencies among project entries
• Build files and projects
• Deliver a project by using the Delivery Wizard
Instructor Note
Individual components—Form Builder, Report Builder, and so on—do not have splash
screens. You see a splash screen only when you start Project Builder.
Oracle Developer demonstrations include the project file that was used to create them.
This file provides an excellent prebuilt demonstration that you can use to show
students all the capabilities of Project Builder.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-3
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-4 Oracle Developer: Build Forms II
Introducing Project Builder
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-5
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Term Description
Project Collection of components
Subproject Projects contained within other projects
Type Type
Built-in
Actions Macros Actions
Macros Macros
Global Registry User
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Demonstration: Use the Oracle Developer: Build Forms II project to illustrate the
terminology. Show the different nodes, the Build From FMB action for the Form
Builder executable type, and also the ORACONNECT macro.
......................................................................................................................................................
1-6 Oracle Developer: Build Forms II
Project Builder Terminology
......................................................................................................................................................
Term Description
Project A project is a collection of pointers to the files that compose an application.
Files might include form modules, icons, or C source.
Subproject A subproject is a project contained within another project, and it enables a
finer level of organizational granularity. You can organize your forms,
reports, and displays in their own subdirectories, or even organize your direc-
tories by functional groups corresponding to sections of your application.
Project A project entry is a representation of a file in your application. When you
Entry delete a project entry from the Project Navigator, you do not delete the file,
only a pointer to the file.
Type A type is a category of file to which a file belongs, such as form, report, or C
source. A type determines which actions can be performed against files of
that type. Project Builder recognizes file types primarily by default extension;
for example, .txt for text files.
Action An action is a command string that applies to types, such as print, edit, or
build. Actions can act on individual components or on several components at
a time.
Macro A macro is a variable used to customize and extend actions.
There are several predefined macros, such as {name} and {path}.
For example, Project Builder inserts all the information you have
specified for connecting to a database into the ORACONNECT macro, which
is included in all commands that require database connection. The informa-
tion in the macro is then inserted into the action so you can log on automati-
cally.
Registry A registry is a storehouse of information about a project.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-7
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Instructor Note
Insist on the word deliver. Do not use the word deploy. Project Builder is not yet able
to deploy an application to end users. The only thing that Project Builder does is
package a set of files.
......................................................................................................................................................
1-8 Oracle Developer: Build Forms II
Project Builder Benefits
......................................................................................................................................................
Automating Actions
Project Builder enables you to initiate on files common actions such as Edit, Print, and
Build from directly within the Project Navigator. Project Builder ships with default
actions that can be modified and customized. Customization of actions is covered in
Appendix C, “Project Builder Addendum.”
......................................................................................................................................................
Oracle Developer: Build Forms II 1-9
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Instructor Note
Demonstration: Use the Oracle Developer: Build Forms II project to show the
components. Expand the Summit application subproject node, and change the Project
Navigator view. Launch Form Builder from the Launcher.
......................................................................................................................................................
1-10 Oracle Developer: Build Forms II
Project Builder User Interface
......................................................................................................................................................
View Description
Project view The entries in a project are organized by project and subproject, then
by type. This is useful to see all of the entries of a particular type, for
example, all of the PL/SQL libraries used in a project.
Dependency view The entries in a project are organized by dependencies between files;
for example, an object file depends on a source file and a number of
header files.
The Launcher
Project Builder also provides the Launcher, a customizable toolbar to which you can
add all the tools, including third-party tools, that you need to edit your project file.
Customizing the Launcher is covered in Appendix C, “Project Builder Addendum.”
......................................................................................................................................................
Oracle Developer: Build Forms II 1-11
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
• Filtered views
• Password protection
......................................................................................................................................................
1-12 Oracle Developer: Build Forms II
Project Builder User Interface
......................................................................................................................................................
Filtered Views
A filter allows you to display only those projects or project items in the Project
Navigator that meet certain criteria. When you apply a filter, the objects that do not
match the criteria specified in the filter definition are hidden from view.
To create a filter, select Navigator—>Manage Filters from the main menu. Click the
Add Filter button. The Add Filter dialog box is displayed. Enter a name for the filter in
the Filter name field.
Use the tabs (General, File, Project, Delivery, Connection, and Macros) to specify
values for the project or item properties you want the filter to locate. All properties are
joined by AND; no provisions are made for OR conditions. As you add criteria, the
filter definition is recorded in the Current filter criteria field.
To remove criteria from your filter, select the property and its value in the Current
filter criteria field and click Remove.
When you finish creating your filter, click the OK button.
Password Protection
You can set passwords for projects to protect them from unauthorized viewing or
modification. When a user tries to open a password-protected project, a dialog
prompts the user to enter the password. If the user cannot supply the correct password,
access to the project is denied.
To set a password for a project file select the node for the project you want to protect.
Select FileAdministration—>Set Project Password to display the Set Project Password
dialog.
Enter the password in the New password field. The password may be of any length and
may contain any characters. The password does not expire. Enter the password again
in the Confirm password field to verify the spelling. Click the OK button.
When you or another user attempts to open this project, a dialog prompts you to enter
the password.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-13
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Creating Projects
and Subprojects
Instructor Note
Demonstration: Create a new project by using the Project Wizard. Name your project
Summit Application and add all the files for the Summit application. Explain that a
connection is a named set of a username, a password, and a connect string that can be
assigned as a group to a project entry or type.
......................................................................................................................................................
1-14 Oracle Developer: Build Forms II
Creating Projects and Subprojects
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-15
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Instructor Note
The directory structure of a project can have far-reaching consequences. Suppose you
include modules in a project that are located in a directory that is not a child of the
project directory. Then you create actions that search for and modify project modules.
How will you find the “orphan” modules? How will you create alternative actions with
hard-coded paths? It is not portable. Perhaps you can search from the root, but this is
not efficient.
Recommendations:
• Locate modules in the project directory or in a directory that is a child of
the project directory (a good choice when adding subprojects).
• Use only relative paths. In other words, create a project and subprojects
that mirror your actual directory structure.
......................................................................................................................................................
1-16 Oracle Developer: Build Forms II
Adding Project Files
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-17
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Creating Subprojects
from Subdirectories
Instructor Note
Create a subproject from a subdirectory. You can use the directory structure where the
instructor demo files are stored.
......................................................................................................................................................
1-18 Oracle Developer: Build Forms II
Subdirectories Added as Subprojects
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-19
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Creating Connections
Instructor Note
Demonstration: Create a connection. Add it to a project and to an entry.
......................................................................................................................................................
1-20 Oracle Developer: Build Forms II
Creating Connections
......................................................................................................................................................
Creating Connections
In a typical project, the developer has a number of databases to work against. For
example, there might be a small “scratch” database where the developer can create any
test data he or she needs; a large test database that contains the data for a formal test
suite; and perhaps databases running different versions of Oracle to test backward
compatibility or new features.
With Project Builder the developer can define and save the connect strings associated
with these various databases, and then easily associate those connections with the
project files, simply by dragging a connection and dropping it on the entry for the file.
When the Form module is next opened from Project Builder, Form Builder
automatically connects to the database before opening the form.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-21
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Instructor Note
Demonstration:
• Open a Form Builder file.
• Edit a SQL file or a text file.
• Show how to create and assign a connect string, because students will
have to do it in the practice session.
• Display the Property Palette by selecting Tools––>Property Palette.
Mention that it is impossible to describe all the properties, because they
differ from type to type. Explain that the properties are classified by
family:
- General information
- Connections
- Actions
- Macros
Do not demonstrate the other options. They are covered later in this lesson. Just
explain what they mean.
......................................................................................................................................................
1-22 Oracle Developer: Build Forms II
Working with Project Files
......................................................................................................................................................
Editing Files
Project Builder comes with a large number of the most common actions already
defined. For example:
• Selecting Open from the pop-up menu for a text file may invoke
Notepad.
• Selecting Open from the pop-up menu for a form may invoke Form
Builder.
If necessary, you can modify the predefined commands for any type. You can also
launch a tool from the Launcher. For more information, see Appendix C, “Project
Builder Addendum.”
......................................................................................................................................................
Oracle Developer: Build Forms II 1-23
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Implicit Dependencies
Explicit Dependencies
Add explicit
dependencies in the
Navigator:
• Select the parent,
click Add Files.
• Cut the child; paste
it onto the parent.
Select Navigator—>
Dependency View.
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
To explain the needs of explicit dependencies, you can use the dependence between
two.fmb files. When you make an object a subclass of a form and you change the
parent definition. you must build the child.
......................................................................................................................................................
1-24 Oracle Developer: Build Forms II
Establishing Dependencies
......................................................................................................................................................
Establishing Dependencies
Project dependencies refer to the order in which project entries depend on each other.
For example, a Form Builder executable file (.fmx) depends on a Form Builder
module file (.fmb), which may depend on a Form Builder library file (.pll), and so
on.
Implicit Dependencies
Project Builder automatically deduces many dependencies from the Deliverable Type
property and the Build From <type> action of interdependent types.
• The Deliverable Type property specifies whether the type of file
delivered to the end user.
• The Build From <type> action specifies the command used to build a file
of a given type.
Example
The type Form Builder module (.fmb files) has a deliverable type of Form Builder
executable (.fmx files). Therefore, Project Builder can deduce that any .fmx files in
your project are dependent on the associated .fmb files, and if those .fmb files
change, the .fmx files must be rebuilt based on the Build From <type> action defined
for the Forms Executable (.fmx) type. If there is no .fmx file already in your project,
Project Builder will show it as an item that is implied by the existence of the .fmb.
Explicit Dependencies
Sometimes you will have dependencies that Project Builder cannot determine
automatically. For instance, your form may contain calls to program units in a PL/SQL
library. If the interfaces to the program units in the library change, you need to rebuild
the Form Builder executable (.fmx).
To allow the developer to include such dependencies in the project definition,
dependencies can be added manually. To indicate that an .fmx depends on a PL/SQL
library:
1 Select the entry (.fmx file).
2 Select Project––>Add Files to Project.
3 Select the files to be added as a dependency of the selected entry.
Note: To see the dependencies in the project, select Dependency View in the Project
Navigator.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-25
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Building Projects
Three build options:
1
2
3
Copyright Oracle Corporation, 1999. All rights reserved.
Callouts
1 Build All
2 Build Selection
3 Build Incremental
Instructor Note
Demonstration: Show all the options.
If you want to demonstrate the Build Selection option, be sure to select the .fmx
entries, and be sure not to select the .fmb entries.
If you want to demonstrate the Build All option, be sure that you illustrate this option
on a small project (with few files). Use, for example, the project that you created
earlier (Summit Application).
......................................................................................................................................................
1-26 Oracle Developer: Build Forms II
Building Projects
......................................................................................................................................................
Building Projects
Project Builder easily enables you to ensure that the “build” is up-to-date. You can
update your project and build all dependencies by using one of three build options in
the Project Builder Project menu:
......................................................................................................................................................
Oracle Developer: Build Forms II 1-27
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-28 Oracle Developer: Build Forms II
Delivering Projects
......................................................................................................................................................
Delivering Projects
After a project is completed, the remaining task is to deliver the executable files, help
files, supporting media (such as sounds, images, videos, or icons), and any other files
that the end user will need to have installed. Typically, the delivery process involves
setting certain delivery properties and invoking the delivery wizard.
......................................................................................................................................................
Oracle Developer: Build Forms II 1-29
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Instructor Note
Demonstration: Deliver a project as an Oracle Installer script.
......................................................................................................................................................
1-30 Oracle Developer: Build Forms II
Delivering Projects
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-31
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
n
Summary
Instructor Note
For additional information about Project Builder, and especially how to use Project
Builder in a team environment, see Appendix C, “Project Builder Addendum.”
......................................................................................................................................................
1-32 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Project Builder Basics
• Define Project Builder terminology
• Identify Project Builder uses
• Describe Project Navigator features
Building a Project
• Create projects and subprojects
• Create connections
• Open project files
• Build and deliver projects
Note: For additional information about Project Builder, see Appendix C, “Project
Builder Addendum.”
......................................................................................................................................................
Oracle Developer: Build Forms II 1-33
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Practice 1 Overview
Practice Solutions
For practice solutions, see Appendix A, “Practice Solutions.”
......................................................................................................................................................
1-34 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 1
......................................................................................................................................................
Practice Contents
• Create an initial project
• Create a connection
• Experiment with various Project Navigator views
• Create subprojects and add files and subdirectories to them
• Deliver a project
......................................................................................................................................................
Oracle Developer: Build Forms II 1-35
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Practice 1
1 Create a connection to the database.
a Create a new connection.
b Name the connection SUMMIT and specify the connect string. Your
instructor should provide this information.
2 Create an initial project.
a Create a new project (use the Project Wizard).
b Name the project “Oracle Developer: Build Forms II”. Assign to this
project the connection created earlier, and save it as summit.upd in
the Lab directory. Do not add files to this project.
a Using the Project Wizard, create a subproject named Summit
Application that belongs to Oracle Developer: Build Forms II.
b From the labs directory, add:
- baseball.tif
- calendar.pll
- copy.ico
- customers.fmb
- Form_Builder_II.olb
- pr11_2f.txt
- pr7_3a.sql
c Give a file items a more meaningful title.
3 Create a subproject and add files to it.
4 Explore the Project Navigator.
a Examine the state of the Project Navigator. Note that Project Builder
has added executable versions of the Oracle source files that you
added to the project.
b Turn off the Show Implicit Items option. Note what happens to the
Project Navigator display.
c Experiment with Project Builder’s different views.
5 Deliver the project.
a Invoke the Delivery Wizard and deliver all files.
b Create Oracle Installer scripts on your local file system.
c Include all the deliverable files in the project.
d Accept the default delivery directories.
......................................................................................................................................................
1-36 Oracle Developer: Build Forms II
Practice 1
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 1-37
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-38 Oracle Developer: Build Forms II
2
................................
Objectives
After completing this lesson, you should
be able to do the following:
• Identify the components of a menu
• Create, save, and attach menu modules
• Set menu properties by using the
Property Palette
• Create menu toolbars
• Create pop-up menus
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 40 minutes
Total 90 minutes
......................................................................................................................................................
2-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
By default, each form module uses the same menu structure, called the Default menu.
This lesson teaches you how to customize this menu and how to create your own menu
modules. You will also learn how to enhance your application by including menu
toolbars and pop-up menus.
Objectives
After completing this lesson, you should be able to do the following:
• Identify the different components of a menu module
• Create, save, and attach menu modules
• Set menu properties by using the Property Palette
• Create menu toolbars
• Create pop-up menus
......................................................................................................................................................
Oracle Developer: Build Forms II 2-3
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Main
Individual menu Menu toolbar
menu
Copyright Oracle Corporation, 1999. All rights reserved.
Menu
module
Individual Menu Menu Individual
menu item item menu
Menu
Submenu
items
Menu
items
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Demonstration: Run the Orders form (orders.fmb) to explain the components.
Open the Default menu (menudef.mmb) to illustrate the hierarchical structure of a
menu.
......................................................................................................................................................
2-4 Oracle Developer: Build Forms II
Components of the Menu Module
......................................................................................................................................................
What Is a Menu?
A menu is a list of related options. Each option performs a different action. You can
create three menu types in Forms:
• Main menu:
- Displays horizontally in the menu bar
- Contains options (menu items) that are typically individual menus
• Individual menu: Displays vertically
• Submenu: Displays vertically and to the right of the menu item that
calls it
......................................................................................................................................................
Oracle Developer: Build Forms II 2-5
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Default Menu
Action Edit Query Block Record Field Help
Instructor Note
The path for menudef.mmb is
ORACLE_HOME/Tools/Devdem60/Demo/Forms.
Open the Default menu (menudef.mmb), and show the menu items in the menu
editor.
......................................................................................................................................................
2-6 Oracle Developer: Build Forms II
The Default Menu
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 2-7
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Technical Note
By default, the Menu Editor displays a pull-down menu, with the
top-level menu displayed horizontally. If you are developing a full-screen menu, you
may want to display the top-level menu vertically, so that the display matches the way
your menu will appear at run time. To change the orientation, click the Switch
Orientation button.
Instructor Note
In the Menu Editor, the key sequences [Ctrl] + the down arrow and [Ctrl] + the right
arrow create, respectively, a menu item below and to the right of an existing object.
Use the Default menu (menudef.mmb) to show the Menu Editor functionalities.
Show the steps to move a menu or a menu item. Show the steps to copy a menu to
another level. Explain the alert duplicate menu or reuse the original. Demonstrate that
if you move a submenu to a parent item with the Command Type property set to PL/
SQL or Null, Form Builder displays an alert.
......................................................................................................................................................
2-8 Oracle Developer: Build Forms II
The Menu Editor
......................................................................................................................................................
Tool Function
Display Determines the highest level menu that the Menu Editor displays. (Choose
Menu from all the menus in your menu module.)
Create Down Creates a new menu item below the currently active one
Create Right Creates a new menu item to the right of the currently active one
Switch Allows display of the top-level menu vertically or horizontally
Orientation
......................................................................................................................................................
Oracle Developer: Build Forms II 2-9
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Instructor Note
Create the following menu:
File Edit Query
Save Clear Record Enter
Exit Clear Block Execute
Sort > By Order Id
By Order Date
......................................................................................................................................................
2-10 Oracle Developer: Build Forms II
Creating a Menu Module
......................................................................................................................................................
Creating a Submenu
1 Select the parent item on the individual menu.
2 Click the Create Right icon.
3 Replace the default label.
4 Select Menu—>Create Down to add another item to the submenu.
5 Replace the default label.
6 Repeat steps 4 and 5 to add more submenu items.
......................................................................................................................................................
Oracle Developer: Build Forms II 2-11
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Main Menu
Menu Directory
Menu Filename
Startup Code
Share Library with Form
Use Security
Module Roles
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Do not spend a long time going through all the menu module properties; instead point
out that they are here for convenience. Also, context-sensitive help is available.
......................................................................................................................................................
2-12 Oracle Developer: Build Forms II
Module Properties
......................................................................................................................................................
Module Properties
Property Description
Main Menu Property that specifies the name of the individual menu in the module
that is the main or starting menu at run time
For a pull-down menu, the main menu is automatically set to the name
of the first menu that you create. Users cannot navigate above this
menu in the menu hierarchy.
Menu Directory Path used by Forms as a pointer to the directory for the run-time .mmx
file; only used by menu modules that are saved to the database
Menu Filename Filename used by Forms as a pointer to the run-time .mmx file; only
used by menu modules that are saved to the database
Startup Code PL/SQL code executed when a menu module is loaded in memory
Share Library Property that enables to be loaded in memory a single copy of a PL/
with Form SQL library, if this library is used by the form module and the menu
module
Use Security Property that when set to Yes enforces security at run time (Set this
property to No to test the menu module without having to be a member
of any database role.)
Module Roles Property that displays the Menu Module Roles dialog box, where you
can list the roles assigned to the menu module (Roles defined must be
assigned to individual menu items in the Menu Editor.)
......................................................................................................................................................
Oracle Developer: Build Forms II 2-13
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Menu Properties
Instructor Note
Do not spend a long time going through all the menu properties; instead point out that
they are here for convenience.
The Tear-Off property is available for the Motif window manager.
......................................................................................................................................................
2-14 Oracle Developer: Build Forms II
Menu Properties
......................................................................................................................................................
Menu Properties
Property Description
Tear-Off Menu Enables the menu to be dragged from the menu bar and repositioned
elsewhere on the screen (available only if your window manager
supports this feature)
......................................................................................................................................................
Oracle Developer: Build Forms II 2-15
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Technical Note
Radio menu items must belong to a radio group. All of the radio items for a radio
group must be contiguous on the same menu. Radio group names are internal names
that are not displayed at run time.
Instructor Note
The mappings of logical accelerator keys to physical device keys are defined in the
run-time resource file. You must edit the resource file in Oracle Terminal to change the
key mappings. You can also create additional accelerator keys in Oracle Terminal
(ACCELERATOR6, ACCELERATOR7, and so on), which you can then associate
with menu items in a menu module.
Demonstration next page: Use the Summit menu (m_summit.mmb) file to show the
different menu item types. You can attach it to the ORDERS form and run it to
illustrate the menu items at run time. You can also use the Customized menu
(menu.mmb) file.
......................................................................................................................................................
2-16 Oracle Developer: Build Forms II
Menu Item Properties
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 2-17
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Plain
Check
Radio
Magic
Separator
Magic Items
• About • Paste
• Undo • Help
• Clear • Quit
• Copy • Window
• Cut
......................................................................................................................................................
2-18 Oracle Developer: Build Forms II
Menu Item Types
......................................................................................................................................................
Magic Items
Some Magic menu items include default functionality. Because a Magic item
provides the standard actions of a graphical user interface (GUI), a copy or
paste action is already defined at the menu level. All you need to do is set the
item to the Magic type and define the desired action (standard or specific).
Magic Item Command Type Default Functionality?
About Any except Menu No. You must assign a command to these
Undo items to perform the desired function.
Clear Null Yes. These items perform the default
Copy operations indicated by their names.
Paste
Cut
Help Menu No. You must define a submenu to be
called by the Magic Help item, and you
must assign commands to the items on
that submenu.
Quit Null Yes. The Quit command, by default, exits
from the form after asking the user to
save any changes.
Window Null or Menu Yes. The window item invokes a default
submenu that lists all open windows.
Users can activate a window by selecting
it from the submenu.
......................................................................................................................................................
Oracle Developer: Build Forms II 2-19
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-20 Oracle Developer: Build Forms II
Menu Item Command Types
......................................................................................................................................................
Note: The command types of Form and Macro are available for compatibility with
SQL*Menu V4.0. and SQL*Menu V.5.0.
......................................................................................................................................................
Oracle Developer: Build Forms II 2-21
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Technical Note
For more flexible or complex requirements, use the existing Toolbar canvas in form
modules.
Instructor Note
The Default menu toolbar works very well; however, building your own menu and
menu toolbar is not so easy. For example, you have to create separator items for every
space that you require to group the items. Also, the menu toolbar icons appear in
exactly the same order as the menu options, which might not be what you want.
Demonstration: Use the menu that you created earlier, and set the properties to display
the Save option in a menu toolbar. Use the save.ico file.
......................................................................................................................................................
2-22 Oracle Developer: Build Forms II
Implementing Menu Toolbars
......................................................................................................................................................
Property Description
Visible in Horizontal Specifies that the menu item should appear (represented by an
Menu Toolbar icon) on the horizontal toolbar of a form
Visible in Vertical Specifies that the menu item should appear (represented by an
Menu Toolbar icon) on the vertical toolbar of a form
Icon Filename Specifies the name of the icon resource that you want to represent
the iconic button
......................................................................................................................................................
Oracle Developer: Build Forms II 2-23
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-24 Oracle Developer: Build Forms II
Storing the Menu Module
......................................................................................................................................................
You can save your menu module definition by either of the following actions:
• Clicking the Save icon in the Object Navigator
• Selecting File—>Save
......................................................................................................................................................
Oracle Developer: Build Forms II 2-25
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Menu Specify
module that menu
to use with module
this form is stored
module in the file
system
Technical Note
If you want to use the Default menu without the associated menu toolbar, replace the
value DEFAULT&SMARTBAR in the Menu Module property with DEFAULT only.
......................................................................................................................................................
2-26 Oracle Developer: Build Forms II
Attaching the Menu Module
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 2-27
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Instructor Note
Demonstration: Run the Customers form (customers.fmb) demonstration.
Navigate to the Comments item, and click the right mouse button.
......................................................................................................................................................
2-28 Oracle Developer: Build Forms II
Pop-up Menus
......................................................................................................................................................
Pop-up Menus
Pop-up menus are context-sensitive menus. You attach pop-up menus to an item or
canvas, and display them by right click on that item or canvas. Pop-up menus enable
end users to quickly access common functions and commands.
Pop-up menus are top-level objects in the Object Navigator (similar to alerts, blocks,
canvases, and so on) and belong to a form module (as opposed to form menus, which
belong to a separate menu module).
Items on a pop-up menu should be contextual to the menu’s associated objects. For
example, you would not include text-editing items on the
pop-up menu for a two-digit numeric item. You might include such items on the pop-
up menu for a multiline text item, however.
Pre-Popup-Menu Trigger
You can use this trigger to add dynamic control at run time, prior to displaying the
menu. For example, you can use the trigger to identify the cursor context and navigate
to a different item if necessary.
Instructor Note
Beginning with release 6, pop-up menus support icons, check boxes, and option
buttons.
......................................................................................................................................................
Oracle Developer: Build Forms II 2-29
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Summary
......................................................................................................................................................
2-30 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
In this lesson, you learned how to add, create, and customize menu modules.
Properties •
• Menu module properties
• Menu properties
• Menu item properties
......................................................................................................................................................
Oracle Developer: Build Forms II 2-31
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Practice 2 Overview
Instructor Note
The practice overview in this lesson and the ones that follow are provided only as
guides. Outline the practice in the level of detail appropriate for the course
participants.
For this lab, use the DO_KEY built-in. At this stage of the course, students do not
yet know this built-in. Explain it briefly and tell them that it is covered in detail in
Lesson 4.
......................................................................................................................................................
2-32 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 2
......................................................................................................................................................
Practice Contents
• Create a simple menu module
• Incorporate menu items in the menu toolbar
• Compile and attach a menu to a form
• Create a pop-up menu
......................................................................................................................................................
Oracle Developer: Build Forms II 2-33
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Practice 2
1 Create a new menu module.
a Using the following screenshot as a guideline, create a new menu
module called M_SUMMIT.
• File Menu
Visible in
Menu Visible Horiz.
Item Command Menu Item in Menu Icon
Label Type Type Code Menu Toolbar Filename
Save Plain PL/SQL DO_KEY(’CO Yes Yes Save
MMIT_FORM’
);
Clear Plain PL/SQL DO_KEY(’ Yes Yes Abort
CLEAR_FORM
’);
Null1 Separator Null Yes Yes
Exit Plain PL/SQL DO_KEY( Yes Yes Exit
’EXIT_FORM
’);
Null2 Separator Null No Yes
......................................................................................................................................................
2-34 Oracle Developer: Build Forms II
Practice 2
......................................................................................................................................................
• Edit Menu
Visible in
Menu Magic Command Visible Horiz. Menu Icon
Label Item Type Item Type in Menu Toolbar Filename
Cut Magic Cut Null Yes Yes Cut
Copy Magic Copy Null Yes Yes Copy
Paste Magic Paste Null Yes Yes Paste
Null3 Separator Null No Yes
• Sort By Menu
• Query Menu
Visible in
Menu Command Horiz. Menu Icon
Label Item Type Type Menu Item Code Toolbar Filename
Enter Plain PL/SQL DO_KEY(’ Yes query
Query ENTER_QUERY’);
eXe- Plain PL/SQL DO_KEY(’EXECUT Yes execute
cute E_QUERY’);
Query
......................................................................................................................................................
Oracle Developer: Build Forms II 2-35
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-36 Oracle Developer: Build Forms II
3
................................
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 40 minutes
Total 90 minutes
......................................................................................................................................................
3-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn how to modify menus dynamically, as well as
how to control application security through menu access.
Objectives
After completing this lesson, you should be able to do the following:
• Control the menu programmatically by using menu built-ins
• Customize menu modules by using substitution parameters
• Implement menu security by using both database roles and the
appropriate built-ins
......................................................................................................................................................
Oracle Developer: Build Forms II 3-3
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Instructor Note
The DO_KEY built-in is explained in the next lesson. Stress that it is very
important to use this built-in for generic coding.
......................................................................................................................................................
3-4 Oracle Developer: Build Forms II
Using PL/SQL in Menu Item Code
......................................................................................................................................................
Restrictions
Menu modules are generated independently of form modules.
In PL/SQL command menu items:
• You cannot directly reference the value of form module objects.
• You must use the NAME_IN built-in function to determine the current
value of the object.
• You cannot use direct assignment to set the value of a form module
object.
• You must use the COPY built-in procedure.
Example
IF :s_emp.title = ’MANAGER’ THEN ...-- INCORRECT
IF NAME_IN(’s_emp.title’) = ’MANAGER’ THEN ... -- CORRECT
:s_product.name := ’PUMP’; -- INCORRECT
COPY(’PUMP’, ’s_product.name’); -- CORRECT
......................................................................................................................................................
Oracle Developer: Build Forms II 3-5
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Instructor Note
Demonstration: Use the Summit menu (m_summit.mmb) file to show
examples of these built-ins.
......................................................................................................................................................
3-6 Oracle Developer: Build Forms II
Useful Built-in Menu Subprograms
......................................................................................................................................................
Example
This procedure finds the ID of a menu item before setting multiple properties.
DECLARE
mi_id MenuItem;
BEGIN
mi_id := Find_Menu_Item(’Preferences.AutoCommit’);
/* Determine the current checked state of the AutoCommit menu
checkbox item and toggle the checked state */
IF Get_Menu_Item_Property(mi_id,CHECKED) = ’TRUE’ THEN
Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_TRUE);
END IF;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 3-7
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Technical Note
REPLACE_MENU replaces the menu for all windows in the application. If
you are using CALL_FORM, REPLACE_MENU replaces the menu for
both the calling form and the called form with the specified menu.
......................................................................................................................................................
3-8 Oracle Developer: Build Forms II
Showing and Hiding the Current Menu
......................................................................................................................................................
Example
Use a standard procedure to change which root menu in the current menu
application appears in the menu bar. A single menu application may have
multiple root menus, which an application can set dynamically at run time.
PROCEDURE Change_Root_To(root_menu_name VARCHAR2) IS
BEGIN
Replace_Menu(’MYAPPLSTD’, PULL_DOWN, root_menu_name);
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 3-9
Lesson 3: Managing Menu Modules
......................................................................................................................................................
What Is a Role?
Users
Role
Privileges
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
3-10 Oracle Developer: Build Forms II
Managing Menu Security
......................................................................................................................................................
What Is a Role?
A role is a group of users sharing the same privileges. With Form Builder,
you can manage menu security through Oracle server roles.
When you create a role, you can grant access privileges to each item
individually. If access is granted only to some roles, only users belonging to
those roles can access those items.
Using this feature, you can deliver the same application for different kinds
of users.
......................................................................................................................................................
Oracle Developer: Build Forms II 3-11
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Technical Note
If Use Security is modified, you must recompile the menu module.
......................................................................................................................................................
3-12 Oracle Developer: Build Forms II
Defining Security Roles
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 3-13
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Instructor Note
You can manipulate roles dynamically at run time by using Form Builder.
For example, you can select views from the data dictionary to get
information about existing roles. Subprograms belonging to the
DBMS_SESSION package enable you to modify the roles that are used by
the menu module to enforce security. Tell students that if they want more
details about DBMS_SESSION, they can read Appendix I, “Using Oracle
Server Roles at Run Time.”
......................................................................................................................................................
3-14 Oracle Developer: Build Forms II
Assigning Access to Menu Items
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 3-15
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Summary
......................................................................................................................................................
3-16 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
PL/SQL in Menu Item Commands
• Typical PL/SQL uses
• Restrictions for PL/SQL in menu item commands
......................................................................................................................................................
Oracle Developer: Build Forms II 3-17
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Practice 3 Overview
This practice covers the following topics:
• Enhancing the menu with a check
menu item
• Synchronizing the Image Activate menu
item with the Image button
• Disabling irrelevant menu items
according to form context
Instructor Note
The practice overview in this lesson and the ones that follow are provided
only as guides. Develop the practice with the level of detail appropriate for
the students. This lab uses a lot of PL/SQL code. Because this is not a
coding course, we provide the code. Take time to explain this practice so that
students understand the code that they will import.
......................................................................................................................................................
3-18 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 3
......................................................................................................................................................
Practice Contents
• Add a check menu item.
• Enhance the menu so that the Image Activate menu item is synchronized
with the Image button. If the image is displayed, a check should appear
next to the Image Activate menu item.
• For the EMPLOYEE form, disable the menu items that are not relevant.
......................................................................................................................................................
Oracle Developer: Build Forms II 3-19
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Practice 3
1 Define a check menu item.
a Open the M_SUMMIT menu module and create a new menu item to
the right of Query and rename it Image.
b Create a new menu item under Image and name it Image Activate.
Import the text for the Image Activate menu item by using the
c
pr3_1c.txt file. The menu item name must be
IMAGE_ACTIVATE.
d Save and compile the menu module.
e Run and test the ORDERS form.
2 Synchronize the menu module with the form.
a Write startup code for the M_SUMMIT menu module that
synchronizes the Image Activate menu item with the Image button.
You can import the pr3_2a.txt file.
b Save and compile your module.
3 The menu items Sort By and Image are not relevant to the
CUSTOMERS form and therefore should have no effect.
a Attach the menu module to the CUSTOMERS form.
b Modify the startup code of the M_SUMMIT menu module to disable
these options when the CUSTOMERS form is opened. You can
replace the existing code with the code from the pr3_3b.txt file.
You may need to change the code to conform to the exact names you
gave to the Main Menu and its menu items.
c Save and compile the module.
d Run the CUSTOMERS form and test your application.Execute a
Query and click the Orders button to move to the ORDERS form.
Note that the Sort By and Image menu items are disabled when the
CUSTOMERS form is current, and that they are enabled when the
ORDERS form is current.
......................................................................................................................................................
3-20 Oracle Developer: Build Forms II
4
................................
Programming
Function Keys
Lesson 4: Programming Function Keys
......................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 40 minutes
Total 80 minutes
......................................................................................................................................................
4-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
The Oracle Developer Form Builder components enable you to redefine the
actions of function keys. This lesson shows you how to define key triggers
to intercept and supplement the usual behavior of the function keys with
which your users navigate the Oracle Developer application.
Objectives
After completing this lesson, you should be able to do the following:
• Define key triggers and their uses
• Program function keys
• Classify key triggers
• Associate function keys with interface controls
......................................................................................................................................................
Oracle Developer: Build Forms II 4-3
Lesson 4: Programming Function Keys
......................................................................................................................................................
Key Triggers
SET_ALERT_PROPERTY(′question_alert
SET_ALERT_PROPERTY( ′question_alert′,′, ALERT_MESSAGE_TEXT,
ALERT_MESSAGE_TEXT,
′Do really want to leave the form? ′);
′Do you really want to leave the form?
you ′);
IF SHOW_ALERT(′question_alert
IF SHOW_ALERT( ′question_alert′)′) == ALERT_BUTTON1
ALERT_BUTTON1 THEN
THEN
EXIT_FORM; -- default functionality
EXIT_FORM; -- default functionality
END
END IF;
IF;
......................................................................................................................................................
4-4 Oracle Developer: Build Forms II
Key Triggers
......................................................................................................................................................
Key Triggers
If you press a function key, Forms usually performs the default function
associated with that key. You can modify the standard functionality of a
function key by defining a key trigger for that function key.
Example
The form level Key-Exit trigger below displays an alert to ask to the end
user if he or she wants to leave the form.
SET_ALERT_PROPERTY(’question_alert’, ALERT_MESSAGE_TEXT, ’Do
you really want to leave the form?’);
IF SHOW_ALERT(’question_alert’) = ALERT_BUTTON1 THEN
EXIT_FORM; -- default functionality
END IF;
Note: If you also want to execute the default functionality of the function
key, you must ensure that the key trigger includes the built-in function
associated with the key.
Example
The following form-level Key-Menu trigger disables [Block Menu] for a
form.
BEGIN
NULL;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 4-5
Lesson 4: Programming Function Keys
......................................................................................................................................................
Instructor Note
Demonstration: Open the LOV Form (Orders2.fmb). Change those
properties for the Key-Duprec trigger at the form level. Run the form.
......................................................................................................................................................
4-6 Oracle Developer: Build Forms II
Defining Key Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 4-7
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-8 Oracle Developer: Build Forms II
Characteristics of Key Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 4-9
Lesson 4: Programming Function Keys
......................................................................................................................................................
Technical Note
The function keys Fn do not necessarily map to F1, F2, F3, and so on.
......................................................................................................................................................
4-10 Oracle Developer: Build Forms II
Classification of Key Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 4-11
Lesson 4: Programming Function Keys
......................................................................................................................................................
Technical Note
Since mouse-event key triggers are not executed when the mouse is used to
initiate window interaction, you should not place code that needs to be
executed every time the window interaction occurs in a mouse-event key
trigger.
Instructor Note
Demonstration for next page pair:
• Use the LOV Form (Orders2.fmb) demonstration to show preventing
duplication of the primary key by using the Key-Duprec trigger.
• Use the same demonstration to illustrate a call of a customized list of
values (LOV) form instead of the native Forms LOV, using Key-Listval.
To do this click the product LOV button. Do not explain in detail the
code associated with this button, because the students will write it later
in this course.
......................................................................................................................................................
4-12 Oracle Developer: Build Forms II
Classification of Key Triggers
......................................................................................................................................................
Examples
• The Key-Nxtblk trigger is a mouse-event key trigger, because the
NEXT_BLOCK functionality can also be activated using the mouse by
clicking in the next block. In this case, a possible Key-Nxtblk trigger
will not fire.
• The Key-Exeqry trigger is not a mouse-event key trigger, because the
EXECUTE_QUERY functionality cannot be activated by simply
clicking the mouse. It can be activated by the mouse only if a trigger is
defined that fires as a result of the mouse action.
......................................................................................................................................................
Oracle Developer: Build Forms II 4-13
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-14 Oracle Developer: Build Forms II
Using Key Triggers
......................................................................................................................................................
Common Uses
• Disable function keys
• Replace or extend the default functionality of function keys
• Add additional keys for custom functions using Key-Fn triggers
• Disable a set of function keys using Key-Others
Technical Note
To determine if a Key-Others trigger applies to a function key, Forms looks
for associated key triggers at all levels. For example, if you define the
Key-Others trigger at the block level, it will not fire for function keys for
which a key trigger is defined at the form level.
......................................................................................................................................................
Oracle Developer: Build Forms II 4-15
Lesson 4: Programming Function Keys
......................................................................................................................................................
Instructor Note
Demonstration: Use the LOV Form + Duplication Primary Key
(Orders2.fmb) demonstration, and show the code for the
CONTROL.EXIT_BUTTON button. Also show the Key-Exit trigger at
form level.
......................................................................................................................................................
4-16 Oracle Developer: Build Forms II
Association with Other Interface Controls
......................................................................................................................................................
What Is DO_KEY?
DO_KEY is a built-in function that executes the key trigger associated with
the built-in that is specified as its parameter. If no key trigger is defined, the
specified built-in is executed.
Syntax
DO_KEY(built_in_name)
Example
Exit a Form by clicking [Exit Form] or an Exit button, or by choosing a
menu item.
1 Define a Key-Exit trigger at form level.
2 Call DO_KEY by using:
a The When-Button-Pressed trigger on the associated Exit button
b The menu-item code for the menu item that exits the form using
DO_KEY(’EXIT_FORM’);
......................................................................................................................................................
Oracle Developer: Build Forms II 4-17
Lesson 4: Programming Function Keys
......................................................................................................................................................
Summary
......................................................................................................................................................
4-18 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Understanding Key Triggers
• They fire when the associated function key is pressed.
• They are defined like any other trigger.
• Special properties are Display in Keyboard Help and Keyboard Help
Text.
......................................................................................................................................................
Oracle Developer: Build Forms II 4-19
Lesson 4: Programming Function Keys
......................................................................................................................................................
Practice 4 Overview
This practice covers the following topics:
• Examining the behavior of
[Duplicate Record] at run time
• Redefining [Duplicate Record]
– To create a new record before
duplication
– To clear primary key items after
duplication
• Changing the behavior of function keys
according to context
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
4-20 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 4
......................................................................................................................................................
Practice Contents
• Examine the behavior of [Duplicate Record] at run time.
• Use a key trigger to redefine [Duplicate Record] to create a new record
before duplicating. Ensure that the primary key of the new record is
empty.
• Disable all function keys on the master block except for
[Execute Query], [Up], [Down], and [Enter Query].
• Test the effects of the key triggers on the master block.
• Add a form-level Key-Exit trigger to perform default exit functionality.
• Run the form again to test the effects of this key trigger.
......................................................................................................................................................
Oracle Developer: Build Forms II 4-21
Lesson 4: Programming Function Keys
......................................................................................................................................................
Practice 4
1 Create and modify a key trigger.
aOpen the ORDERS form module and replace the M_SUMMIT menu
module with the DEFAULT&SMARTBAR menu.
b Run the form and make sure that you understand the default behavior
of [Duplicate Record], by invoking it once while the cursor is on a
queried record in the S_ORD block and again when the cursor is on a
new record.
c Redefine [Duplicate Record] so that a new record is created before
the record duplication occurs. Redefine [Duplicate Record] at the
form level.
d In the S_ORD block, redefine [Duplicate Record] in such a way that
the Id item is emptied after duplication. This code should be
executed in addition to and after the form level code.
e In the S_ITEM block, redefine [Duplicate Record] in such a way that
the item_id, product_id, description, and price items are emptied
after duplication. This code should be executed in addition to and
after the form level code.
f Save, generate, and test the ORDERS form.
If you have time...
2 Disable function keys.
a Make sure that only the function keys [Duplicate Record],
[Execute Query], [Enter Query], [Create Record], [Clear Block],
[Up], and [Down] can be used for the S_ORD master block. All
function keys should be available for the S_ITEM detail block.
b Test whether you can exit from the form by selecting the [Exit] key
in the master block.
c Add a form-level Key-Exit trigger to perform the exit functionality
of the CONTROL.EXIT_BUTTON item.
d Test again whether you can exit from the form by selecting [Exit] in
the master block. Explain this behavior.
e Modify the When-Button-Pressed trigger of the
CONTROL.EXIT_BUTTON item to activate the same functionality
when you select the [Exit] function key. Remove the existing code.
3 Create and modify a key trigger.
a Create an alert called DELETE_ALERT.
......................................................................................................................................................
4-22 Oracle Developer: Build Forms II
Practice 4
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 4-23
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-24 Oracle Developer: Build Forms II
5
................................
Responding to Mouse
Events
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 30 minutes
Total 70 minutes
Instructor Note
Demonstration for the next page pair: Use the Cursor Style
(cursor_style.fmb) demonstration to show the mouse cursor style.
......................................................................................................................................................
5-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
The keyboard, menu, and mouse are the operator’s tools for interacting with
the Forms application. This lesson demonstrates how to write an application
that responds to mouse events.
Objectives
After completing this lesson, you should be able to do the following:
• Define mouse events
• Cause a form module to respond to mouse movement
• Cause a form module to respond to mouse button actions
• Drag and drop items
......................................................................................................................................................
Oracle Developer: Build Forms II 5-3
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Mouse Events
Instructor Note
Do not forget to change the cursor style to DEFAULT in case of a trigger
failure.
......................................................................................................................................................
5-4 Oracle Developer: Build Forms II
What Are Mouse Events?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-5
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
When-Mouse-Enter
When-Mouse-Leave
When-Mouse-Move
Technical Note
Using the When-Mouse-Enter, When-Mouse-Leave, and
When-Mouse-Move triggers can affect the performance of your form,
because these triggers have the potential to fire frequently.
Instructor Note
Demonstration: Use the Simple Mouse Events (mouse_event.fmb)
demonstration to illustrate a humorous use of the When-Mouse-Enter
trigger.
You can also use the Mouse Events (mouse.fmb) demonstration to
illustrate all the mouse triggers and system variables.
......................................................................................................................................................
5-6 Oracle Developer: Build Forms II
Responding to Mouse Movement
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-7
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Navigation in a Block
1
2
7
3 6
4
5
1 MOUSE_FORM 5 MOUSE_RECORD_OFFSET
2 MOUSE_CANVAS 6 MOUSE_X_POS
3 MOUSE_ITEM 7 MOUSE_Y_POS
4 MOUSE_RECORD
Technical Note
The SYSTEM.MOUSE_FORM system variable is NULL if the platform is
not a GUI platform.
Instructor Note
Demonstration: Use the Mouse Events (mouse.fmb) demonstration to
illustrate all the mouse triggers and system variables.
Demonstration for the next page pair: Use the Mouse Events (mouse.fmb)
demonstration to illustrate all the mouse triggers and system variables.
......................................................................................................................................................
5-8 Oracle Developer: Build Forms II
Responding to Mouse Movement
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-9
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
When-Mouse-Up
When-Mouse-Click
click
When-Mouse-Doubleclick
click click
2. When-Mouse-Up
3. When-Mouse-Click
4. When-Mouse-Down
5. When-Mouse-Up
6. When-Mouse-Doubleclick
Copyright Oracle Corporation, 1999. All rights reserved.
Technical Note
Click and double-click work only if the mouse stays on the item (or canvas)
throughout the down-up action.
......................................................................................................................................................
5-10 Oracle Developer: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-11
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
SYSTEM.MOUSE_BUTTON_PRESSED
SYSTEM.MOUSE_BUTTON_MODIFIERS
Ctrl Alt
Instructor Note
There are now more useful system variable names for the mouse button
state. SYSTEM.MOUSE_BUTTON_MODIFIERS should be used in place
of SYSTEM.MOUSE_BUTTON_SHIFT_STATE.
The values returned by SYSTEM.MOUSE_BUTTON_MODIFIERS are
invariant across all platforms and languages.
• SYSTEM.MOUSE_BUTTON_SHIFT_STATE returns the string, but in
the language of the operating system.
• SYSTEM.MOUSE_BUTTON_MODIFIERS always returns the same
string, regardless of OS language.
Demonstration: Use the Mouse Events (mouse.fmb) demonstration to
illustrate all the mouse triggers and system variables.
Demonstration for the next page pair: Use the Drag and Drop
(dragdrop.fmb) demonstration to show an example of drag and drop
use. Click an employee number, and drag this employee to a department.
......................................................................................................................................................
5-12 Oracle Developer: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-13
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Item-A highlighted
Items repositioned
Instructor Note
A library named drag.pll is shipped with the product. Use the following
steps as a demonstration:
1 Create a new form module and a new text item manually.
2 Attach the PL/SQL library drag.pll to your form.
3 For this item, create a When-Mouse-Down trigger, a
When-Mouse-Move trigger, and a When-Mouse-Up trigger.
In the When-Mouse-Down trigger, include the following statement:
MOUSE.CLICK;
You can also include code here to change the cursor to indicate that a
drag operation is occurring.
In the When-Mouse-Move trigger, include the following statement:
IF :SYSTEM.MOUSE_BUTTON_PRESSED =’1’ THEN
MOUSE.MOVE;
END IF;
In the When-Mouse-Up trigger, add your application-specific code,
which should check where the object has been dropped, and take
appropriate action.
......................................................................................................................................................
5-14 Oracle Developer: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 5-15
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Summary
• Mouse events
• Responding to mouse movement
– Mouse position system variables
– Mouse movement triggers
• Responding to mouse button actions
– Mouse button system variables
– Mouse button triggers
......................................................................................................................................................
5-16 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
In this lesson, you saw how to write an application that responds to mouse
events.
Mouse Events
• Entry to a canvas or an item
• Exit from a canvas or an item
• Move the cursor
• Click
• Double-click
• Up
• Down
• Responding to mouse movement
• Mouse position system variables
......................................................................................................................................................
Oracle Developer: Build Forms II 5-17
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Practice 5 Overview
......................................................................................................................................................
5-18 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 5
......................................................................................................................................................
Practice Contents
• Define a mouse-event trigger to invoke an editor on the
S_CUSTOMER.COMMENTS item.
• Modify the control.help button to a display item.
• Assign a value of “?” to the CONTROL.SHOW_HELP_BUTTON
display item when the user enters the form.
• Display the CV_HELP canvas when the mouse enters the
CONTROL.SHOW_HELP_BUTTON display item.
......................................................................................................................................................
Oracle Developer: Build Forms II 5-19
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Practice 5
In this practice, you provide additional functionality in your forms by
defining mouse-event triggers.
1 In the CUSTOMERS form, define a mouse-event trigger on
S_CUSTOMER.COMMENTS that invokes the item’s editor when the
user double-clicks the item.
2 In the ORDERS form convert the CONTROL.SHOW_HELP_BUTTON
button into a display item capable of displaying a single large character.
Change the item type property and choose a font that allows large
character sizes (such as Times New Roman). Set the font size to 24. Set
Bevel to none. Adjust the item size so that one character is visible inside
it. Since only the first character of the item name is visible in the Layout
Editor, this item appears as S. The item’s background color should match
the toolbar, and its text color should be green.
3 In the ORDERS form, define a When-Mouse-Enter trigger at form level
that assigns a value of? to the display item
CONTROL.SHOW_HELP_BUTTON. This should occur only when the
mouse is in the CV_ORDER canvas.
4 Create a When-Mouse-Enter trigger on
CONTROL.SHOW_HELP_BUTTON that uses the SHOW_VIEW
built-in to display the CV_HELP. Remove the When-Button-Pressed
trigger.
5 Create a When-Mouse-Leave trigger on
CONTROL.SHOW_HELP_BUTTON that hides the CV_HELP. Use the
HIDE_VIEW built-in to achieve this. Delete the
CONTROL.HIDE_HELP_BUTTON button.
6 Save, compile, and run the ORDERS form to test. The stacked canvas,
CV_HELP is displayed only if the current item is not obscured. Ensure,
at least, that the first entered item in the form is CV_HELP will not
obscure.
If you have time...
7 Modify the When-Mouse-Enter and When-Mouse-Leave triggers to
display the Cv_Help canvas, even if the current item is obscured. You
can replace the existing code with the code from the pr5_7_1.txt
and pr5_7_2.txt files.
......................................................................................................................................................
5-20 Oracle Developer: Build Forms II
6
................................
Controlling Windows
and Canvases
Programmatically
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Objectives
After completing this lesson, you should
be able to do the following:
• Display a form document in multiple
windows
• Write code to interact with windows
• Manipulate windows programmatically
• Manipulate canvas-views
programmatically
• Use large data blocks
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 45 minutes
Total 85 minutes
......................................................................................................................................................
6-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
You should already be familiar with setting window and canvas properties at design
time. This lesson covers the triggers and built-ins that you can use to manage the
properties and behavior of windows and canvases at run-time.
Objectives
After completing this lesson, you should be able to do the following:
• Display a form module in multiple windows
• Write code to interact with windows
• Manipulate windows programmatically
• Manipulate canvas-views programmatically
• Use large data blocks
......................................................................................................................................................
Oracle Developer: Build Forms II 6-3
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Using Window-Interaction
Triggers
Trigger Use
System variable
:SYSTEM.EVENT_WINDOW
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
6-4 Oracle Developer: Build Forms II
Using Window-Interaction Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-5
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Technical Note
In Microsoft Windows, you can reference the multiple-document interface
(MDI) application window with the FORMS_MDI_WINDOW constant.
FORMS_MDI_WINDOW is used with certain built-in functions and procedures
that relate to windows.
......................................................................................................................................................
6-6 Oracle Developer: Build Forms II
Built-ins for Manipulating Windows
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-7
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Technical Note
REPLACE_CONTENT_VIEW does not hide the stacked canvas already displayed
in the window, whereas SHOW_VIEW and SET_VIEW_PROPERTY (with the
Visible property) display the given canvas in front of any stacked canvas.
Instructor Note
Point out that the GET_ built-ins are the most important ones when writing generic
code.
Demonstration for the next pages: Use the Tab Pages (tab_page.fmb)
demonstration to show those system variables. Click a tab page and press [F1];
a message is displayed.
Use the same demonstration to show how to enforce navigation when a user selects
a tab page.
Use the same demonstration to illustrate the TOPMOST_TAB_PAGE argument.
Click the TopMost Tab Page button.
......................................................................................................................................................
6-8 Oracle Developer: Build Forms II
Built-ins for Manipulating Canvases
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-9
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Previous Next
Tab Page Tab Page
Instructor Note
The trigger does not fire if the end user presses [Next Item] + [Tab] to navigate from
one field to another in the same block but on different tab pages.
......................................................................................................................................................
6-10 Oracle Developer: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................
Technical Note
When you are changing to another tab page, the cursor does not automatically move to
a different item. To move the cursor you must include a GO_ITEM statement in the
When-Tab-Page-Changed trigger. This is intended functionality to allow users to view
other tab pages without navigating the cursor and therefore causing item navigation
and validation (as previously mentioned).
......................................................................................................................................................
Oracle Developer: Build Forms II 6-11
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Instructor Note
TOPMOST_TAB_PAGE returns only the tab page name, and not the canvas name.
To set a property, you must concatenate the canvas name with the page name.
......................................................................................................................................................
6-12 Oracle Developer: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................
Example
DECLARE
tp_id Tab_Page;
BEGIN
tp_id := Find_Tab_Page(’Canvas2.TabPage1’);
IF Get_Tab_Page_Property(tp_id, enabled) =’FALSE’ THEN
Set_Tab_Page_Property(tp_id, enabled,property_true);
END IF;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 6-13
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Window 2
Block 2
Block 3
Cursor
location
......................................................................................................................................................
6-14 Oracle Developer: Build Forms II
Windows and Blocks
......................................................................................................................................................
Transaction Management
During commit processing, Forms processes all base table blocks in
sequential order. Therefore, transaction management is block-based rather than
window-based. However, the user expects to interact with a form in a window-based
way.
......................................................................................................................................................
Oracle Developer: Build Forms II 6-15
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Technical Note
You can also maximize the MDI window application with the WINDOW_STATE
command line parameter:
ifrun60.exe module=customer.fmx userid=my_name/my_password@my_database
window_state=maximize
Instructor Note
Demonstration: Use the Window Coding (window.fmb) demonstration to show the
two examples described above. Show the When-New-Form-Instance trigger, which
includes the code for maximizing the MDI application window.
Show the GET_CURSOR_WINDOW program unit.
......................................................................................................................................................
6-16 Oracle Developer: Build Forms II
Manipulating Window Properties Programmatically
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-17
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Cascaded Windows
with Context
Instructor Note
Demonstration: Use the Window Coding (window.fmb) demonstration to show
cascaded windows with context. Show the Key-Help trigger, which includes the code
for cascading windows with context.
......................................................................................................................................................
6-18 Oracle Developer: Build Forms II
Showing Multiple Windows
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-19
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Instructor Note
Demonstration: Use the Window Coding (window.fmb) demonstration to show a
form using the Close option from the Microsoft Windows System menu.
......................................................................................................................................................
6-20 Oracle Developer: Build Forms II
Closing Windows
......................................................................................................................................................
Closing Windows
Use the Close Menu item on the system-menu box to provide the user with a means for
closing windows. Because there is no default behavior in Forms when a user chooses
the Close Menu item, you must define a
When-Window-Closed trigger.
The following examples show a form based on departments and employees. The
department block and employee block are located in separate windows. The When-
Window-Closed and When-Window-Activated triggers implement the following
functionality:
• Exiting from the form or hiding the window that is closed by the user
(Forms automatically activates another window.)
• Navigating to the newly activated window
Note: The function GET_CURSOR_WINDOW, discussed in an earlier example, is
used here.
......................................................................................................................................................
Oracle Developer: Build Forms II 6-21
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Instructor Note
Demonstration: Use the large block (Tab_Page.fmb) demonstration to illustrate
the example above. The larg_emp.sql file drops and creates the
S_LARGE_EMP table.
......................................................................................................................................................
6-22 Oracle Developer: Build Forms II
Blocks with Many Items
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 6-23
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Summary
• Window-interaction triggers
• SYSTEM.EVENT_WINDOW
• Built-ins for manipulating windows
• Built-ins for manipulating canvases
• Built-ins for manipulating tab canvases
Summary
......................................................................................................................................................
6-24 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Window-Interaction Triggers
• When-Window-Activated
• When-Window-Deactivated
• When-Window-Closed
• When-Window-Resized
Use the SYSTEM.EVENT_WINDOW system variable to keep track of the triggered
window.
......................................................................................................................................................
Oracle Developer: Build Forms II 6-25
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Practice 6 Overview
......................................................................................................................................................
6-26 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 6
......................................................................................................................................................
Practice Contents
• Build a multiple-window form and use the appropriate window
interaction triggers and built-ins to implement the behavior specified.
• Make sure that a user cannot make any window larger than it was at the
startup of the form.
If you have time...
• Display a hint or description for the current tab page.
• Change the label on the Comment tab page when it is the topmost page.
......................................................................................................................................................
Oracle Developer: Build Forms II 6-27
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Practice 6
1 Manipulate a multiple-window form.
aOpen the ORDERS form module.
b Make sure that when a user closes the orders window by way of the
system-menu box, the form is exited. Also make sure that when a
user closes the inventory window by way of the system-menu box,
the cursor navigates to the orders window. If cursor navigation
succeeds, the inventory window should closed. Create a When-
Window-Closed trigger. You can import the pr6_1b.txt file.
c Save, compile, and test the form.
d Make sure that a user cannot make any window larger than it was at
the startup of the form. You should save the size of the windows at
the startup of the form, and create a procedure called
CHECK_WINDOW_SIZE that resets the size of the current window
if the new width and height are larger than the initial one. Create a
When-New-Form-Instance trigger. You can replace the existing code
with the code from the pr6_1d1.txt file. Next, create the
procedure CHECK_WINDOW_SIZE. You can import the code from
the pr6_1d2.txt file. Create a When-Window-Resized trigger
that calls the procedure.
2 Manipulate the MDI application window.
a Open the CUSTOMERS form module.
b At the startup of the form, maximize the MDI application window,
and display an appropriate title. You can import the pr6_2b.txt
file.
If you have time...
3 Open the EMPLOYEES form, and use the CONTROL.HELP_TAB text
item to display a hint or description for the current tab page.
a Create a When-Tab-Page-Changed trigger to populate this item with
an appropriate message for each page. You can import the
pr6_3a.txt file.
b Test and verify your module.
c Modify the When-Tab-Page-Changed trigger to change the label on
the Comment tab page. When Comment is the topmost page, change
its label to Employee XX, where XX is the employee’s ID number
(emp.id). When any other tab page is topmost, change the label back
to Comment. You can import the pr6_3c.txt file.
......................................................................................................................................................
6-28 Oracle Developer: Build Forms II
7
................................
Objectives
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 50 minutes
Total 100 minutes
......................................................................................................................................................
7-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson introduces you to the different data source types that can be used
for data blocks. This lesson also provides you with some guidelines for
choosing the best data source for the job.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the various data source types
• Base a data block on a FROM clause query
• Discuss the advantages of using a FROM clause query
• Base a data block on a stored procedure that returns a REF cursor
• Select the appropriate data source for a data block
......................................................................................................................................................
Oracle Developer: Build Forms II 7-3
Lesson 7: Defining Data Sources
......................................................................................................................................................
Query DML
Table Table
FROM clause Company Name:
query Company Code:
Stored Balance: Stored
procedure procedure
Transactional Transactional
trigger trigger
......................................................................................................................................................
7-4 Oracle Developer: Build Forms II
Data Source Types
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-5
Lesson 7: Defining Data Sources
......................................................................................................................................................
FROM...
(SELECT...
FROM...
WHERE...)
WHERE...
Instructor Note
Demonstration: Run the from_clause.sql and from_clause3.sql
scripts to illustrate a FROM clause query.
......................................................................................................................................................
7-6 Oracle Developer: Build Forms II
Basing a Data Block on a FROM Clause Query
......................................................................................................................................................
Example
SELECT deptno, sal_total
FROM
( SELECT deptno, SUM(sal) sal_total
FROM emp
HAVING SUM(sal) > 5000
GROUP BY deptno
)
ORDER BY deptno ;
......................................................................................................................................................
Oracle Developer: Build Forms II 7-7
Lesson 7: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
7-8 Oracle Developer: Build Forms II
Basing a Data Block on a Stored Procedure
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-9
Lesson 7: Defining Data Sources
......................................................................................................................................................
Instructor Note
Demonstration: Edit the RefCurSpec.sql and RefCurBody.sql
scripts to show the code of a stored procedure using a REF cursor.
......................................................................................................................................................
7-10 Oracle Developer: Build Forms II
Example of a Query Using a REF Cursor Procedure
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-11
Lesson 7: Defining Data Sources
......................................................................................................................................................
Instructor Note
Demonstration: Edit the TorQuerySpec.sql and
TorQueryBody.sql scripts to show the code of a stored procedure using
a table of records.
......................................................................................................................................................
7-12 Oracle Developer: Build Forms II
Example of Query Using a Table of Records Procedure
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-13
Lesson 7: Defining Data Sources
......................................................................................................................................................
Note
See Appendix F, “Handling Server-Side Errors, for code details.
Instructor Note
Demonstration: Edit the TorDMLSpec.sql and TorDMLBody.sql
scripts to show the code of a stored procedure using a table of records.
......................................................................................................................................................
7-14 Oracle Developer: Build Forms II
Example of DML Using a Stored Procedure
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-15
Lesson 7: Defining Data Sources
......................................................................................................................................................
Procedure
Query 1 2 REF cursor
REF cursor
3
Fetched rows
4
Cursor
3
Table of records
4
......................................................................................................................................................
7-16 Oracle Developer: Build Forms II
Deciding Whether to Use a REF Cursor or a Table of Records
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-17
Lesson 7: Defining Data Sources
......................................................................................................................................................
Instructor Note
Demonstration: If they do not already exist, create and populate the EMP
and DEPT tables using the UTLSample.sql file. Run the
TorDMLSpec.sql and TorDMLBody.sql scripts.
Create a new form module. Base the block on a stored procedure.
The query procedure is emp_pkg.empquery.
The insert procedure is emp_pkg.empinsert.
The update procedure is emp_pkg.empupdate.
The delete procedure is emp_pkg.empdelete.
The lock procedure is emp_pkg.emplock.
......................................................................................................................................................
7-18 Oracle Developer: Build Forms II
Data Block Wizard
......................................................................................................................................................
Property Description
Data source type Specifies if the data block is based on a table or a stored procedure
Query procedure Name of the procedure used to query rows
Insert procedure Name of the procedure used to insert rows
Update procedure Name of the procedure used to update rows
Delete procedure Name of the procedure used to delete rows
Lock procedure Name of the procedure used to lock rows
......................................................................................................................................................
Oracle Developer: Build Forms II 7-19
Lesson 7: Defining Data Sources
......................................................................................................................................................
Instructor Note
Demonstration: Use the form created previously to illustrate these
properties.
......................................................................................................................................................
7-20 Oracle Developer: Build Forms II
Data Block Properties
......................................................................................................................................................
Property Description
Query Data Source Type Specifies the query data source type for the data block
Query Data Source Name Used only used if the query data source type is Table,
Subquery, or Procedure
Query Data Source Columns Specifies the names and data types of the columns
associated with the query data source (Used only if the
query data source type is Table, Subquery, or
Procedure.)
Query Data Source Arguments Specifies the names, data types, and values of the argu-
ments that are to be passed to the procedure for query-
ing data (Used only if the query data source type is
Procedure.)
Property Description
DML Data Target Type Specifies the DML data source type for the data block
DML Data Target Name Specifies the name of the DML data source for the data
block (Used only if the DML data target type is Table.)
(Insert, Update, Delete, Lock) Specifies the name of the procedure to be used (Used
Procedure Name only if the DML data target type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names and data types of the
Procedure Result Set Columns result set columns associated with the
procedure (Used only if the DML data
target type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names, data types, and values
Procedure Arguments of the arguments that are to be passed to the
procedure (Used only if DML data target
type is Procedure.)
......................................................................................................................................................
Oracle Developer: Build Forms II 7-21
Lesson 7: Defining Data Sources
......................................................................................................................................................
Instructor Note
Demonstration: Use the Stored Procedures demonstration to illustrate how
to use the same block to display data from different tables. Before the
demonstration, run the OrderSpecs.sql and OrderBody.sql scripts.
......................................................................................................................................................
7-22 Oracle Developer: Build Forms II
Data Source Guidelines
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-23
Lesson 7: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
7-24 Oracle Developer: Build Forms II
Data Source Guidelines
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 7-25
Lesson 7: Defining Data Sources
......................................................................................................................................................
Summary
Summary
......................................................................................................................................................
7-26 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
New Data Sources
• Stored procedure (query and DML)
• FROM clause query (query only)
......................................................................................................................................................
Oracle Developer: Build Forms II 7-27
Lesson 7: Defining Data Sources
......................................................................................................................................................
Practice 7 Overview
......................................................................................................................................................
7-28 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 7
......................................................................................................................................................
Practice Contents
• Base a block on a nested SELECT statement
• Enable DML on a block based on a nested SELECT statement
• Create a package containing a stored procedure to return a REF Cursor
• Base a block on a stored procedure
......................................................................................................................................................
Oracle Developer: Build Forms II 7-29
Lesson 7: Defining Data Sources
......................................................................................................................................................
Practice 7
1 Base the EMP block on a subquery.
a Open the EMPLOYEES form module.
b Set the Query Data Source Type EMP block property to From Clause
Query.
c In the Query Data Source Name property enter the SELECT
statement. Your query should return all the columns from the S_EMP
table joined with the columns from the S_DEPT table. Remember to
enclose your select SELECT statement in parentheses. You can copy
and paste the content of the pr7_1c.txt file.
The SELECT statement is:
(SELECT e.ID,
USERID,
LAST_NAME,
FIRST_NAME,
START_DATE,
TITLE,
MANAGER_ID,
DEPT_ID,
SALARY,
COMMISSION_PCT,
COMMENTS,
d.ID NUM,
REGION_ID,
NAME
FROM s_emp e, s_dept d
WHERE e.dept_id = d.id)
......................................................................................................................................................
7-30 Oracle Developer: Build Forms II
Practice 7
......................................................................................................................................................
Configure the EMP block so that Oracle Forms will use the primary
key values when constructing the WHERE clause. Set the KeyMode
property for the EMP block to Updatable. Set the Enforce Primary
Key property for the EMP block to Yes. Set the Primary Key
property for the Id item to Yes.
e Save, run, and test your module.
2 Enable DML on the EMP block without using transactional triggers.
a Set the block DML Target Name.
b Prevent Oracle Forms from attempting to update the columns from
the S_DEPT table. On the Property Palette for the item, set the Query
Only property to Yes, and the Update Allowed and Insert Allowed
properties to No for the S_DEPT items (NUM, NAME,
REGION_ID).
c Remove the appropriate transactional triggers.
d Save, run, and test your module.
If you have time...
3 Create a server-side package containing a procedure to return a REF
cursor.
Using the code in the pr7_3a.sql file in your labs directory, create
the Orders package body and package specification.
4 Modify the Ord_Sum block in the ord_sum.fmb module to base it on
the stored procedure.
a Open the ord_sum.fmb module. Change the Query Data Source
Type of the Ord_Sum block to Procedure. Change the DML Data
Target Type to None (this block does not allow any inserts, updates,
or deletes).
b Set the Query Data Source Name to the name of the stored procedure
in the package.
c Specify the Query Data Source Columns to match the items in the
Ord_Sum block.
The column names and types are:
ID, Number
NAME, Varchar2(255)
TOTAL, Number
d Specify the procedure arguments. The first argument is the REF
cursor that will be used by Forms to populate the block. The second
argument is used to pass the value of the list box
......................................................................................................................................................
Oracle Developer: Build Forms II 7-31
Lesson 7: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
7-32 Oracle Developer: Build Forms II
8
................................
Objectives
After completing this lesson, you should
be able to:
• Recognize which object types are
supported
• Describe how object types are
represented within Oracle Developer
• Create a block based on an object table
• Create a block based on a relation table
with an object or a REF column
• Populate a REF column with an LOV
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Topic Timing
Lecture 30 minutes
Practice 25 minutes
Total 55 minutes
......................................................................................................................................................
8-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson reviews certain object features of Oracle8 and explains how
these objects are displayed in the Object Navigator.
Objectives
After completing this lesson, you should be able to do the following:
• Recognize which Oracle8 object types are supported
• Describe how Oracle8 objects are represented within Oracle Developer
• Create a block based on an object table
• Create a block based on a relational table with an object column or REF
column
• Populate a REF column with an LOV
......................................................................................................................................................
Oracle Developer: Build Forms II 8-3
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Object Types
Attributes
Ship
ORDER
po_no Cancel
Check custinfo
status line_items
amount
Hold
Methods
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
These pages review object type fundamentals. Additional object type
information can be found in Appendix D, “Introduction to Oracle8 Object
Features.”
......................................................................................................................................................
8-4 Oracle Developer: Build Forms II
What Are Object Types?
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-5
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Review of Objects
• Object tables
• Object columns
• Object views
• INSTEAD-OF triggers
DECLARE
BEGIN
EXCEPTION
END;
Instructor Note
These pages review object type fundamentals. Additional object type
information can be found in Appendix D, “Introduction to Oracle8 Object
Features.”
......................................................................................................................................................
8-6 Oracle Developer: Build Forms II
Review of Objects
......................................................................................................................................................
Review of Objects
With an object type, you can create object tables, object columns, object
views, and INSTEAD-OF triggers.
Object Tables
After you have declared an object type, you can create objects based on the
type. One way to do this is to create a table whose rows are objects of that
object type. Rows in an object table are assigned object IDs (OIDs) and can
be referenced using a REF type.
Object Column
Another construct that can be based on an object type is an object column in
a relational table. In the object table, the rows of a table are objects. In a
relational table with an object column, the column is an object. The table
usually has standard columns, as well as one or more object columns. Object
columns are not assigned OIDs, and thus cannot be referenced using object
REF values.
Object View
An object view transforms the way a table appears to a user, without
changing the actual structure of the table. Object views make relational
tables look like object tables. Objects accessed through object views are
assigned OIDs, and can be referenced using object REFs.
INSTEAD OF Triggers
INSTEAD OF triggers provide a transparent way of modifying views that
cannot be modified directly through SQL DML statements (INSERT,
UPDATE, and DELETE). These triggers are called INSTEAD-OF triggers
because, unlike with other types of triggers, the Oracle server fires the
trigger instead of executing the triggering statement. The trigger performs
update, insert, or delete operations directly on the underlying tables.
Technical Note
The Database Trigger editor has been enhanced to include the INSTEAD OF
triggering event.
......................................................................................................................................................
Oracle Developer: Build Forms II 8-7
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
References to Objects
Instructor Note
These pages review object type fundamentals. Additional object type
information can be found in Appendix D, “Introduction to Oracle8 Object
Features.”
......................................................................................................................................................
8-8 Oracle Developer: Build Forms II
Object REFs
......................................................................................................................................................
Object REFs
When a row in an object table or object view is created, it is assigned
automatically a unique identifier called an object Id (OID). This OID value
can be stored in attributes of other objects, or columns of other tables. The
stored copy of the OID then becomes a pointer, or REF, to the original
object. (Object columns are not assigned OIDs and cannot be pointed to by a
REF.)
In relational databases, primary key values are used to identify records
uniquely. In object-relational databases, OIDs provide an alternate method.
With relational tables, you can associate two records by storing the primary
key of one record in one of the columns (the foreign key column) of another.
In a similar way, you can associate two objects by storing the OID of one
object in an attribute of another. Or you can associate a row in a relational
table to an object by storing the OID of an object in a column of a relational
table. The attribute or column that holds the OID is of data type REF.
Remember, the object itself is not stored in the table, only the OID value for
the object.
......................................................................................................................................................
Oracle Developer: Build Forms II 8-9
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Oracle8 in Developer
Supported Oracle8 features
• Large objects: BLOB, CLOB, NCLOB,
BFILE
• User-defined objects
– Object table
– Column object
– REF column
Unsupported Oracle8 features
• Collection types
• Stored procedures that return object
values
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
8-10 Oracle Developer: Build Forms II
Supported Oracle8 Features
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-11
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-12 Oracle Developer: Build Forms II
How Oracle Developer Treats Objects
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-13
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Object Display
Object Column
Object Table
Object REF
Object Type
......................................................................................................................................................
8-14 Oracle Developer: Build Forms II
Object Type Displays
......................................................................................................................................................
-- object table
CREATE TABLE oo_dept_table OF dept_type;
-- object column
CREATE TABLE rel_emp_table_ObjCol (
id NUMBER(7),
last_name VARCHAR2(25),
first_name VARCHAR2(25),
userid VARCHAR2(8),
start_date DATE, manager_id
NUMBER(7),
title VARCHAR2(25),
dept_id dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );
-- ref column
CREATE TABLE rel_emp_table_RefCol (
id NUMBER(7), last_name VARCHAR2(25),
first_name VARCHAR2(25), userid VARCHAR2(8),
start_date DATE, manager_id NUMBER(7), title
VARCHAR2(25), dept_id REF dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );
......................................................................................................................................................
Oracle Developer: Build Forms II 8-15
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-16 Oracle Developer: Build Forms II
Creating Data Blocks Based on Oracle8 Objects
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-17
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-18 Oracle Developer: Build Forms II
Selecting Object Table Columns
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-19
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-20 Oracle Developer: Build Forms II
Selecting Object Column Attributes
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-21
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-22 Oracle Developer: Build Forms II
Blocks with REF Lookups
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-23
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-24 Oracle Developer: Build Forms II
The REF Column Value
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-25
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-26 Oracle Developer: Build Forms II
LOVs for REFs
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 8-27
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Summary
• Most Oracle8 object types are
supported.
• Indentations represent nested objects.
• Blocks can be based on object tables.
• Blocks can be based on tables with
object columns or REF columns.
• REF columns can be populated with an
LOV.
......................................................................................................................................................
8-28 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
• Oracle Developer supports most, but not all, of the Oracle8 object types.
• In Oracle Developer, object types are displayed like columns, where
indentation shows the nesting of objects.
• Blocks can be based on object tables.
• Blocks based on object or relational tables can include object columns or
REF columns.
• REF columns can be populated with an LOV.
......................................................................................................................................................
Oracle Developer: Build Forms II 8-29
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Practice 8 Overview
This practice covers the following topics:
• Creating a block based on an object
table
• Creating a block based on a relational
table with an object column
• Creating a block based on a relational
table with a REF column
• Populating a REF column with an LOV
......................................................................................................................................................
8-30 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 8
......................................................................................................................................................
Practice Contents
• Create a block based on an object table
• Create a block based on a relational table with an object column
• Create a block based on a relational table with a REF column
• Populate a REF column with an LOV
......................................................................................................................................................
Oracle Developer: Build Forms II 8-31
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
Practice 8
1 Create a block based on a relational table.
Create a new form called OO_DEPT.
a
b Create a block by using the Data Block Wizard. Base the block on
the object table OO_DEPT_TABLE, and include all the columns. Do
not enforce data integrity.
c Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display, and use a tabular
layout with three displayed records and a scroll bar. Do not enter a
frame title.
d Test and save the form.
2 Create a block based on a relational table with an object column.
a Create a form called OBJ_COL.
b Create a block by using the Data Block Wizard. Base the block on
the relational table REL_EMP_TABLE_OBJCOL. Select the
columns ID, FIRST_NAME, and LAST_NAME. Expand the object
column DEPT_ID and select the attributes ID and NAME. Note the
name that is given to the new item. Do not enforce data integrity.
c Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display. Change the prompt for
item DEPT_ID to Department ID and DEPT_ID_NAME to
Department Name. Use a form layout. Do not enter a frame title.
Finish following the wizard.
d Examine the properties for the item dept_id_name. Pay particular
attention to the database properties. Later, you will compare and
contrast these properties with the properties set for a REF column.
e Test and save the form.
3 Create a block based on a relational table with an REF column and an
LOV to populate the REF column.
a Create a form called REF_COL.
b Create a block by using the Data Block Wizard. Base the block on
the relational table REL_EMP_TABLE_REFCOL. Select the
columns ID, FIRST_NAME and LAST_NAME. Do not enforce data
integrity.
c Note that there are two items called DEPT_ID. The first is
expandable and has the term “LOOKUP” in parenthesis after the
name. The second represents the REF column value itself. Expand
......................................................................................................................................................
8-32 Oracle Developer: Build Forms II
Practice 8
......................................................................................................................................................
the first DEPT_ID item and select the attributes ID and NAME. (Do
not select the second DEPT_ID item. The REF item is included
automatically when the LOV is created.)
d The Data Block Wizard offers to create an LOV for the REF item
dept_id. Select the check box, and select OO_DEPT_TABLE as the
source for the LOV.
e Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display. Do not enter a frame
title. (Note that the REF item DEPT_ID is included in the list of
items in the Object Navigator but is not included in the list of
available items in the Layout Wizard. REF item values are normally
not displayed, so by default the REF item is assigned to the Null
canvas.)
f Examine the database properties for the item DEPT_ID_NAME. Pay
particular attention to the database properties. Notice that the Query
Only property is set to Yes.
g Select the item DEPT_ID from the Object Navigator, and examine
the Canvas property. Also, notice that an LOV and associated record
group now exist.
h Test and save the form, including the LOV.
......................................................................................................................................................
Oracle Developer: Build Forms II 8-33
Lesson 8: Working with Oracle8 Objects in Form Builder
......................................................................................................................................................
......................................................................................................................................................
8-34 Oracle Developer: Build Forms II
9
................................
Objectives
After completing this lesson, you should
be able to do the following:
• Define block coordination
• Coordinate data blocks by using REF
relations
• Describe the characteristics and
principles of relation-handling code
• Implement a coordination-type toggle
• Force one commit per master record
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Topic Timing
Lecture 30 minutes
Practice 30 minutes
Total 60 minutes
Demonstration for the next page pair: Use the Coordination-Type Toggle
(Orders3.fmb) demonstration to create explicitly a relation between the
S_ITEM and S_INVENTORY blocks.
......................................................................................................................................................
9-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
You have seen how form modules consist of data blocks based on related
tables. This lesson shows how you can modify the relationship between two
data blocks to affect the way in which deletes are handled and to what extent
the data blocks are coordinated at query time. Also, it explains how to create
relationships based on object REFs.
Objectives
After completing this lesson, you should be able to do the following:
• Define block coordination
• Coordinate data blocks by using REF relations
• Describe the characteristics and principles of relation-handling code
• Implement a coordination-type toggle
• Force one commit per master record
......................................................................................................................................................
Oracle Developer: Build Forms II 9-3
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Relations
• Logical objects that handle the
relationship between two blocks
• Created implicitly with a master-detail
form module
• Created explicitly with the New Relation
dialog box
......................................................................................................................................................
9-4 Oracle Developer: Build Forms II
Creating a Relation
......................................................................................................................................................
Creating a Relation
What Is a Relation?
A relation is a Form Builder object that handles the relationship between
two associated blocks.
You can create a relation either:
• Implicitly with a master-detail form module
• Explicitly in the Object Navigator
Implicit Relations
When you create a master-detail form module, a relation is automatically
created. This relation is named in the format masterblock_detailblock, for
example, S_ORD_S_ITEM.
Explicit Relations
If a relation is not established when default blocks are created, you can
create your own by setting the properties in the New Relation dialog box.
Like implicitly created relations, PL/SQL program units and triggers are
created automatically when you explicitly create a relation.
Instructor Note
The creation of explicit relations was covered in the Oracle Developer:
Build Forms I course. Use these pages to review the fact that relations can be
created implicitly or explicitly.
......................................................................................................................................................
Oracle Developer: Build Forms II 9-5
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Block Coordination
• Coordination-causing event
• Block-coordination phases:
– Clear phase executed before change
of master record
– Populate phase executed after
change of master record
• Implementation of block coordination:
– The Copy Value from Item property
– Relation-handling triggers
– Relation-handling procedures
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Explain to students the importance of the Copy Value from Item property for
implementing block coordination.
Demonstration: Use the Coordination-Type Toggle (Orders3.fmb)
demonstration to show the objects used to implement a block coordination.
......................................................................................................................................................
9-6 Oracle Developer: Build Forms II
Block Coordination
......................................................................................................................................................
Block Coordination
To maintain a master-detail relationship, Forms coordinates the master and
detail blocks to ensure that only the detail records that belong to the current
master record are displayed.
Coordination-Causing Events
Any event that changes the master record is called a coordination-causing
event or a coordination operation. Forms automatically coordinates the
master and detail blocks again when you move to another master record.
......................................................................................................................................................
Oracle Developer: Build Forms II 9-7
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
......................................................................................................................................................
9-8 Oracle Developer: Build Forms II
Coordinate Blocks Using REFs
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-9
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Characteristics of Relation-
Handling Triggers
Technical Note
Relation-handling triggers fire only if you have defined a corresponding
relation.
......................................................................................................................................................
9-10 Oracle Developer: Build Forms II
Characteristics of Relation-Handling Triggers
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-11
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Principles of Relation-Handling
Code
Three relation-handling procedures:
• CLEAR_ALL_MASTER_DETAILS
• QUERY_MASTER_DETAILS
• CHECK_PACKAGE_FAILURE
Adding your own code to relation-
handling triggers:
• Forms adds comments around code.
• You add your own code before or after
these comments.
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
9-12 Oracle Developer: Build Forms II
Principles of Relation-Handling Code
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-13
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Obtaining Relation-Handling
Information
System variables for relation handling:
• SYSTEM.MASTER_BLOCK
• SYSTEM.COORDINATION_OPERATION
Built-ins for relation handling:
• GET_FORM_PROPERTY
• GET/SET_BLOCK_PROPERTY
• GET/SET _RELATION_PROPERTY
Copyright Oracle Corporation, 1999. All rights reserved.
Technical Note
You can use these system variables in the On-Clear-Details trigger only.
Assign their values to global variables to broaden the scope.
......................................................................................................................................................
9-14 Oracle Developer: Build Forms II
Obtaining Relation-Handling Information
......................................................................................................................................................
(*): You can also set those properties using the Set-Relation-Property built-
in.
......................................................................................................................................................
Oracle Developer: Build Forms II 9-15
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Implementing
a Coordination-Type Toggle
Define a procedure that toggles between
immediate and deferred coordination
• Use GET_BLOCK_PROPERTY to obtain
relation name.
• Use GET_RELATION_PROPERTY to
obtain current coordination type.
• Use SET_RELATION_PROPERTY to
switch to other coordination type.
Copyright Oracle Corporation, 1999. All rights reserved.
Implementing
a Coordination-Type Toggle
Call this procedure from:
• When-Checkbox-Changed trigger
• Menu item of type Check
Instructor Note
Demonstration: Use the Coordination-Type Toggle (Orders3.fmb)
demonstration to show the example described above.
Select Query––>Deferred.
......................................................................................................................................................
9-16 Oracle Developer: Build Forms II
Implementing a Coordination-Type Toggle
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-17
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Instructor Note
Demonstration: Use the Commit Per Master (Mascmt.fmb) demonstration
to illustrate the example described above.
......................................................................................................................................................
9-18 Oracle Developer: Build Forms II
Forcing a Commit Per Master
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-19
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Summary
Creating relations:
• Implicitly
• Explicitly
Relation properties:
• For deletion
• For coordination
Block coordination:
• Coordination-causing events change
the master record
• Clear and populate
Copyright Oracle Corporation, 1999. All rights reserved.
Summary
Coordinating blocks with REFs
Elements involved in block coordination:
• Copy Value from Item property
• Relation-handling triggers and
procedures
Characteristics of relation-handling
triggers
Obtaining relation-handling information
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
9-20 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Creating Relations
• Implicitly, when a block is created through the New Block facility
• Explicitly, by creating the relation separately from the related blocks
Relation Properties
For controlling behavior on deletion of master records and coordination of
data between blocks
Block Coordination
• Coordination-causing events cause a change of the master record.
• The two block-coordination phases are the Clear and Populate phases.
• Base coordination of blocks on REF values.
......................................................................................................................................................
Oracle Developer: Build Forms II 9-21
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Practice 9 Overview
This practice covers the following topics:
• Examining and changing relation
properties
• Implementing a coordination-type
toggle for a master-detail form
• Implementing foreign-key delete rules
for a master-detail form
• Creating a relation based on REF values
......................................................................................................................................................
9-22 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 9
......................................................................................................................................................
Practice Contents
• Examining and changing relation properties
• Using check boxes to implement a coordination-type toggle for a master-
detail form.
- The first check box should enable a user to toggle between
immediate coordination and deferred coordination.
- The second check box should enable a user to toggle between auto
query and no auto query in the detail block.
• Implementing foreign-key delete rules for a master-detail form.
• Creating a relation based on REF values.
......................................................................................................................................................
Oracle Developer: Build Forms II 9-23
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
Practice 9
1 Open the ORDERS form and examine the properties of the relation
called S_ORD_S_ITEM.
a Note the deletion and coordination property values.
b Run the ORDERS form and test the way deletes are handled.
2 Implement a query coordination-type toggle.
a Add two check boxes to the control block with the following
properties:
......................................................................................................................................................
9-24 Oracle Developer: Build Forms II
Practice 9
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 9-25
Lesson 9: Controlling Data Block Relationships
......................................................................................................................................................
......................................................................................................................................................
9-26 Oracle Developer: Build Forms II
10
................................
Objectives
Objectives
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 50 minutes
Total 100 minutes
......................................................................................................................................................
10-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
You have already seen that Oracle Developer applications frequently consist of more
than one form. This lesson revisits the topic of multiple form applications and takes a
deeper look into the ways in which one form module can invoke another and the
effects this has on transaction processing.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the various ways of invoking additional form modules
• Open, call, and close form modules
• Navigate between form modules
• Control open form modules and called form modules
• Manage transaction processing for open and called form modules.
• Choose the most appropriate method for invoking form modules
• Pass form parameters
......................................................................................................................................................
Oracle Developer: Build Forms II 10-3
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
OPEN_FORM to Invoke
Additional Forms
A B
• Modeless
• Different transaction
scopes
OPEN_FORM(′form_name
OPEN_FORM( ′form_name′,
′, activate_mode,
activate_mode,
session_mode,
session_mode, data_mode, paramlist);
data_mode, paramlist);
Characteristics of OPEN_FORM
• Restricted
• Not valid in Enter Query mode
• No savepoint issued
• Modeless with respect to other opened
forms
• Session run time option:
FORMS50_SESSION
Instructor Note
Explain that “different transaction scopes” refers to the SESSION/NO_SESSION
parameter of the OPEN_FORM built-in.
......................................................................................................................................................
10-4 Oracle Developer: Build Forms II
OPEN_FORM to Invoke Additional Forms
......................................................................................................................................................
Syntax
OPEN_FORM(’form_name’, activate_mode, session_mode, data_mode,
paramlist);
Parameter Description
form_name The file holding the executable module
activate_mode Either ACTIVATE (the default) or NO_ACTIVATE
session_mode Either NO_SESSION (the default) or SESSION
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a parameter list
(This argument is optional.)
Characteristics of OPEN_FORM
• Is a restricted procedure
• Causes opened form to be modeless
• Can start a new database session
......................................................................................................................................................
Oracle Developer: Build Forms II 10-5
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Closing Forms
• CLOSE_FORM:
– form_name
– form_id
• Characteristics of CLOSE_FORM:
– Restricted
– Not valid in Enter-Query mode
– CLOSE_FORM or EXIT_FORM
– Cannot close a form that called
another form
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Explanation for next page pair: Explain that NEXT_FORM stops the execution of
subsequent statements in the trigger or program unit.
Stress that the When-New-Form-Instance trigger does not fire on navigation into a
form unless the form is being started. Point out that the When-Window-Activated
trigger should be used for synchronizing forms in a multiple-form application.
Demonstration for next page pair: Use the Multiple Form (Customer - Form 1)
(Mf_cus.fmb), Multiple Form (Order - Form 2) (Mf_ord.fmb), and Multiple
Form (Item - Form 3) (Mf_itm.fmb) files to demonstrate the navigational and
validation aspects of multiple-form applications.
You can also use the Open/Call_Form (DEPT form) (dept.fmb) and Open/
Call_Form (EMP form) (emp.fmb) to illustrate when the triggers fired.
......................................................................................................................................................
10-6 Oracle Developer: Build Forms II
Closing Forms
......................................................................................................................................................
Closing Forms
Syntax
CLOSE_FORM(form_name);
CLOSE_FORM(form_id);
Parameter Description
form_name The module name of the form (not the .fmx filename)
form_id The internal form module ID of the form (of type Form Module)
......................................................................................................................................................
Oracle Developer: Build Forms II 10-7
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
10-8 Oracle Developer: Build Forms II
Navigating Between Forms
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-9
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Session
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
10-10 Oracle Developer: Build Forms II
Transaction Processing for Opened Forms
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-11
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
CALL_FORM to Invoke
Additional Forms
A B
• Modal
• Returns to calling
form
CALL_FORM(′form_name
CALL_FORM( ′form_name′,
′, display,
display,
switch_menu,
switch_menu, query_mode,
query_mode,
data_mode, paramlist);
data_mode, paramlist);
Copyright Oracle Corporation, 1999. All rights reserved.
Characteristics of CALL_FORM
• Unrestricted
• Valid in Enter Query mode
• Savepoint issued
• Modal with respect to calling form
• Does not cause navigation and
validation
• Forms called from query-only form are
always query-only
• Exiting a called form
Instructor Note
Demonstration: Use the Open/Call_Form (DEPT form) (dept.fmb) and Open/
Call_Form (EMP form) (emp.fmb) to illustrate the CALL_FORM built-in.
......................................................................................................................................................
10-12 Oracle Developer: Build Forms II
CALL_FORM to Invoke Additional Forms
......................................................................................................................................................
Syntax
CALL_FORM(’form_name’, display, switch_menu, query_mode,
data_mode, paramlist);
Parameter Description
form_name The file holding the executable form module
display Either HIDE (the default) or NO_HIDE (This defines whether the call-
ing form should be hidden from view while the called form is running.)
switch_menu Either NO_REPLACE (the default) or DO_REPLACE (This defines
whether the current menu module should be replaced by the default
menu of the called form.)
query_mode Either NO_QUERY_ONLY (the default) or QUERY_ONLY (This
defines whether the called form should run in Query Only mode.)
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a parameter list
(This argument is optional.)
Characteristics of CALL_FORM
• Is valid in Enter Query mode
• Causes Forms to issue a savepoint
• Causes called form to be modal
• Does not cause navigation or validation in the initial form
• Can call a form in Query Only mode
• Propagates query-only parameter through all subsequent called forms
• Returns control to the calling form and resumes processing of the
PL/SQL code at the statement immediately following the calling
statement (This occurs when Forms exits the called form.)
......................................................................................................................................................
Oracle Developer: Build Forms II 10-13
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Transaction Processing
for Called Forms
Instructor Note
Demonstration: Use the Open/Call_Form (DEPT form) (dept.fmb) and Open/
Call_Form (EMP form) (emp.fmb) to illustrate the Post-Only mode.
......................................................................................................................................................
10-14 Oracle Developer: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-15
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Transaction Processing
for Called Forms
Examples of adjusting default transaction
processing:
Key-Commit on form
IF
IF <form
<form called>
called> THEN
THEN
POST;
POST;
ELSE
ELSE
COMMIT_FORM;
COMMIT_FORM;
END
END IF;
IF;
Transaction Processing
for Called Forms
Key-Exit on form
IF <form called> THEN
EXIT_FORM(ASK_COMMIT, NO_ROLLBACK);
ELSE
EXIT_FORM;
END IF;
Instructor Note
Demonstration: Open the Open/Call_Form (DEPT form) (dept.fmb) and Open/
Call_Form (EMP form)(emp.fmb) demonstrations. Remove the comments in the
Key-Exit and Key-Commit triggers.
......................................................................................................................................................
10-16 Oracle Developer: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................
Examples
Key-Commit trigger at form level:
BEGIN
IF GET_APPLICATION_PROPERTY(calling_form) is not null THEN
POST;
ELSE
COMMIT_FORM;
END IF;
END;
Key-Exit trigger at form level:
BEGIN
IF GET_APPLICATION_PROPERTY(calling_form) is not null THEN
EXIT_FORM(ask_commit, no_rollback);
ELSE
EXIT_FORM;
END IF;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 10-17
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
NEW_FORM to Invoke
Additional Forms
A B
NEW_FORM(′form_name
NEW_FORM( ′form_name′,
′, rollback_mode,
rollback_mode,
query_mode,
query_mode, data_mode,
data_mode,
paramlist);
paramlist);
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
10-18 Oracle Developer: Build Forms II
NEW_FORM to Invoke Additional Forms
......................................................................................................................................................
Syntax
NEW_FORM(’form_name’, rollback_mode, query_mode, data_mode,
paramlist);
Parameter Description
form_name The file holding the executable form module
rollback_mode Either TO_SAVEPOINT (the default), NO_ROLLBACK, or
FULL_ROLLBACK
query_mode Either NO_QUERY_ONLY (the default) or QUERY_ONLY (This
defines whether the called form should run in Query Only mode.)
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a parameter list
(This argument is optional.)
......................................................................................................................................................
Oracle Developer: Build Forms II 10-19
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Controlling Opened
and Called Forms
Form A Form C Form D
OPEN_FORM
S.P.
CALL_FORM
CALL_FORM
Form B
OPEN_FORM
S.P.
CALL_FORM
Form F
Form E
Form A+B+E = Call form stack
Copyright Oracle Corporation, 1999. All rights reserved.
Technical Note
You can obtain information about the call form stack by using the
GET_APPLICATION_PROPERTY built-in with the CALLING_FORM parameter.
Instructor Note
The slide illustrates the restrictions on using OPEN_FORM and CALL_FORM.
In this scenario, Form A calls Form B, Form B then opens Form C, Form C then opens
Form D; and Form B then calls Form E.
• The call is not allowed to navigate to Forms A and B.
• The current call form stack consists of Forms A, B, and E.
• A form cannot be called from Form C and D.
• Changes in any form are rolled back to the savepoint (S.P.) that was set
when Form E was called.
......................................................................................................................................................
10-20 Oracle Developer: Build Forms II
Controlling Open Forms and Called Forms Together
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-21
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
10-22 Oracle Developer: Build Forms II
Different Ways of Invoking Forms
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-23
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Runform Form B
command line Design-time
parameters
Form A P1
P2
Run time
P3
OPEN_FORM
Parameter CALL_FORM
list
NEW_FORM
......................................................................................................................................................
10-24 Oracle Developer: Build Forms II
Using Form Parameters
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-25
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Instructor Note
Demonstration: Use the Multiple Form (Order - Form 2)(Mf_ord.fmb)
demonstration to show the properties of the CUS_ID form parameter.
......................................................................................................................................................
10-26 Oracle Developer: Build Forms II
Using Form Parameters
......................................................................................................................................................
Example
Pass a value for the CUS_ID form parameter to the ORDITEM form by way of the
Runform command line. Note that MODULE and USERID are predefined command
line parameters.
ifrun60.exe module=orditem userid=scott/tiger cus_id=202
Example
Assign the value of the CUS_ID form parameter to the CUSTOMER_ID item in the
ORDER block.
:order.customer_id := :PARAMETER.cus_id;
......................................................................................................................................................
Oracle Developer: Build Forms II 10-27
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Parameter Lists
Parameter
list
OPEN_FORM( …, )
CALL_FORM( …, )
NEW_FORM( …, )
The default parameter list is DEFAULT.
Copyright Oracle Corporation, 1999. All rights reserved.
Technical Note
You must define the parameters whose values are being passed to a form in that form
at design time.
......................................................................................................................................................
10-28 Oracle Developer: Build Forms II
Parameter Lists
......................................................................................................................................................
Parameter Lists
One way to supply form parameter values is to specify a parameter list in the call to
the built-in that invokes the form.
......................................................................................................................................................
Oracle Developer: Build Forms II 10-29
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Parameter
ORDERS DATA_PARAMETER ‘RG_ORD’
list ID
ADD_PARAMETER
GET_PARAMETER_ATTR
DESTROY_PARAMETER_LIST
SET_PARAMETER_ATTR
DELETE_PARAMETER
Copyright Oracle Corporation, 1999. All rights reserved.
Technical Note
You cannot create a parameter list named DEFAULT or one that already exists. Use
GET_PARAMETER_LIST and ID_NULL to check whether a parameter list already
exists.
Instructor Note
Use the Multiple Form (Customer - Form 1) (Mf_cus.fmb) demonstration to show
the PASS_CUS procedure, which creates a parameter list and adds the CUS_ID
parameter.
Demonstration for the next page pair: Use the Multiple Form (Customer - Form 1)
(Mf_cus.fmb) file to show the methods of passing data between forms in a multiple-
form application. Show the When-Button-Pressed trigger on the CTL.OPEN_FORM
button and explain that the final argument to the OPEN_FORM built-in is the
parameter list name.
Point out the use of a global variable in the first line of the code.
......................................................................................................................................................
10-30 Oracle Developer: Build Forms II
Creating and Manipulating Parameter Lists
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 10-31
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
P1 P1
P2 P2
P3 P3
Technical Note
Global variables are used more often than parameters for passing data between forms.
......................................................................................................................................................
10-32 Oracle Developer: Build Forms II
Passing Data Between Forms
......................................................................................................................................................
Example
The When-Button-Pressed trigger on the CTL.OPEN_ORDITEM item:
DECLARE
v_pl_id PARAMLIST;
BEGIN
IF not ID_NULL(GET_PARAMETER_LIST(’cus’)) THEN
DESTROY_PARAMETER_LIST(’cus’);
END IF;
v_pl_id := CREATE_PARAMETER_LIST(’cus’);
ADD_PARAMETER(v_pl_id,’cus_id’,text_parameter,
TO_CHAR(:cus.id));
OPEN_FORM(’orditem’, activate, no_session,
no_share_library_data, ’cus’);
END;
Note: You must define the CUS_ID parameter in the ORDITEM form at design time,
because each run-time parameter must have a corresponding design-time parameter in
the target form.
......................................................................................................................................................
Oracle Developer: Build Forms II 10-33
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Summary
Summary
• Transaction processing
– Opened forms: Within same or
different sessions
– Called forms: Post-Only mode; a
rollback to savepoint
• Using form parameters and parameter
lists
– Methods for parameter passing
– Referencing form parameters
– Text parameters and data parameters
– Built-ins for parameter lists
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
10-34 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
The Three Built-ins for Invoking Forms
• OPEN_FORM
• CALL_FORM
• NEW_FORM
......................................................................................................................................................
Oracle Developer: Build Forms II 10-35
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Practice 10 Overview
This practice covers implementing a
button on CUSTOMER to call
EMPLOYEE:
• Performing an automatic query on the
EMPLOYEE form based on the current
Sales Rep ID in the CUSTOMER form
• Ensuring that posted changes in
EMPLOYEE are not rolled back
• Ensuring that [Commit] performs a post
when EMPLOYEE is called from another
form
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
10-36 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 10
......................................................................................................................................................
Practice Contents
Implement a button on the CUSTOMER form to call the EMPLOYEE form.
• Perform an automatic query on the EMPLOYEE form based on the
current sales rep ID in the CUSTOMER form.
• Ensure that posted changes in the EMPLOYEE form are not rolled back
on exit.
• Ensure that when the EMPLOYEE form is called by another form,
[Commit] performs a post.
......................................................................................................................................................
Oracle Developer: Build Forms II 10-37
Lesson 10: Building Multiple Form Applications
......................................................................................................................................................
Practice 10
1 Produce a multiple form application by linking the CUSTOMERS and
the EMPLOYEES forms.
a In the control block of the CUSTOMERS form, create a button
called EMPLOYEE_BUTTON. Place it on the CV_CUST canvas,
below the Orders button.
b Define a trigger for CONTROL.EMPLOYEE_BUTTON that calls
the EMPLOYEES form with the current sales representative ID.
- Change the Mouse Navigate property of
CONTROL.EMPLOYEE_BUTTON to No.
- Create a parameter list called SALES.
- Add the SALES_ID parameter to the parameter list. The type of this
parameter is TEXT_PARAMETER, and it is initialized with the
value of the SALES_REP_ID item.
- Invoke the EMPLOYEES form by using the CALL_FORM built-in.
You can import the pr10_1b.txt file.
c Open the EMPLOYEES form module.
d In the Object Navigator, create a parameter called SALES_ID.
e Add a trigger to ensure that queries on the employee block are
restricted by the value of the SALES_ID parameter. Replace the
existing code with the code in the pr10_1e.txt file.
f Save and compile each form, then run the CUSTOMERS form
module. Test the application by exiting the EMPLOYEE form using
the menu or the toolbar.
If you have time...
2 Transaction processing for called forms:
a Make sure that any changes in the EMPLOYEES form that are
posted by a user are not rolled back by Forms upon exit.
b Make sure that when the CUSTOMERS form calls the
EMPLOYEES form, [Commit] performs a post. You can import the
pr10_2b.txt file.
c Save and compile each form, then run the CUSTOMERS form
module and test your application.
......................................................................................................................................................
10-38 Oracle Developer: Build Forms II
11
................................
Objectives
After completing this lesson, you should
be able to do the following:
• Describe the record group object
• Use record groups
• Define record groups at design time
• Control record groups by using built-in
functions
• Define query record groups
programmatically
• Define nonquery record groups
programmatically
Copyright Oracle Corporation, 1999. All rights reserved.
Objectives
• Manipulate record group rows
• Define lists of values (LOVs)
programmatically
• Manipulate list items programmatically
• Implement dynamic list items
• Add values to combo boxes
Instructor Note
Topic Timing
Lecture 50 minutes
Practice 40 minutes
Total 90 minutes
......................................................................................................................................................
11-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
Record groups are useful constructs for storing structured data, and they can
be manipulated at run time. This lesson covers how to create, modify, and
delete record groups at design time and programmatically at run time. It also
covers how you apply record groups in useful ways, such as for dynamic list
items.
Objectives
After completing this lesson, you should be able to do the following:
• Describe the record group object
• Use record groups
• Define record groups at design time
• Control record groups by using built-in functions
• Define query record groups programmatically
• Define nonquery record groups programmatically
• Manipulate record group rows
• Define lists of values (LOVs) programmatically
• Manipulate list items programmatically
• Implement dynamic list items
• Add values to condo boxes
......................................................................................................................................................
Oracle Developer: Build Forms II 11-3
Lesson 11: Working with Record Groups
......................................................................................................................................................
Record Groups
Record Groups
Record groups and LOVs
• Forms implicitly creates query record
groups.
• Use SET_LOV_PROPERTY to replace
default record group.
...
...
IF
IF Get_LOV_Property(lov_id,GROUP_NAME)
Get_LOV_Property(lov_id,GROUP_NAME) == ’GROUP1’
’GROUP1’
THEN
THEN
Set_LOV_Property(lov_id,GROUP_NAME,’GROUP2’);
Set_LOV_Property(lov_id,GROUP_NAME,’GROUP2’);
END
END IF;
IF;
...
...
......................................................................................................................................................
11-4 Oracle Developer: Build Forms II
Record Groups
......................................................................................................................................................
Record Groups
What Is a Record Group?
A record group is an internal Forms data structure that is similar to a
database table. It can have columns of type CHAR, NUMBER, or DATE,
and its data is stored in rows. Record groups exist in local Forms memory,
rather than in the database.
Note: When you create a record group, you cannot specify its type
explicitly. The type is implied by when and how you create the record group.
......................................................................................................................................................
Oracle Developer: Build Forms II 11-5
Lesson 11: Working with Record Groups
......................................................................................................................................................
......................................................................................................................................................
11-6 Oracle Developer: Build Forms II
Using Record Groups
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-7
Lesson 11: Working with Record Groups
......................................................................................................................................................
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show how you create query record
groups (CUSTOMER_ID) and static record groups (STATIC_GROUP).
......................................................................................................................................................
11-8 Oracle Developer: Build Forms II
Defining Record Groups at Design Time
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-9
Lesson 11: Working with Record Groups
......................................................................................................................................................
DELETE_GROUP
Copyright Oracle Corporation, 1999. All rights reserved.
ADD_GROUP_ROW
Row No ID Name Address
1 201 Unisports
2
3 203 Delhi Sports
4 204 Womansport
DELETE_GROUP_ROW
ADD_GROUP_COLUMN
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Point out that CREATE_GROUP_FROM_QUERY does not populate the record
group. ADD_GROUP_ROW adds an empty row. Row No is an internal number.
......................................................................................................................................................
11-10 Oracle Developer: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-11
Lesson 11: Working with Record Groups
......................................................................................................................................................
ID Name
SET_GROUP_CHAR_CELL
GET_GROUP_NUMBER_CELL
Technical Note
POPULATE_GROUP built-in function returns 0 when population succeeds
and 1 if population does not succeed.
......................................................................................................................................................
11-12 Oracle Developer: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
Note: You can convert a nonquery record group into a query record group
by using the POPULATE_GROUP_WITH_QUERY built-in function to
populate the nonquery record group.
......................................................................................................................................................
Oracle Developer: Build Forms II 11-13
Lesson 11: Working with Record Groups
......................................................................................................................................................
GET_
GROUP_
SET_GROUP_SELECTION ROW_
GET_GROUP_SELECTION COUNT
Copyright Oracle Corporation, 1999. All rights reserved.
Instructor Note
Explain the built-ins and describe how with SET_GROUP_SELECTION, if
you select rows 2 and 4, the associated selection numbers are 1 and 2.
Explain that the record group type (query, nonquery, static) and time of
creation (design time or run time) determine which built-in functions are
valid for a particular record group.
......................................................................................................................................................
11-14 Oracle Developer: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-15
Lesson 11: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
Populate group
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code for creating a query
record group. Use the DEFINE_QUERY_RECORD_GROUP procedure.
......................................................................................................................................................
11-16 Oracle Developer: Build Forms II
Defining Query Record Groups Programmatically
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-17
Lesson 11: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code for creating a nonquery
record group. Use the DEFINE_NON_QUERY_RECORD_GROUP
procedure.
......................................................................................................................................................
11-18 Oracle Developer: Build Forms II
Defining Nonquery Record Groups Programmatically
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-19
Lesson 11: Working with Record Groups
......................................................................................................................................................
Cell value=
For all given value
group Yes No
rows
Return row
number
Return NULL
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code for manipulating
record group rows. Use the GET_VALUE_GRPROW function to show the
code that you use to search for a specific value in a record group.
Explain that this technique can be used with a combo box to determine
whether or not the value already exists in the record group.
......................................................................................................................................................
11-20 Oracle Developer: Build Forms II
Manipulating Record Group Rows
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-21
Lesson 11: Working with Record Groups
......................................................................................................................................................
Row number
For all even?
group Yes No
rows
Mark row
as selected
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code for manipulating
selected record group rows.
Use the SELECT_EVEN_ROWS procedure to show the code for searching
for a specific row in a record group.
Use the GET_VALUE_GRPSEL function to show the code for looping
through the row in a record group.
Explain that the even number can be identified by using the MOD function.
......................................................................................................................................................
11-22 Oracle Developer: Build Forms II
Manipulating Selected Record Group Rows
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-23
Lesson 11: Working with Record Groups
......................................................................................................................................................
Technical Note
If a global record group is created from (or populated with) a query while
executing a Form A, and the query string contains bind variable references
that are local to A (:block.item or :PARAMETER.param), then when Form
A terminates execution, the global query record group is converted to a
global nonquery record group. The record group retains its data, but a
subsequent POPULATE_GROUP is considered an error.
Instructor Note
Demonstration: Use the Global Record Groups (Orders2.fmb)
demonstration to illustrate the use of a global record group. Click the
product_lov button to display a list of values form. Press [Ctrl] and click the
products that you want. Then click the OK button. The products selected are
returned by way of a global record group to the ORDERS form. You can
show the When-Mouse-Click trigger of the lov_product form.
......................................................................................................................................................
11-24 Oracle Developer: Build Forms II
Defining Global Record Groups
......................................................................................................................................................
Scope Parameter
A “scope” parameter can be added to the CREATE_GROUP and
CREATE_GROUP_FROM_QUERY built-ins. The value for this scope can
be either:
• FORM_SCOPE
• GLOBAL_SCOPE
If you omit this parameter, the default is FORM_SCOPE.
Once created, a global record group persists for the remainder of the
application.
......................................................................................................................................................
Oracle Developer: Build Forms II 11-25
Lesson 11: Working with Record Groups
......................................................................................................................................................
POPULATE_LIST RETRIEVE_LIST
CHAR Column 1 CHAR Column 2
......................................................................................................................................................
11-26 Oracle Developer: Build Forms II
Manipulating List Items Programmatically
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-27
Lesson 11: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
Populate group
Yes Success? No
Populate list
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code of the
POPULATE_LIST_WITH_QUERY procedure.
Explain that the When-Create-Record trigger is used because it is too late
for the When-List-Changed trigger to here.
Another option is to use the When-Mouse-Down trigger.
......................................................................................................................................................
11-28 Oracle Developer: Build Forms II
Implementing Dynamic List Items
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-29
Lesson 11: Working with Record Groups
......................................................................................................................................................
Element value=
For all Item value?
list Yes No
elements
Return
Instructor Note
Demonstration: Use the Record Groups (Code Examples)
(rec_grp.fmb) demonstration to show the code of the
ADD_COMBO_BOX_ELEMENT procedure.
......................................................................................................................................................
11-30 Oracle Developer: Build Forms II
Adding Values to Combo Boxes
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-31
Lesson 11: Working with Record Groups
......................................................................................................................................................
Summary
Summary
......................................................................................................................................................
11-32 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
A record group is an internal Forms data structure that is similar to a
database table.
......................................................................................................................................................
Oracle Developer: Build Forms II 11-33
Lesson 11: Working with Record Groups
......................................................................................................................................................
Practice 11 Overview
......................................................................................................................................................
11-34 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 11
......................................................................................................................................................
Practice Contents
• Convert a text item into a list item that is populated dynamically at run
time.
• Create a list of values form that allows multiple values to be selected
simultaneously and returned to the calling form by way of a global
record group.
......................................................................................................................................................
Oracle Developer: Build Forms II 11-35
Lesson 11: Working with Record Groups
......................................................................................................................................................
Practice 11
1 Create a dynamic list item. This functionality avoids having to create a
new item to display the department name.
a Open the EMPLOYEES form module.
b Create a design time query record group that contains IDs and names
of departments. Name your record group DEPT_ID.
In the Object Navigator, create a record group named DEPT_ID based
on the query below:
SELECT name || ’ in region ’ || TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
ORDER BY 1
c Convert the text item DEPT_ID into a list item, Combo Box Style.
Resize it in the Layout Editor.
d Create an element in the list. Label: Dummy and Value: 0
e Create a procedure called LIST_FROM_DESIGNTIME_GROUP.
This procedure accepts the list item name as an argument and
populates the list item dynamically at runtime, using the design-time
query record group. You can import the pr11_1e.txt file.
f Call the procedure each time a new record is created. You can import
the pr11_1f.txt file.
g Save, compile, and test the module.
If you have time...
2 Create a multirecord select list form. This practice shows how to create a
list of values where the user can select multiple values. This lab uses a
global record group.
a Exit Form Builder.
b Run Form Builder and create a new form based on a template named
lov_prod_template.fmb.
c Examine this new module and save it as lov_product.fmb.
Create a When-Mouse-Click trigger at the PROD_LOV_BLK block
level that selects or clears a record when a user presses Control-
clicks for a product.
d Write the code to create a record group if it does not already exist
and add columns to the group for each item in the
PROD_LOV_BLK block. If the record group exists write the code to
......................................................................................................................................................
11-36 Oracle Developer: Build Forms II
Practice 11
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 11-37
Lesson 11: Working with Record Groups
......................................................................................................................................................
......................................................................................................................................................
11-38 Oracle Developer: Build Forms II
12
................................
Including Charts
and Reports
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Objectives
After completing this lesson, you should
be able to do the following:
• Include charts in an application
• Integrate other graphics displays in an
application
• Include reports in an application
Instructor Note
Topic Timing
Lecture 40 minutes
Practice 40 minutes
Total 80 minutes
......................................................................................................................................................
12-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn how to include other module types in your
application, such as charts built using Graphics Builder and reports built
using Report Builder.
Objectives
After completing this lesson, you should be able to do the following:
• Include charts in an application
• Integrate other graphics displays in an application
• Include reports in an application
......................................................................................................................................................
Oracle Developer: Build Forms II 12-3
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Instructor Note
Demonstration:
Step 1: Open the Employee Form (Emp.fmb)demonstration. Display the
CANVAS4 canvas. From the Layout Editor toolbar, change the Block pop-
up list from EMP to CONTROL. Using the Chart tool, drag a chart area onto
the canvas. (The Employee form is based on the EMP table. If it does not
already exist, it can be created by running the utlsample.sql file.
(Instructions for this demonstration continue in the next instructor note.)
......................................................................................................................................................
12-4 Oracle Developer: Build Forms II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Incorporating a Chart
The steps to create a chart are:
1 Specify a chart type and subtype.
2 Specify the data block that contains the data you want to assign to chart
columns.
3 Specify the data to appear on the Category (X) axis of the chart.
4 Specify the data to appear on the Value (Y) axis of the chart.
Follow the prompts on each page of the wizard to specify the settings for the
chart you want to create.
......................................................................................................................................................
Oracle Developer: Build Forms II 12-5
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Chart
type
Arrow
indicates that
data from
the block is
represented
in the chart.
Instructor Note
Step 2: Select Column for the chart type.
Step 3: Select the EMP block. (continued)
......................................................................................................................................................
12-6 Oracle Developer: Build Forms II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Chart Type
Select the style of chart that you require. The picture on the left of the wizard
displays the relevant chart style.
The chart subtype options are context-sensitive; the number and style of
options change depending on the chart type that you choose. Choose the
chart subtype that you require, and then click Next to continue to the next
wizard page.
Data Source
The next step in the Chart Wizard is to select the block that contains the data
you want to represent in the chart. The data block you select determines the
data that is available for assignment to the Category and Value axes of your
chart.
......................................................................................................................................................
Oracle Developer: Build Forms II 12-7
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Arrow points
to the
Category
axis.
Arrow points
to the Value
axis.
Instructor Note
Step 4: Select ENAME for the Category axis.
Step 5: Select SAL for the Value axis. Save into Disp1.ogd. Run your
form.
......................................................................................................................................................
12-8 Oracle Developer: Build Forms II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Category Axis
To use the Chart Wizard to map data to your chart’s Category (X) axis:
1 In the Available Fields list, select the field that you want to map to the
Category (X) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Category
Axis list.
Note
Value Axis
To use the Chart Wizard to map data to your chart’s Value (Y) axis:
1 In the Available Fields list, select the field that you want to map to the
Value (Y) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Value
Axis list.
Note
Note: You must transfer at least one field from the Available Fields list to
the Category Value list before navigating to the next page.
......................................................................................................................................................
Oracle Developer: Build Forms II 12-9
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Filename
Execution Mode
Communication Mode
Data Source Data Block
Query Name
Data Source X Axis
Data Source Y Axis
Update on Query
Update on Commit
Instructor Note
The default name of the Query Name property is Genie_Query. The query is
created automatically with the structure of the Data Source Data Block.
......................................................................................................................................................
12-10 Oracle Developer: Build Forms II
Chart Item Properties
......................................................................................................................................................
Property Description
Filename Specifies the name of the file where the chart is stored
Execution Mode Specifies the execution version of Graphics Builder to use:
BATCH or RUNTIME
Communication Mode Specifies the communication mode to be used when calling
Graphics Builder: SYNCHRONOUS or ASYNCHRONOUS
Data Source Data Block Specifies the block that contains the data to represent in the chart
Query Name Specifies the name of the query used to display the chart
Data Source X Axis Specifies the item name used to map data to the chart Category
(X) axis
Data Source Y Axis Specifies the item name used to map data to the chart Value (Y)
axis
Update on Query Specifies that the chart is refreshed each time you perform a
query
Update on Commit Specifies that the chart is refreshed each time you perform a
commit
......................................................................................................................................................
Oracle Developer: Build Forms II 12-11
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Technical Note
Passing data is applicable only if running against a local server.
Instructor Note
You cannot run a report based on a block that contains a long column.
Demonstration: Open the Customer Form (customers.fmb)
demonstration and create a new report object.
......................................................................................................................................................
12-12 Oracle Developer: Build Forms II
Reporting Within Form Builder
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 12-13
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Oracle Developer
integration properties
Filename
Filename
Execution
Execution Mode
Mode
Communication
Communication Mode
Mode
Data
Data Source
Source Data
Data Block
Block
Query
Query Name
Name
Copyright Oracle Corporation, 1999. All rights reserved.
Reports properties
Instructor Note
Demonstration: Set the Execution Mode property to RUNTIME, the
Communication Mode to SYNCHRONOUS, and the Report Destination
Type to PREVIEW.
......................................................................................................................................................
12-14 Oracle Developer: Build Forms II
Report Object Properties
......................................................................................................................................................
Reports Properties
......................................................................................................................................................
Oracle Developer: Build Forms II 12-15
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Instructor Note
Examples of the syntax for RUN_REPORT_OBJECT,
FIND_REPORT_OBJECT, REPORT_OBJECT_STATUS, and
COPY_REPORT_OUTPUT built-ins are available on the next page.
CANCEL_REPORT_OBJECT is not explained, but you can show the
syntax by expanding the Built-in Packages node in the Object Navigator,
and then STANDARD Extensions node.
GET_REPORT_OBJECT_PROPERTY and
SET_REPORT_OBJECT_PROPERTY are not explained in detail, because
these built-ins are similar to the Get and Set built-ins.
Instructor Note
Demonstration: Create a button in the Control block. Write a When-Button-
Pressed trigger with the following code:
DECLARE
v_rep VARCHAR2(100);
BEGIN
v_rep := RUN_REPORT_OBJECT(’<your_report_object_name>’);
END;
......................................................................................................................................................
12-16 Oracle Developer: Build Forms II
Working with Reports
......................................................................................................................................................
Built-in Description
RUN_REPORT_OBJECT Runs a specified report on a specified server
FIND_REPORT_OBJECT Returns the internal ID of a report object
CANCEL_REPORT_OBJECT Cancels a report in the server queue
REPORT_OBJECT_STATUS Returns the current status of a report (The status
codes can be FINISHED, RUNNING,
CANCELED, OPENING_REPORT,
ENQUEUED, INVALID_JOB,
TERMINATED_WITH_ERROR, or
CRASHED.)
COPY_REPORT_OUTPUT Copies the report output back to the client
GET_REPORT_OBJECT_PROPERTY Dynamically gets report object properties at
run time
SET_REPORT_OBJECT_PROPERTY Dynamically sets report object properties at
run time
RUN_PRODUCT Invokes one of the supported Oracle tools
products and specifies the name of the module or
modules to be run
......................................................................................................................................................
Oracle Developer: Build Forms II 12-17
Lesson 12: Including Charts and Reports
......................................................................................................................................................
DECLARE
v_rep VARCHAR2(100);
repid REPORT_OBJECT;
BEGIN
repid := FIND_REPORT_OBJECT(’deptrpt’);
v_rep := RUN_REPORT_OBJECT(repid);
end;
. . .
repid := FIND_REPORT_OBJECT(’barcode’);
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
IF rep_status = ’FINISHED’ THEN
COPY_REPORT_OBJECT_OUTPUT(v_rep,’c:\local.pdf’);
HOST(’netscape c:\local.pdf’);
END IF;
. . .
Instructor Note
If you want to test the report status when you run a report against a remote
server, the Communication Mode report object property must be
synchronous.
......................................................................................................................................................
12-18 Oracle Developer: Build Forms II
Working with Reports
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 12-19
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Summary
Summary
• Interacting with reports:
– RUN_REPORT_OBJECT
– FIND_REPORT_OBJECT
– CANCEL_REPORT_OBJECT
– REPORT_OBJECT _STATUS
– COPY_REPORT_OUTPUT
– GET_REPORT_OBJECT_PROPERTY
– SET_REPORT_OBJECT_PROPERTY
......................................................................................................................................................
12-20 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
In this lesson, you should have learned how to include charts and reports in
your application. You should have learned how to invoke the Chart Wizard.
......................................................................................................................................................
Oracle Developer: Build Forms II 12-21
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Practice 12 Overview
......................................................................................................................................................
12-22 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 12
......................................................................................................................................................
Practice Contents
• Create a chart to display the total orders for each customer.
• Create a report based on the S_CUSTOMER block.
• Display different report styles.
......................................................................................................................................................
Oracle Developer: Build Forms II 12-23
Lesson 12: Including Charts and Reports
......................................................................................................................................................
Practice 12
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the CUSTOMERS form module.
b Create a new tab page on the TAB_CUSTOMER canvas. Name this
page CHART and change the label name.
Open the FormBuilder_II.olb object library. Copy the
OBJ_CHART object group into the CUSTOMERS form. This object
group contains a block named S_ORD. Only one item from this
block is visible: TITLE. This item displays a title for the chart.
c From the Layout Editor, use the Chart tool to drag a chart area onto
the chart tab page. Select Use the Chart Wizard from the New Chart
Object dialog box. Do not specify a title for the chart.
d Select Column as chart type, Plain as chart subtype.
e Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
f Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
g Click the Finish button. Save, run, and test your form. To display the
chart, click in the Title item on the Chart tab.
2 Create a report object based on the S_CUSTOMER block. This report
displays a customer list using a tabular layout. Display only the ID,
NAME, COUNTRY, and REGION_ID fields.
a Open the CUSTOMERS form.
b Create a new report object.
This will invoke the Report Builder. Within the Report Wizard:
- Choose the report style Tabular.
- Select the ID, NAME, COUNTRY, and CREDIT_RATING fields.
- Do not select fields to total.
- Change labels and widths for your fields.
- Select a template for your report.
c Save your report and exit Report Builder.
d Set the Execution Mode report object property to runtime and the
Report Destination Type report object property to screen.
......................................................................................................................................................
12-24 Oracle Developer: Build Forms II
Practice 12
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 12-25
Lesson 12: Including Charts and Reports
......................................................................................................................................................
......................................................................................................................................................
12-26 Oracle Developer: Build Forms II
13
................................
Applying Timers
Lesson 13: Applying Timers
......................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 25 minutes
Practice 30 minutes
Total 55 minutes
Explanation for the next page: Point out that using
GET_APPLICATION_PROPERTY(timer_name) returns NULL if called
from any trigger other than When-Timer-Expired.
Demonstration for the next page pair: Use the “About...” Information at
Startup (Customers.fmb) demonstration to illustrate one use of timers.
Use the Auto Commit/Rollback After Period of Time to illustrate
automatically asking for COMMIT after a period of time.
......................................................................................................................................................
13-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson covers time-initiated processing; that is, processing that occurs
after a certain amount of time has elapsed. The mechanism you use to do this
is called a timer and it is created, modified, and deleted at run time.
Objectives
After completing this lesson, you should be able to do the following:
• Describe timers
• Create a timer
• Modify a timer
• Delete a timer
• Handle timer expiration
......................................................................................................................................................
Oracle Developer: Build Forms II 13-3
Lesson 13: Applying Timers
......................................................................................................................................................
Timers
• What is a timer?
• Built-ins for timers:
– FIND_TIMER
– CREATE_TIMER
– SET_TIMER
– DELETE_TIMER
– GET_APPLICATION_PROPERTY
(TIMER_NAME)
Copyright Oracle Corporation, 1999. All rights reserved.
Timers
• When-Timer-Expired trigger
• Using timers:
– Poll database
– Periodically query, commit, or
rollback
– Show “About…” information at
startup
Technical Note
Timers are not suitable means of shutting down an application. It is the job
of the operating system to recognize idle processes and shut them down.
......................................................................................................................................................
13-4 Oracle Developer: Build Forms II
Timers
......................................................................................................................................................
Timers
Typically, Forms processes events that are (originally) initiated by the user.
You can use timers when you want Forms to perform a set of actions after a
period of time has elapsed.
What Is a Timer?
A timer is a programmatic construct similar to an “internal alarm clock.”
You can create, modify, or delete timers by means of built-ins. When you
create or modify a timer, you can specify the period of time that elapses
before the timer “expires.” Using a trigger, you can specify what actions
must be performed at that time.
When-Timer-Expired Trigger
This trigger fires when a timer expires; that is, when the specified time
interval of the timer has elapsed.
Uses of Timers
• Polling the database to check if a certain event has occurred
• Performing an automatic query at regular intervals
• Showing “About this...” information at form startup
• Performing an automatic commit or rollback after a specific amount of
idle time
......................................................................................................................................................
Oracle Developer: Build Forms II 13-5
Lesson 13: Applying Timers
......................................................................................................................................................
Timer A B,A
expired
Query
complete
Repeat When-Timer-Expired (B)
When-Timer-Expired (A)
Instructor Note
Explain that:
1 Timer A is created, and when it expires, it is placed in the timer queue.
2 If no other processing is taking place, then the When-Timer-Expired
trigger fires for Timer A.
3 After Timer A has been serviced from the queue, it can begin its next
iteration.
4 Timer B (a nonrepeating timer) is created in the meantime.
5 When Timer B expires, it cannot be immediately serviced by the
When-Timer-Expired trigger, because a query is taking place.
6 After the query is complete, the When-Timer-Expired trigger can fire for
Timer B.
......................................................................................................................................................
13-6 Oracle Developer: Build Forms II
Handling Timer Expiration
......................................................................................................................................................
Timer Queue
When a timer expires, it is put in a queue of expired timers. Forms services
this timer queue on a first-in-first-out basis, but only while it is waiting for
user actions. After an expired timer is handled, it is removed from the queue.
Note: A repeating timer will not begin the next iteration while it is still in
the timer queue.
When-Timer-Expired Trigger
When using the When-Timer-Expired trigger remember that it:
• Fires once for each timer that expires, but only after Form Builder has
completed any current processing of triggers and built-in functions
• Fires after the specified time interval, rather than exactly on the moment
of expiration
• Must be defined at the form level
• Should include the GET_APPLICATION_PROPERTY built-in function
for you to find out which timer has expired
Example
Handle the expiration of two timers named HOUR_ALARM and
ABOUT_STARTUP.
DECLARE
v_timer_name VARCHAR2(30);
BEGIN
v_timer_name := GET_APPLICATION_PROPERTY(timer_name);
IF v_timer_name = ’HOUR_ALARM’ THEN
MESSAGE(’One hour has passed again.’);
ELSIF v_timer_name = ’ABOUT_STARTUP’ THEN
DELETE_TIMER(’ABOUT_STARTUP’);
END IF;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 13-7
Lesson 13: Applying Timers
......................................................................................................................................................
Creating a Timer
Syntax:
CREATE_TIMER
CREATE_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)
Example:
v_timer_id
v_timer_id := CREATE_TIMER ((′hour_alarm’,
:= CREATE_TIMER ′hour_alarm’, cst_hour);
cst_hour);
......................................................................................................................................................
13-8 Oracle Developer: Build Forms II
Creating a Timer
......................................................................................................................................................
Creating a Timer
You can create a timer by using the CREATE_TIMER built-in function,
which returns type TIMER.
Syntax
Parameter Description
timer_name The timer name
milliseconds The duration of the timer in milliseconds (Value must be
between 1 and 2147483648, approximately 25 days.)
iterate Specifies whether the timer should repeat upon expiration
(Valid values are REPEAT—the default—and NO_REPEAT.)
Example
At form startup, create a timer named HOUR_ALARM that expires every
hour.
DECLARE
cst_hour constant NUMBER(7) := 3600000;
--3600000 is one hour in milliseconds
v_timer_id TIMER;
BEGIN
v_timer_id := CREATE_TIMER(’hour_alarm’, cst_hour);
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 13-9
Lesson 13: Applying Timers
......................................................................................................................................................
Modifying a Timer
Syntax:
SET_TIMER
SET_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)
SET_TIMER (timer_id, milliseconds, iterate))
SET_TIMER (timer_id, milliseconds, iterate
Example:
SET_TIMER ((′hour_alarm’,
SET_TIMER ′hour_alarm’, no_change, no_repeat);
no_change, no_repeat );
......................................................................................................................................................
13-10 Oracle Developer: Build Forms II
Modifying a Timer
......................................................................................................................................................
Modifying a Timer
You can modify a timer by using the SET_TIMER built-in procedure.
Syntax
Parameter Description
timer_name The timer name
timer_id The internal timer ID
milliseconds The duration of the timer in milliseconds (Value must be between 1 and
2147483648—approximately 25 days—or must be NO_CHANGE.)
iterate Specifies whether the timer should repeat upon expiration (Valid
values are REPEAT (default), NO_REPEAT, and NO_CHANGE.)
Example
Set the repeat behavior of a timer named HOUR_ALARM without changing
the time interval. The trigger name depends on the situation.
BEGIN
SET_TIMER(’hour_alarm’, no_change, no_repeat);
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 13-11
Lesson 13: Applying Timers
......................................................................................................................................................
Deleting a Timer
Syntax:
DELETE_TIMER
DELETE_TIMER (timer_name)
(timer_name)
DELETE_TIMER (timer_id)
DELETE_TIMER (timer_id)
Example:
...
...
IF
IF NOT
NOT ID_NULL (FIND_TIMER ((′hour_alarm
ID_NULL (FIND_TIMER ′hour_alarm′))
′)) THEN
THEN
DELETE_TIMER (‘hour_alarm’);
DELETE_TIMER (‘hour_alarm’);
END
END IF;
IF;
...
...
......................................................................................................................................................
13-12 Oracle Developer: Build Forms II
Deleting a Timer
......................................................................................................................................................
Deleting a Timer
You can delete a timer by using the DELETE_TIMER built-in procedure.
Syntax
DELETE_TIMER(timer_name)
DELETE_TIMER(timer_id)
Parameter Description
timer_name The timer name
timer_id The internal timer ID
Example
Delete a timer named HOUR_ALARM after first checking that it exists. The
trigger name depends on the situation.
BEGIN
IF NOT ID_NULL(FIND_TIMER(’hour_alarm’)) THEN
DELETE_TIMER(’hour_alarm’);
END IF;
END;
......................................................................................................................................................
Oracle Developer: Build Forms II 13-13
Lesson 13: Applying Timers
......................................................................................................................................................
Summary
• A timer is a programmatic construct
• Built-in functions for timers:
– FIND_TIMER
– CREATE_TIMER
– SET_TIMER
– DELETE_TIMER
– GET_APPLICATION_PROPERTY
(TIMER_NAME)
Copyright Oracle Corporation, 1999. All rights reserved.
Summary
• Using timers
• Handling timer expiration:
– Timer queue
– When-Timer-Expired trigger
......................................................................................................................................................
13-14 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
A timer is a programmatic construct much like an “internal alarm clock.”
Uses of Timers
• Polling the database to check if a certain event has occurred
• Performing an automatic query at regular intervals
• Showing “About this...” information at form startup
• Performing an automatic commit or rollback after a specific amount of
idle time
......................................................................................................................................................
Oracle Developer: Build Forms II 13-15
Lesson 13: Applying Timers
......................................................................................................................................................
Practice 13 Overview
This practice covers the topics:
• Showing “About...” information at form
startup
• Periodically checking to see if there are
locked records and asking the user to
commit or roll back
......................................................................................................................................................
13-16 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 13
......................................................................................................................................................
Practice Contents
• Show “About...” information at form startup.
• If table rows are locked, display an alert that asks the user to commit or
roll back changes after a set period of time.
......................................................................................................................................................
Oracle Developer: Build Forms II 13-17
Lesson 13: Applying Timers
......................................................................................................................................................
Practice 13
1 Show”About...” information at the startup of the form.
aOpen the CUSTOMERS form module.
b Add a window and a canvas to the form that are used to display the
two control items. This window could be considered an ”About...”
window and should be a modal dialog window. Set the Hide on Exit
property to Yes for this window.
c Create manually a new control block, called ABOUT. Create two
items in the ABOUT block that are used to display the user name and
the current date and time.
d Show the ”About...” window for a short period of time at the startup
of the form. You can import the pr13_1d1.txt file for the
When-New-Form-Instance trigger. Add the new code after the
existing code. You can import the pr13_1d2.txt file for the
When-Timer-Expired trigger. Append the new code to the end of the
existing code.
If you have time...
2 Automatically ask the users if they want to commit after a set period of
time.
a Open the CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING, which indicates at all times whether
rows of the S_CUSTOMER table are locked. Append the new code
to the end of the existing code.
c Create the On-Lock trigger to implement the default lock processing,
update the global variable, and create the timer. You can import the
pr13_2c.txt file.
d Write a When-Timer-Expired trigger to display an alert if locks are
still pending after a certain period of time elapses. This alert should
ask the user to commit or roll back the changes. You can replace the
existing code with the code from the pr13_2d.txt file.
Note: You need to create an alert called ASK_SAVE.
Define an alert (called ASK_SAVE) of style Caution with a Yes and a
No button. Define an appropriate message.
e Create the Post-Database-Commit trigger to give the NULL value to
the global variable.You can import the pr13_2e.txt file.
f Create the On-Rollback trigger to implement the default rollback
processing and give the NULL value to the global variable. You can
import the pr13_2f.txt file.
......................................................................................................................................................
13-18 Oracle Developer: Build Forms II
14
................................
Objectives
After completing this lesson, you should
be able to do the following:
• Use Oracle server functionalities in
forms
• Deal with server-side PL/SQL
• Recognize which PL/SQL8 features are
supported in forms, and which are not
• Handle Oracle server errors
• Perform DDL commands by using the
FORMS_DDL built-in subprograms
Instructor Note
Topic Timing
Lecture 25 minutes
Practice 30 minutes
Total 55 minutes
......................................................................................................................................................
14-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson covers the use of Oracle server features in Form Builder
applications. You will learn about storing and calling PL/SQL code,
handling Oracle server errors, and issuing DDL commands from within
forms.
Objectives
At the end of this lesson, you should be able to:
• Use Oracle server functionalities in forms
• Deal with server-side PL/SQL
• Recognize which PL/SQL8 features are supported in forms
• Handle Oracle server errors
• Perform DDL commands by using the FORMS _DDL built-in
subprograms
......................................................................................................................................................
Oracle Developer: Build Forms II 14-3
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
......................................................................................................................................................
14-4 Oracle Developer: Build Forms II
Using Oracle Server Functionality in Forms
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 14-5
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
......................................................................................................................................................
14-6 Oracle Developer: Build Forms II
Dealing with PL/SQL Code
......................................................................................................................................................
Application Partitioning
For enhanced performance, you may want to call or store PL/SQL code on
the client side. In Forms, you can drag and drop PL/SQL program units
between the Oracle server and the application. In this way, you can
optimally divide applications over the available resources. This is called
application partitioning.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-7
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
......................................................................................................................................................
14-8 Oracle Developer: Build Forms II
PL/SQL8 Support
......................................................................................................................................................
PL/SQL8 Support
Oracle Developer Release 6 uses PL/SQL8 in the client and in the server.
However, client-side program units currently cannot support Oracle8 object-
related functionality.
The Stored Program Unit editor has been extended in Oracle Developer
Release 6 to allow editing of the type body (methods) and type specification
(attributes) of Oracle8 user-defined data types.
Instructor Note
Oracle Developer is backward-compatible with client-side program units
built using PL/SQL Version 2. Client-side program units created with
previous releases will run against the PL/SQL8 engine with no modification.
Although stored program units created with previous releases will run
against PL/SQL8, because of syntax incompatibility between PL/SQL8 and
PL/SQL Version 2, these stored program units may compile with errors.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-9
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
......................................................................................................................................................
14-10 Oracle Developer: Build Forms II
New PL/SQL8 Scalar Data Types
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 14-11
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Unsupported Client-Side
PL/SQL8 Features
• Untrusted external procedures
• Object types
• Collection types
• LOB types
• Methods
• Objects as stored procedure parameters
......................................................................................................................................................
14-12 Oracle Developer: Build Forms II
Unsupported Client-Side PL/SQL8 Features
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 14-13
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Database
Trigger/PU
trigger
Explicit DML
Stored
Stored PU call program unit
Instructor Note
Demonstration: Use the Handling of Server Errors (errh.fmb) file to
demonstrate causes of Oracle server errors. Show the code in the
DEMO_RAISE_ERROR procedure and then drag it to the Oracle server.
Create a Before-Insert database trigger on the S_ORD table. Run the form
and show an implicit update causing an error by attempting to change the
primary key value. Attempt an insert and commit. Use [Display Error] to
display the database trigger error. Add comments to the first line of the Key-
Help trigger and remove the comments from the second line. Run the form
and press [Help] to show that the explicit insert, followed by commit, also
results in the database triggers firing.
......................................................................................................................................................
14-14 Oracle Developer: Build Forms II
Handling Errors Raised by the Oracle Server
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 14-15
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Instructor Note
Stress that the On-Error trigger and the DBMS_ERROR_CODE and
DBMS_ERROR_TEXT functions are specifically for handling errors in
implicit DML. (Implicit DML consists of the INSERT, UPDATE, and
DELETE statements implicitly created when changes to a form are saved.)
The PL/SQL functions SQLCODE and SQLERRM are for use with explicit
DML. (Explicit DML consists of the INSERT, UPDATE, and DELETE
statements explicitly written into PL/SQL blocks in the form.)
......................................................................................................................................................
14-16 Oracle Developer: Build Forms II
Handling Errors Raised by the Oracle Server
......................................................................................................................................................
Technical Note
The values of DBMS_ERROR_CODE and DBMS_ERROR_TEXT are not
automatically reset following successful execution.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-17
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Performing DDL
with FORMS_DDL
• Syntax: FORMS_DDL (statement);
• Parameter (<=32 K):PL/SQL block, DML
or DDL statement
• Characteristics:
– Unrestricted; valid in Enter Query
mode
– Statement must not contain bind-
variable references
Performing DDL
with FORMS_DDL
• Characteristics:
– Statement cannot return results
directly
– Use FORM_SUCCESS to check
success of statement
• Hints:
– Query record group instead
FORMS_DDL with SELECT
– Call stored program unit instead of
FORMS_DDL
Copyright Oracle Corporation, 1999. All rights reserved.
......................................................................................................................................................
14-18 Oracle Developer: Build Forms II
Performing DDL with FORMS_DDL
......................................................................................................................................................
Syntax
FORMS_DDL(statement);
Description
FORMS_DDL issues dynamic SQL statements at run time, including
server-side PL/SQL and DDL.
Parameter
The specified statement can be any string expression up to 32K
representing a:
• PL/SQL block
• DML statement
• DDL statement
Do not end the PL/SQL block with a slash or the DML or DDL statement
with a semicolon.
Characteristics
FORMS_DDL is an unrestricted procedure that is also valid in Enter Query
mode.
• The specified statement must not contain bind-variable references.
However, you can concatenate the values of bind variables into the
specified string.
• The statement executed using FORMS_DDL cannot return results to
Forms directly.
• Use the FORM_SUCCESS built-in to check whether the statement
issued using FORMS_DDL executed correctly.
Note: Consider using a query record group with a SELECT statement or
calling a stored program unit, instead of executing FORMS_DDL.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-19
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Performing DDL
with FORMS_DDL
• Example: Create temporary table
FORMS_DDL (‘CREATE table temp (n_col number)‘);
IF not FORM_SUCCESS THEN
MESSAGE (‘Table creation failed.‘);
RAISE form_trigger_failure;
END IF;
Instructor Note
Demonstration: Use the Handling of Server Errors (errh.fmb)
demonstration file to show the code for the CREATE_TEMP_TABLE
procedure. This procedure is called from the Pre-Commit trigger. Show the
code for the EXEC_PROC procedure.
Explain that the Post-Database-Commit trigger does not fire when changes
are issued through the FORMS_DDL built-in, because Form Builder is not
aware of such changes.
......................................................................................................................................................
14-20 Oracle Developer: Build Forms II
Using FORMS_DDL
......................................................................................................................................................
Using FORMS_DDL
The following examples show how you can use the FORMS_DDL built-in
function.
Example
Create a temporary table at the start of a post.
Pre-commit trigger at form level:
BEGIN
FORMS_DDL(’CREATE table temp(n_col number)’);
IF not FORM_SUCCESS THEN
MESSAGE (’Table creation failed.’);
RAISE form_trigger_failure;
END IF;
END;
Example
Execute a procedure with a given name. This is useful if you want to determine
dynamically which procedure should be executed in a certain situation.
PROCEDURE exec_proc (p_proc_name IN VARCHAR2)
IS
BEGIN
FORMS_DDL(’BEGIN ’|| p_proc_name ||’; END;’);
IF not FORMS_SUCCESS THEN
handle_server_error(DBMS_ERROR_CODE,DBMS_ERROR_TEXT);
END IF;
END;
Note: If the FORMS_DDL built-in fails, Forms sets the DBMS_ERROR_CODE
and DBMS_ERROR_TEXT built-ins. Therefore, you can handle Oracle server
errors using the HANDLE_SERVER_ERROR procedure discussed earlier.
Always test the SYSTEM.FORM_STATUS before calling the FORMS_DDL
built-in.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-21
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Summary
• Oracle server features useful for Form
Builder
• Dealing with PL/SQL code
• PL/SQL8 supported and unsupported
features
• Trap errors raised by the Oracle server
– Implicit DML
– Explicit DML or stored program units
• Performing DDL with FORMS_DDL
......................................................................................................................................................
14-22 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Oracle Server Features Useful for Form Builder
• Declarative integrity constraints
• Stored program units
• Database triggers
• DDL
......................................................................................................................................................
Oracle Developer: Build Forms II 14-23
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Practice 14 Overview
......................................................................................................................................................
14-24 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 14
......................................................................................................................................................
Practice Contents
• Handle errors caused by declarative-constraint violations.
• Handle errors caused by stored program units.
......................................................................................................................................................
Oracle Developer: Build Forms II 14-25
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
Practice 14
1 Handle errors caused by declarative constraints violations.
aOpen the CUSTOMERS form module. This form is based on the
S_CUSTOMER table. A primary key constraint is declared on the
column Id.
b Run the CUSTOMERS form and try to add a new customer with an
existing customer number. Assign the new record an Id of 201 and a
name of Dummy. What FRM-error message do you get? What
Oracle server error message do you get? (Select [Display Error] to
see the message.)
c Which trigger must you use to trap error messages caused by
violation of this constraint?
d Which built-in functions must you use to get error messages caused
by violations of this constraint?
e Trap and replace the default constraint-violation message with your
own message. Use the function STRIP_CONSTRAINT_NAME to
detect which constraint was violated. You can import the
pr14_1e1.txt file to create the function and the
pr14_1e2.txt file to replace the existing code in the trigger.
Note: The function STRIP_CONSTRAINT_NAME accepts a complete
server error message, strips away the error number and prefix, and returns a
more readable error message. The details of this function are covered in
Appendix F, “Handling Server Side Errors.”
f Save and compile the form. Try to insert a duplicate Id value, and
note the displayed message.
If you have time...
2 Handle errors caused by stored program units.
a Open the CUSTOMERS form module.
b Implement immediate primary-key checking in the CUSTOMERS
form by creating a procedure called CHECK_PK_CUST. Call this
procedure from an appropriate trigger. You can import the
pr14_2b1.txt file to create the procedure and the
pr14_2b2.txt file to replace the existing code in the trigger.
c Run the form and try to add a new customer with an existing
customer number. Enter an Id value of 201 and press [Next Item] to
fire the When-Validate-Item trigger. What error do you get?
......................................................................................................................................................
14-26 Oracle Developer: Build Forms II
Practice 14
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 14-27
Lesson 14: Using Server Features in Form Builder
......................................................................................................................................................
......................................................................................................................................................
14-28 Oracle Developer: Build Forms II
15
................................
Using Reusable
Components
Lesson 15: Using Reusable Components
......................................................................................................................................................
Objectives
Instructor Note
Topic Timing
Lecture 25 minutes
Practice 45 minutes
Total 70 minutes
......................................................................................................................................................
15-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn about the reusable components that are
available with Oracle Developer. You will learn how these components can
fit into any application.
Objectives
After completing this lesson, you should be able to do the following:
• List the reusable components
• Include the calendar object in an application
......................................................................................................................................................
Oracle Developer: Build Forms II 15-3
Lesson 15: Using Reusable Components
......................................................................................................................................................
Reusable Components
I’m the
navigator
I’m the
calendar
Instructor Note
Many of the demonstrations contain objects and techniques that the students
may want to copy. They may reuse the icons, images, ActiveX controls,
menus, and all other files provided in the demonstrations in their own
applications. They may also include the components within a product of
their own, including a commercial product that they sell to third parties.
There is no license or fee required for any such reuse.
These components are provided as is. Oracle Corporation makes no
warranty as to their correctness or their fitness for any particular purpose. If
they reuse any of these components in their own applications, whether
modified or unmodified, they do so entirely at their own risk. Oracle
Corporation does not provide any support for these components.
ActiveX (OCX) controls are provided solely for demonstration purposes.
Oracle does not support these controls and makes no guarantee as to their
reliability. For their own applications, Oracle strongly recommends that they
purchase supported, commercial controls such as those supplied by our
Open Tools Initiative partners.
Oracle Corporation retains all copyrights on these demonstrations,
components, icons, ActiveX controls, and images.
......................................................................................................................................................
15-4 Oracle Developer: Build Forms II
Reusable Components
......................................................................................................................................................
Reusable Components
Oracle Developer contains a complete set of demonstrations that illustrate
the power and productivity of the product. These demonstrations contain
many tips and techniques that you can copy and use in your own
applications.
Technical Note
Some of the demonstrations and reusable components require PL/SQL
features that are supported only in Oracle7 release 7.3 or later. If your
database does not support these features, certain packages will be created
but marked as Invalid. If you try to run a demonstration that requires these
objects, you will see a warning that the packages are invalid.
......................................................................................................................................................
Oracle Developer: Build Forms II 15-5
Lesson 15: Using Reusable Components
......................................................................................................................................................
Instructor Note
Demonstration: Use the Orders (Orders.fmb) to demonstrate the
implementation of the calendar class and the picklist class.
Navigate to the DATE_ORDERED item and press [F9] to display the
calendar.
Click the PRODUCT_LOV button to display the picklist form.
......................................................................................................................................................
15-6 Oracle Developer: Build Forms II
Reusable Components List
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 15-7
Lesson 15: Using Reusable Components
......................................................................................................................................................
......................................................................................................................................................
15-8 Oracle Developer: Build Forms II
Reusable Components List
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 15-9
Lesson 15: Using Reusable Components
......................................................................................................................................................
Creating a Calendar
To create a calendar:
1. Copy or make the Calendar Object
Group a subclass.
2. Attach the PL/SQL library
CALENDAR.PLL.
3. Create a Key-Listval trigger.
4. Call Date_LOV.Get_Date.
......................................................................................................................................................
15-10 Oracle Developer: Build Forms II
The Calendar Class
......................................................................................................................................................
Creating a Calendar
To create a calendar, follow the steps below:
1 Open the stndrd20.olb object library. From the Components page,
copy or subclass the Calendar object group.
2 Attach the PL/SQL library calendar.pll, which contains the
Date_LOV package, to your module.
3 Create a Key-Listval trigger on the date item for which you would like to
use the Date List of Values window. Add code to display the calendar
using the Date_LOV package.
4 If you want the end user to be able to close the Date List of Values
window by clicking the WindowClose button in the title bar, create a
form-level When-Window-Closed trigger.
The calendar appears whenever the end user invokes a list of values for the
date item. A single calendar can be reused on many different date items.
Simply create a Key-Listval trigger for each item.
......................................................................................................................................................
Oracle Developer: Build Forms II 15-11
Lesson 15: Using Reusable Components
......................................................................................................................................................
......................................................................................................................................................
15-12 Oracle Developer: Build Forms II
Calendar Object Group Content
......................................................................................................................................................
The Blocks
The calendar object contains two blocks:
• Date_Control_Block: This block contains the buttons that control which
month and year is displayed.
• Date_Button_Block: This block contains the buttons that represent each
day of the month.
The Canvas
The calendar class contains a content canvas named Date_Lov_Canvas. This
canvas contains all the items from both blocks.
The Window
The calendar class contains a window named Date_Lov_Window. This
window is used to display the Date_Lov_Canvas.
......................................................................................................................................................
Oracle Developer: Build Forms II 15-13
Lesson 15: Using Reusable Components
......................................................................................................................................................
• Example
date_lov.get_date(sysdate,’s_ord.date_ordered’,240,
date_lov.get_date(sysdate,’s_ord.date_ordered’,240,
60,’Order
60,’Order Date’,’OK’,’Cancel’,TRUE,FALSE,FALSE);
Date’,’OK’,’Cancel’,TRUE,FALSE,FALSE);
......................................................................................................................................................
15-14 Oracle Developer: Build Forms II
Built-in for Manipulating the Calendar
......................................................................................................................................................
Date_LOV.Get_Date Procedure
This procedure displays the calendar with the month and year specified in
the Display_Date argument. The day of the month is displayed with bold
numbers. The date chosen by the end user is returned to the item specified
by the Return_Item argument.
. . .
PROCEDURE Date_LOV.Get_Date(
display_date DATE, return_item VARCHAR2,
v_x_pos NUMBER := 0, v_y_pos NUMBER := 0,
v_title VARCHAR2 := ’Date List of Values’,
v_ok VARCHAR2 := ’OK’,
v_cancel VARCHAR2 := ’Cancel’, v_highlight BOOLEAN := TRUE,
v_autoconfirm BOOLEAN := TRUE, v_autoskip BOOLEAN := FALSE );. . .
Argument Description
display_date The date to display when the Date List of Values window first appears
return_item The name of the block and item to which to return the chosen date
v_x_pos Specifies the X coordinate of the Date List of Values window
v_y_pos Specifies the Y coordinate of the Date List of Values window
v_title Title to display in the Date List of Values window
v_ok Label for the OK button
v_cancel Label for the Cancel button
v_highlight Specifies that weekend days appear in a different color
v_autoconfirm Specifies that the date immediately be returned when the end user
clicks a day
v_autoskip Specifies that the input focus moves to the next item in sequence
......................................................................................................................................................
Oracle Developer: Build Forms II 15-15
Lesson 15: Using Reusable Components
......................................................................................................................................................
Summary
• Reusable components
• Calendar class:
– Create a calendar class
– Built-in to manipulate the calendar
class
......................................................................................................................................................
15-16 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................
Summary
Reusable Components
• The purpose of a reusable component
• Reusable components list
......................................................................................................................................................
Oracle Developer: Build Forms II 15-17
Lesson 15: Using Reusable Components
......................................................................................................................................................
Practice 15 Overview
......................................................................................................................................................
15-18 Oracle Developer: Build Forms II
Practice Session Overview: Lesson 15
......................................................................................................................................................
Practice Contents
• Create a picklist to display and select the products available.
• Add a calendar on the S_ORD.DATE_ORDERED and
S_ORD.DATE_SHIPPED items.
......................................................................................................................................................
Oracle Developer: Build Forms II 15-19
Lesson 15: Using Reusable Components
......................................................................................................................................................
Practice 15
1 Create a picklist by using the picklist class. This picklist enables the end
user to make selections from two lists, one showing the products
available and the other showing the objects selected.
Note: To reuse the code you wrote in practice 10 question 2, we have
provided most of the code by way of an object library.
a Create a new form module.
b Open the Form_Builder_II.olb object library.
c From the Picklist Basic tab page, drag and copy the
PICKLIST_BASIC object group to the Object Groups node in your
module and release it. Copy the object group, do not subclass the
object group. This object group contains a canvas, a window, and a
block. The block contains two buttons, with the code to return the
products selected in the picklist to the orders form.
d From the Picklist Class tab page, copy the PICKLIST object group
into your new form module. This object group contains all the
objects to implement the picklist. Organize the CONTROL block so
it is the last block in sequence.
e Attach the picklist.pll library to your form.
f Create a When-New-Form-Instance trigger to populate the List_In.
Create an instance of the picklist with the CREATE_PICKLIST
procedure. Populate the List_in, using the
POPULATE_PICKLIST_WITH_QUERY function, with the results
of a query that returns the IDs, names, and suggested prices from the
S_PRODUCT table. (Retrieve the list of products excluding the
products that exists in the S_ITEM block. You should use the global
variable from practice 11.) Select the first element in the list by using
the SET_PICLIST_SELECTION procedure, and display both lists
by using the DISPLAY_PICKLIST procedure. You can import the
pr15_1f.txt file.
g Save your form using the filename PickList.fmb. Compile your
form.
h Open the ORDERS form module.
i Modify the When-Button-Pressed trigger for the
CONTROL.PRODUCT_LOV_BUTTON so that it calls your new
form module. Comment out the old CALL_FORM line, it called an
LOV from an earlier lab.
......................................................................................................................................................
15-20 Oracle Developer: Build Forms II
Practice 15
......................................................................................................................................................
......................................................................................................................................................
Oracle Developer: Build Forms II 15-21
Lesson 15: Using Reusable Components
......................................................................................................................................................
......................................................................................................................................................
15-22 Oracle Developer: Build Forms II