Professional Documents
Culture Documents
44111GC10
Production 1.0
January 1998
M06178
Author Copyright Oracle Corporation, 1998. All rights reserved.
Technical
Restricted Rights Legend
Contributors and
Use, duplication or disclosure by the Government is subject to restrictions for
Reviewers commercial computer software and shall be deemed to be Restricted Rights
software under Federal law, as set forth in subparagraph (c) (1) (ii) of DFARS
Louise Barnfield
252.227-7013, Rights in Technical Data and Computer Software (October 1988).
Gunnar Boehrs
This material or any portion of it may not be copied in any form or by any means
Jacquelyn Bruce without the express prior written permission of the Worldwide Education Services
Phyllis Chan group of Oracle Corporation. Any other copying is a violation of copyright law and
Bulent Cinarkaya may result in civil and/or criminal penalties.
Laurent Dereac If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Right,” as defined in
Mark Doran
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Gillian Elias
The information in this document is subject to change without notice. If you find
Tushar Gadhia any problems in the documentation, please report them in writing to Education
Stephen Gramann Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Nancy Greenberg Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Ursula Hovy
Developer/2000, Oracle Server, and PL/SQL are trademarks or registered
Uwe Jentzsch
trademarks of Oracle Corporation.
Leta A. Johnson
All other products or company names are used for identification purposes only,
Jan Keuben and may be trademarks of their respective owners.
Steve Lirette
Jayne Marlow
Rita Morin
Daphne Nougier
Christin Nowakowski
Bryan Roberts
Bert Salyga
Helene Schwann
Hiroyuki Sugiyama
Pal Tarcsay
Bart Van der Laar
Jack Walsh
Publishers
Stephanie Jones
Kelly Lee
Renee Voss
Contents
...........................................................................................................................................................
Preface
Profile xi
Related Publications xii
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Typographic Conventions xiii
Introduction I-1
Course Objectives I-3
Course Content I-5
Lesson 1: Managing Projects with Project Builder
Introduction 1-3
Introducing Project Builder 1-5
Project Builder Terminology 1-7
Project Builder Benefits 1-9
Project Builder User Interface 1-11
Creating Projects and Subprojects 1-13
Adding Project Files 1-15
Working with Project Files 1-17
Establishing Dependencies 1-19
Building Projects 1-21
Delivering Projects 1-23
Practice Session Overview: Lesson 1-1 1-25
Practice Session: Lesson 1 1-26
Inheritance in Project Builder 1-29
Defining New Types 1-31
Actions 1-33
Modifying Types Using Actions 1-35
Customizing Actions Using Macros 1-37
Customizing the Launcher 1-41
Summary 1-43
Practice Session Overview: Lesson 1-2 1-45
Practice Session: Lesson 1 1-46
Lesson 2: Creating a Menu Module
Introduction 2-3
Components of the Menu Module 2-5
Menu Styles 2-7
The Default Menu 2-9
The Menu Editor 2-11
Creating a Menu Module 2-13
Module Properties 2-15
Menu Properties 2-17
Menu Item Properties 2-19
Menu Item Types 2-21
Menu Item Command Types 2-23
Implementing Menu Toolbars 2-25
......................................................................................................................................................
Developer/2000: Build Forms II iii
Contents
......................................................................................................................................................
Storing the Menu Module 2-27
Attaching the Menu Module 2-29
Pop-Up Menus 2-31
Summary 2-33
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
iv Developer/2000: Build Forms II
Contents
...........................................................................................................................................................
Lesson 6: Controlling Windows and Canvases Programmatically
Introduction 6-3
Using Window-Interaction Triggers 6-5
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Built-ins for Manipulating WINDOWS 6-7
Built-ins for Manipulating Canvases 6-9
Working with Tab-Style Canvases 6-11
Windows and Blocks 6-15
Manipulating Window Properties Programmatically 6-17
Showing Multiple Windows 6-19
Closing Windows 6-21
Using Large Blocks 6-23
Summary 6-25
Practice Session Overview: Lesson 6 6-27
Practice Session: Lesson 6 6-28
Lesson 7: Controlling Data Block Relationships
Introduction 7-3
Creating a Relation 7-5
Modifying a Relation 7-7
Block Coordination 7-11
Characteristics of Relation-Handling Triggers 7-13
Principles of Relation-Handling Code 7-15
Obtaining Relation-Handling Information 7-17
Implementing a Coordination-Type Toggle 7-19
Forcing a Commit Per Master 7-21
Summary 7-23
Practice Session Overview: Lesson 7 7-25
Practice Session: Lesson 7 7-26
Lesson 8: Building Multiple Form Applications
Introduction 8-3
OPEN_FORM to Invoke Additional Forms 8-5
Closing Forms 8-7
Navigating Between Forms 8-9
Transaction Processing for Opened Forms 8-11
CALL_FORM to Invoke Additional Forms 8-13
Transaction Processing for Called Forms 8-15
NEW_FORM to Invoke Additional Forms 8-19
Controlling Open Forms and Called Forms Together 8-21
Different Ways of Invoking Forms 8-23
Using Form Parameters 8-25
Parameter Lists 8-29
Creating and Manipulating Parameter Lists 8-31
Passing Data Between Forms 8-33
Summary 8-35
......................................................................................................................................................
Developer/2000: Build Forms II v
Contents
......................................................................................................................................................
Practice Session Overview: Lesson 8 8-37
Practice Session: Lesson 8 8-38
Lesson 9: Defining Data Sources
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Introduction 9-3
Data Sources Types 9-5
Basing a Data Block on a From Clause Query 9-7
Basing a Data Block on a Stored Procedure 9-9
Example of Query Using a Ref Cursor Procedure 9-11
Example of Query Using a Table of Records Procedure 9-13
Example of DML Using a Stored Procedure 9-15
Deciding Whether to Use a Ref Cursor or a Table of Records 9-17
Data Block Wizard 9-19
Data Block Properties 9-21
Data Source Guidelines 9-23
Summary 9-27
Practice Session Overview: Lesson 9 9-29
Practice Session: Lesson 9 9-30
Lesson 10: Working with Record Groups
Introduction 10-3
Record Groups 10-5
Using Record Groups 10-7
Defining Record Groups at Design Time 10-9
Built-in Functions for Controlling Record Groups 10-11
Defining Query Record Groups Programmatically 10-17
Defining Non-Query Record Groups Programmatically 10-19
Manipulating Record Group Rows 10-21
Manipulating Selected Record Group Rows 10-23
Defining Global Record Groups 10-25
Manipulating List Items Programmatically 10-27
Implementing Dynamic List Items 10-29
Adding Values to Combo Boxes 10-31
Summary 10-33
Practice Session Overview: Lesson 10 10-35
Practice Session: Lesson 10 10-36
Lesson 11: Including Charts and Reports
Introduction 11-3
Including Charts Using the Chart Wizard 11-5
Chart Item Properties 11-11
Reporting Within Form Builder 11-13
Report Object Properties 11-15
Working with Reports 11-17
Summary 11-21
Practice Session Overview: Lesson 11 11-23
......................................................................................................................................................
vi Developer/2000: Build Forms II
Contents
...........................................................................................................................................................
Practice Session: Lesson 11 11-24
Lesson 12: Applying Timers
Introduction 12-3
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Timers 12-5
Handling Timer Expiration 12-7
Creating a Timer 12-9
Modifying a Timer 12-11
Deleting a Timer 12-13
Summary 12-15
Practice Session Overview: Lesson 12 12-17
Practice Session: Lesson 12 12-18
Lesson 13: Using Reusable Components
Introduction 13-3
Reusable Components 13-5
Reusable Components List 13-7
The Calendar Class 13-11
Calendar Object Group Content 13-13
Built-in for Manipulating the Calendar 13-15
Summary 13-17
Practice Session Overview: Lesson 13 13-19
Practice Session: Lesson 13 13-20
Lesson 14: Using Server Features in Form Builder
Introduction 14-3
Using Oracle Server Functionality in Forms 14-5
Dealing with PL/SQL Code 14-7
Handling Errors Raised by the Oracle Server 14-9
Obtaining the Cause of Declarative-Constraint Violations 14-13
Customizing Oracle Server Error Messages 14-15
Example Procedure for Handling Oracle Server Errors 14-17
Performing DDL with FORMS_DDL 14-21
Summary 14-25
Practice Session Overview: Lesson 14 14-27
Practice Session: Lesson 14 14-28
Appendix A: Practice Solutions
Practice 1-1 Solution A-2
Practice 1-2 Solution A-5
Practice 2 Solution A-7
Practice 3 Solution A-13
Practice 4 Solution A-19
Practice 5 Solution A-23
Practice 6 Solution A-26
Practice 7 Solution A-29
......................................................................................................................................................
Developer/2000: Build Forms II vii
Contents
......................................................................................................................................................
Practice 8 Solution A-33
Practice 9 Solution A-35
Practice 10 Solution A-39
Practice 11 Solution A-47
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
viii Developer/2000: Build Forms II
Contents
...........................................................................................................................................................
Displaying Online Help G-15
Summary G-17
Appendix H: Working with ActiveX Controls
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Introduction H-3
What Are VBX, OCX, and ActiveX Controls? H-5
Comparison of VBX, OCX, and ActiveX Controls H-7
ActiveX in Form Builder H-9
Implementing an ActiveX Control H-11
Inserting an ActiveX Control in an ActiveX Control Item H-13
Importing ActiveX Control Methods and Events Packages H-15
Setting and Getting ActiveX Control Properties H-17
Invoking ActiveX Control Methods H-21
Responding to ActiveX Control Events H-23
Handling Exceptions H-25
Registering an ActiveX Control H-27
Summary H-29
Appendix I: Oracle Rdb Overview
What Is Oracle Rdb? I-2
Oracle Rdb Features I-3
Standard User Interfaces I-4
Other Information I-5
......................................................................................................................................................
Developer/2000: Build Forms II ix
Contents
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
x Developer/2000: Build Forms II
................................
Preface
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Preface
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
x Developer/2000: Build Forms II
Preface
......................................................................................................................................................
Profile
Before You Begin This Course
Before you begin this course, you should have:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Thorough knowledge of
- Creating simple applications with Developer/2000 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:
• Developer/2000: Build Forms I
......................................................................................................................................................
Developer/2000: Build Forms II xi
Preface
......................................................................................................................................................
Related Publications
Oracle Publications
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Additional Publications
• read.me file
• relnotes.pdf file
......................................................................................................................................................
xii Developer/2000: Build Forms II
Preface
......................................................................................................................................................
Typographic Conventions
Typographic Conventions Within Text
The following conventions are used in text:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Convention Object or Term Example
Press Cancel.
Quotation marks Lesson module titles This subject is covered in Lesson 3, “Working
referenced within a with Objects.”
course
Italic bold The first time a glos- The algorithm inserts the new key.
sary word is referred
to in a section
......................................................................................................................................................
Developer/2000: Build Forms II xiii
Preface
......................................................................................................................................................
SELECT last_name
FROM s_emp;
......................................................................................................................................................
xiv Developer/2000: Build Forms II
Introduction
................................
I
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Introduction
......................................................................................................................................................
Course Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Course Objectives
......................................................................................................................................................
I-2 Developer/2000: Build Forms II
Course Objectives
......................................................................................................................................................
Course Objectives
This course gives participants an opportunity to broaden their
Developer/2000 form-building skills. Using Project Builder to manage their
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
application files, participants will create multiple-form applications and
learn how to manage multiple transactions across modules. Participants will
also practice enhancing their applications with custom menus, reports, and
charts.
After completing this course, you should be able to do the following:
• Manage and deliver Developer/2000 applications
• Build fully functional menu modules, including security
• Redefine function key behavior
• Include charts and reports in Developer/2000 applications
• Code triggers that respond to:
- Mouse movement and mouse button actions
- Window manipulation
• Create and manage multiple form applications
• Manage transaction
• Choose appropriate data sources for data blocks
......................................................................................................................................................
Developer/2000: Build Forms II I-3
Introduction
......................................................................................................................................................
Course Content
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Day 1
• Managing Projects with Project Builder
• Creating a Menu Module
• Managing Menu Modules
• Programming Function Keys
Course Content
Day 2
• Responding to Mouse Events
• Controlling Windows and Canvases
Programmatically
• Controlling Data Block Relationships
• Building Multiple Form Applications
• Defining Data Sources
......................................................................................................................................................
I-4 Developer/2000: Build Forms II
Course Content
......................................................................................................................................................
Course Content
The lesson titles show topics covered in this course, and the usual sequence
of lessons. However, the daily schedule is an estimate, and may vary for
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
each individual class.
Day 1
• Course Introduction
• Managing Projects with Project Builder
• Creating a Menu Module
• Managing Menu Modules
• Programming Function Keys
Day 2
• Responding to Mouse Events
• Controlling Windows and Canvases Programmatically
• Controlling Data Block Relationships
• Building Multiple Form Applications
• Defining Data Sources
......................................................................................................................................................
Developer/2000: Build Forms II I-5
Introduction
......................................................................................................................................................
Course Content
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Day 3
• Working with Record Groups
• Including Charts and Reports
• Applying Timers
• Using Reusable Components
• Using Server Features in Form Builder
......................................................................................................................................................
I-6 Developer/2000: Build Forms II
Course Content
......................................................................................................................................................
Day 3
• Working with Record Groups
• Including Charts and Reports
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Applying Timers
• Using Reusable Components
• Using Server Features in Form Builder
......................................................................................................................................................
Developer/2000: Build Forms II I-7
Introduction
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
I-8 Developer/2000: Build Forms II
Managing Projects with
Project Builder
................................
1
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
.
Objectives
After completing this lesson, you should
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
1-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
One of the most difficult aspects of application development is managing the
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
files that make up an application. Large applications can consist of literally
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 Developer/2000 Project Builder to help you manage application
development.
Objectives
After completing this lesson, you should be able to do the following:
• List benefits of using Project Builder
• Create projects and subprojects using the Project Wizard
• Add files to a project by using the Add Files dialog box
• Distinguish between implicit and explicit dependencies
• Create an explicit dependency
• Describe the compile options to build a project
• Deliver a project
• Customize the Project Builder environment
......................................................................................................................................................
Developer/2000: Build Forms II 1-3
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-4 Developer/2000: Build Forms II
Introducing Project Builder
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
comprise those projects is inevitably a difficult and time-consuming task. A
typical Developer/2000 project might consist of tens or hundreds or more of
files. These files will be of many different types, for example:
• Forms modules and their corresponding executables
• Reports documents
• Graphics modules
• PL/SQL libraries
• Icons and bitmaps
• DLLs built from C source files
• Text documents such as test scripts and specifications
• Test data
• SQL scripts
The developer faced with these files must constantly ask questions such as:
• What files make up this project?
• How do files depend on each other?
• Which files have been modified and need to be recompiled?
• Which files are to be delivered to the deployment environment?
• What type of file is this, and how do I print, edit, or compile it?
Many developer hours are wasted trying to resolve such issues of
configuration and management. Project Builder brings these tasks under
control as an integral part of the Developer/2000 product.
......................................................................................................................................................
Developer/2000: 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
1-5 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
1-6 Developer/2000: Build Forms II
Project Builder Terminology
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Term Description
Project A project is a collection of pointers to the files that comprise 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 files 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
compile. 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.
......................................................................................................................................................
Developer/2000: Build Forms II 1-7
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-8 Developer/2000: Build Forms II
Project Builder Benefits
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Viewing All Files Associated with an Application in a Common Navigator
You can associate all of the files comprising your application simply by
adding them to the same project. You can then view a graphical presentation
of the project in a familiar “navigation” style.
This allows you to track a large application as a single entity and to
determine the dependencies between modules.
Automating Actions
Project Builder allows you to perform common actions such as Edit, Print,
Compile on files from directly within the Project Navigator. Project Builder
ships with default actions which can be modified and customized.
......................................................................................................................................................
Developer/2000: Build Forms II 1-9
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-10 Developer/2000: Build Forms II
Project Builder User Interface
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
The Project Navigator
The Project Navigator is the main window for managing and organizing the
entries in a project. It can be displayed in one or two views.
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, you need to edit your
project file.
......................................................................................................................................................
Developer/2000: Build Forms II 1-11
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-12 Developer/2000: Build Forms II
Creating Projects and Subprojects
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Your first job in creating a project is to define the project registry file.
......................................................................................................................................................
Developer/2000: Build Forms II 1-13
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-14 Developer/2000: Build Forms II
Adding Project Files
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Project Wizard (the default), or create an empty project. When you select
Finish, the Project Wizard creates your new project.
......................................................................................................................................................
Developer/2000: Build Forms II 1-15
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-16 Developer/2000: Build Forms II
Working with Project Files
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Create and assign a connect string to a project or project entries
• Add, modify, or remove files and types
• Add dependencies manually
• Edit file properties, or define actions for types, or override the actions as
a single file has inherited from its type
• Compile the project and package it for delivery
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.
......................................................................................................................................................
Developer/2000: Build Forms II 1-17
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Implicit Dependencies
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
1-18 Developer/2000: 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
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Form Builder document 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, the type of file that is built for
delivery to end users.
• The Build From <type> action specifies the command used to compile a
file of a given type.
Example
The type Form Builder document (.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 cannot be determined
automatically by Project Builder. 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, it will be necessary to rebuild the Form Builder
excutable (.fmx).
To allow the developer to include such dependencies in the project
definition, dependencies can be added manually. To indicate that a .Fmx
depends on a PL/SQL library:
1 Select the entry (.fmx file).
2 Select Project––>Add Files to Project from the menu.
3 Select the file(s) 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.
......................................................................................................................................................
Developer/2000: Build Forms II 1-19
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Building Projects
Three compile options:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
1 3
1 Compile All
2 Compile Incremental
3 Compile Selection
......................................................................................................................................................
1-20 Developer/2000: Build Forms II
Building Projects
......................................................................................................................................................
Building Projects
Project Builder easily enables you to ensure that the “build” is up-to-date;
that everything needing to be rebuilt, has indeed been rebuilt.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
You can update your project and build all dependencies by using one of
three compile options in the Project Builder Project menu:
......................................................................................................................................................
Developer/2000: Build Forms II 1-21
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-22 Developer/2000: Build Forms II
Delivering Projects
......................................................................................................................................................
Delivering Projects
Once a project is completed, the remaining task is to deliver the executable
files, help files, supporting media (such as sounds, images, videos, or icons),
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
and any other files that the end user will need to have installed. Typically, the
delivery process involves creating an archive or “stage” of the required files.
......................................................................................................................................................
Developer/2000: Build Forms II 1-23
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-24 Developer/2000: Build Forms II
Practice Session Overview: Lesson 1-1
......................................................................................................................................................
Practice Contents
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Create an initial project.
• Experiment with the different Project Navigator views.
• Create subprojects and add items to them.
......................................................................................................................................................
Developer/2000: Build Forms II 1-25
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-26 Developer/2000: Build Forms II
Practice Session: Lesson 1
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
PACKFILE macro.
c Select the Summit Application subproject, and define the “Deliver
the selected files(s)” action.
d Deliver the project.
If you have time:
6 Create a subproject and files to it.
a Using the Project Wizard, create a subproject named “Practice
Solutions” that belongs to Developer/2000: Build Forms II.
b From the labs directory, add the custwkNN.fmb, ordwkNN.fmb, and
empwkNN.fmb files.
c Set the “Deliver File” property to No for those files.
......................................................................................................................................................
Developer/2000: Build Forms II 1-27
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Technical Note
In Windows 95 and NT, actions defined in the registry for a particular file
type, such as Open, Edit, and Print, are automatically available in Project
Builder using a special notation. For example, [open {name}] means do
whatever Windows 95 defines as the Open action for this filename.
......................................................................................................................................................
1-28 Developer/2000: Build Forms II
Inheritance in Project Builder
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
also whether they are inherited or overridden. An entry inherits properties,
actions, and macros both from its type and from its project.
• An entry inherits from its type the properties, actions, and macros
associated with that type.
These include properties such as whether the file is text or binary and the
actions to edit or compile an entry of that type.
• An entry also inherits properties, actions, and macros from the project.
Properties inherited from the project include the author of an entry. If
actions or macros are added to the project, they are inherited by all
entries in the project.
Note: Some properties, actions and macros can be inherited from both
the project and the type. In this case, setting the value at the project level
overrides the value set at the type level.
Generic Types
Each type description applies to a single file type, with the exception of three
Project Builder-defined types that provide generic definitions for text files
(Text File), the files in which project information is stored
(Project type), and links to files within projects (Project Link type).
To view these type definitions, go to the Global Registry in the Project
Navigator, select one of the types, and either choose Edit Type or Property
Palette from the pop-up menu.
Two generic types allow a property (such as Version Control File) or an
action (such as Edit) to be easily set across types without having to define it
individually for each type.
Type Description
<Any File> Properties, actions, and macros are inherited by every type and
therefore every entry.
<Text File> Properties, actions, and macros are inherited by every type whose
File Contents property is set to Text rather than Binary.
......................................................................................................................................................
Developer/2000: Build Forms II 1-29
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-30 Developer/2000: Build Forms II
Defining New Types
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Property Description
Type Name of the type.
Format The format for the type can be any literal string, or combination of a
literal string and one of the following built-in macros: b, d, f, or n (for
example, {b}.txt for a text file). Project Builder uses this information
to determine the types of the files you add to your project, and what,
if any, implied items will result.
File contents are Define the format for files of this type. Binary files added to your
project will inherit actions and macros from the global type Any
Type. Text files added to your project will inherit actions and macros
from the global type Text.
Description (Optional) A description of the type. The description, if you specify
it, will furnish a label for the type in the Project
Navigator.
Deliver As Specify the deliverable type.
Version-controlled Specify if the type is subject to version control.
Deliverable Specify if the type is to be included when packaging the project for
delivery as an application.
Derive type Ask Project Builder to deduce information from an example file you
information from provide.
file
Icon Choose an icon from the list provided, or select the From File check
box and choose Browse to display a file selection dialog.
......................................................................................................................................................
Developer/2000: Build Forms II 1-31
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Actions
The three types of actions are:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Predefined
– Shipped with Project Builder
• User-defined
– Custom actions, defined by the
developer
• Global
– Included with Project Builder
– Implemented across projects and files
Technical Note
The command strings for predefined actions are platform-dependent and are
either based on tools commonly available on the platforms, or take
advantage of commands already registered by the operating system for the
different types.
If your platform already recognizes commands associated with file types,
you can take advantage of these in your actions.
For example, if you want to create a Play action for video files on Windows
and the Windows Explorer has already associated a command with video
files, you can use the Windows command by enclosing it in brackets in your
action definition; for example, [play {n}], where {n} is the built-in macro
that evaluates to the name of the item you selected in the Project Navigator.
......................................................................................................................................................
1-32 Developer/2000: Build Forms II
Actions
......................................................................................................................................................
Actions
Project Builder has three types of actions:
• Predefined actions
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• User-defined actions
• Global actions
Predefined Actions
Predefined actions are shipped with Project Builder and are automatically
available via either menu items or tools on the toolbar.
Predefined actions vary from file type to file type. To determine which
predefined actions are available for a specific type:
1 Select that type in the Project Navigator.
2 Display the Property Palette.
3 View the entries under the Actions node.
Note: Predefined actions are completely customizable.
User-Defined Actions
User-defined actions are custom actions and you define them explicitly.
Global Actions
Global actions are included with Project Builder and work across projects
and files, adapting themselves to varied file types. The global actions are a
subset of the pre-defined actions, and include the following:
• Build actions (Compile Selection, Compile Incremental, Compile All)
• Packaging action (Deliver)
• Source control (Check In, Check Out, Get RCS Information, Lock File
in RCS)
......................................................................................................................................................
Developer/2000: Build Forms II 1-33
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
• Actions can be
defined for a type,
project, or
components through
the Property Palette.
• Action definitions
often use macros.
Technical Note
If you add an action to a type in the user registry, all objects of that type that
reference the user registry inherit the new action. If you add an action to an
object, the action only applies to that object, unless that object is a project or
subproject. Then the action applies to the child objects of the project if the
action affects the type of the child objects.
......................................................................................................................................................
1-34 Developer/2000: Build Forms II
Modifying Types Using Actions
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
2 From the pop-up menu, select New Action to display the Add Action
dialog box.
3 Specify the following properties in the Add Action dialog box.
Property Description
Name Name for the action.
Description Description of the action. If you add this action to the pop-up menu, the
description furnishes the menu item. If you choose not to enter a description,
the name of the action will appear in the pop-up menu instead. If you want to
use keyboard mnemonics, mark the key you want to use by placing an amper-
sand (&) in front of it; for example if you specify &Print as the description,
the P will furnish the mnemonic. If you want to include a non-mnemonic
ampersand in the command, use two ampersands (&&).
Pop-up Select the “Add to pop-up menu” check box if you want to include the action
menu in the pop-up menu associated with the type or object. If you choose not to
include the action in the pop-up menu, it will be inaccessible; you can hide
actions in this fashion without deleting them.
Select the Default check box if you want to make the action the default
(invoked by double-clicking).
Definition Specify the command string issued to invoke the action.
Insert Specify the application you want to use to perform the action from
Application the resulting Select an Application dialog box.
Insert Specify a macro that it will be expanded when the action is invoked.
Macro
Insert Input Insert Input Item is only available for global actions (Build, Deliver, or the
Item source control actions) and will remain grayed out for other types of actions.
However, if you are adding an action to overwrite one of the global actions,
Insert Input Item will become active and you can click it to select the type of
input item required (for example, .fmb, or files of the type Forms Document,
are required to build .fmx files). The input item you select will either replace
any selected text in the Action Definition text box, or be inserted at the cursor
position.
......................................................................................................................................................
Developer/2000: Build Forms II 1-35
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Simple macros
• myprinter = “ HPLASER_01”
Built-in macros
• n = Full filename
Predefined macros
• D2KEDITOR = {EDITOR ? {EDITOR} :
notepad}
......................................................................................................................................................
1-36 Developer/2000: Build Forms II
Customizing Actions Using Macros
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
choose from, or you can create your own.
Simple Macros
Simple macros are macros which equate to simple strings. When you
reference such a macro from an action or another macro, the macro will be
replaced by that string. If you want to reference a simple macro, insert the
macro name, enclosed by braces, within the action or macro at the point in
the command where such a string would be executed.
Built-in Macros
Built-in macros are macros provided by Project Builder for use with actions.
These macros have one character name and you cannot redefine the value.
Note: To have a complete list of the built-in macros, see the Project Builder
online Help.
Predefined Macros
These macros are customizable macros that are provided by Project Builder
and assigned preliminary values.
The values assigned to pre-defined macros are preliminary and easily
customized to suit your preferences. Possible values depend on the tools
available on your platform.
Example
For Windows platforms, the macro D2KEDITOR is defined as {EDITOR ?
{EDITOR} : notepad}, which means that your default editor will be
Notepad unless you define a macro named EDITOR and equate it to another
word processing program available in Windows.
In Motif, D2KEDITOR is defined as {EDITOR ? {EDITOR} : vi}, which
means that your default editor will be vi unless you define a macro named
EDITOR and equate it to another word processing program available in
Motif.
......................................................................................................................................................
Developer/2000: Build Forms II 1-37
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Macros can:
• Be defined for each
object through the
Property Palette
• Be conditional
• Reference other macros
......................................................................................................................................................
1-38 Developer/2000: Build Forms II
Customizing Actions Using Macros
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
comprising an action or another macro definition.
Note: Placement of the macro reference is dictated by its value and how
that relates to the command you are modifying. In other words, put the
macro where you would normally enter the string to which the macro is
equated.
Conditionalizing Macros
You can set the value of a macro depending on a condition. To do so, use the
following expression:
{macroname?expression1:expression2}
{EDITOR ? {EDITOR} : vi}
Label Description
macroname The name of the macro
expression1 The expression to which the macro is evaluated if the macro has been
defined and has an assigned value
expression2 The expression to which the macro is evaluated if the macro has either not
(Optional) been previously defined, or has been defined but has no assigned value
Nesting Macros
You can nest a macro within another macro by inserting its name, enclosed
by braces, in the string to which the outer macro is equated.
The innermost macros will be expanded first, followed by the next level, and
then the next, until the action containing the nested macros is evaluated and
executed.
In addition, macros are recursively expanded. For example, if the value of a
macro named bar is set to the already-defined macro {foo}, when bar is
referenced from within an action or another macro, the value substituted for
it will be the value of foo.
......................................................................................................................................................
Developer/2000: Build Forms II 1-39
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-40 Developer/2000: Build Forms II
Customizing the Launcher
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
tools.
......................................................................................................................................................
Developer/2000: Build Forms II 1-41
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
1-42 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
Project Builder Basics
• Identify Project Builder uses
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Define Project Builder terminology
• Describe Project Navigator features
Building a Project
• Create projects and subprojects
• Work with project components
• Make and deliver projects
......................................................................................................................................................
Developer/2000: Build Forms II 1-43
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
......................................................................................................................................................
1-44 Developer/2000: Build Forms II
Practice Session Overview: Lesson 1-2
......................................................................................................................................................
Practice Contents
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Create new types and actions.
• Enable Project Builder to act upon .sql files.
• Customize the Launcher.
......................................................................................................................................................
Developer/2000: Build Forms II 1-45
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................
bSelect the Setup1.sql file, and initiate the action “Run Script”.
If you have time...
3 Customize the Launcher.
a Add the Notepad application to the Launcher. Use the Notepad editor
as the launch string (command). Label it Notepad. Add an icon by
typing Notepad editor string in the Icon Field.
b Change the orientation of the Launcher from horizontal to vertical
(or from vertical to horizontal, depending on the default orientation).
c Rename the Notepad shortcut icon to “Notes”.
......................................................................................................................................................
1-46 Developer/2000: Build Forms II
Creating a Menu Module
................................
2
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Objectives
After completing this lesson, you should
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
2-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
By default, each form module uses the same menu, the Default menu. This
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 using the Property Palette
• Create menu toolbars
• Create Pop-Up menus
......................................................................................................................................................
Developer/2000: Build Forms II 2-3
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Main
Individual menu Menu toolbar
menu
2-3 Copyright Oracle Corporation, 1998. All rights reserved.
Menu
Module
Menu
Submenu
items
Menu
items
2-4 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
2-4 Developer/2000: Build Forms II
Components of the Menu Module
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
and easy method for operating your Forms application. Like the form
module, the menu module is one of the main components of an application.
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
......................................................................................................................................................
Developer/2000: Build Forms II 2-5
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Menu Styles
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Pull-Down
• Displays the main menu horizontally
under the application window title
• Displays submenus vertically beneath
the main menu
• Default menu style
Menu Styles
Full-Screen
• Displays each menu in a separate
window
• Often used in character-mode
applications
Bar
• Displays the main menu horizontally
under the application window title
• Displays submenus horizontally
......................................................................................................................................................
2-6 Developer/2000: Build Forms II
Menu Styles
......................................................................................................................................................
Menu Styles
You can run a custom menu module using different display styles. However,
not all menu features are available in every display style. When you create
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
the menu, consider the features you want to include and make sure that the
style includes those features.
Technical Note
Bar and full-screen menus are supported for backward compatibility only
and for compatibility with character mode.
......................................................................................................................................................
Developer/2000: Build Forms II 2-7
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Default Menu
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
2-8 Developer/2000: Build Forms II
The Default Menu
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
form module. The Default menu includes standard commands for editing,
navigating, and database interaction, such as Action—>Save.
When you build a form module, it automatically uses the Default menu and
you cannot change the Default menu; however, you can replace this by
building your own custom menu module.
......................................................................................................................................................
Developer/2000: Build Forms II 2-9
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.
......................................................................................................................................................
2-10 Developer/2000: Build Forms II
The Menu Editor
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
viewing menu modules and their objects. Use the Menu Editor to carry out
all of your menu design work.
Tool Use
Display Determines the menu for which you want to display menu items. (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
......................................................................................................................................................
Developer/2000: Build Forms II 2-11
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-12 Developer/2000: Build Forms II
Creating a Menu Module
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
and menu items in the Menu Editor. When the Menu Editor is displayed, it
shows a menu called MAIN_MENU, with one item labeled New Item.
Creating a Submenu
1 Select the parent item on the individual menu.
2 Select the Create Right icon.
3 Replace the default label.
4 Choose 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.
......................................................................................................................................................
Developer/2000: Build Forms II 2-13
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Main Menu
Menu Directory
Menu Filename
Startup Code
Share Library with Form
Use Security
Module Roles
2-10 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
2-14 Developer/2000: Build Forms II
Module Properties
......................................................................................................................................................
Module Properties
Property Description
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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. This property is used mostly with
full-screen menus to limit the menus to which users have access
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 allows to load in memory a single copy of a PL/SQL
with Form 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; when set to
No tests a menu without your belonging to the security role assigned to
the module
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.)
......................................................................................................................................................
Developer/2000: Build Forms II 2-15
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Menu Properties
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Title
Sub-title
Bottom Title
Tear-Off
......................................................................................................................................................
2-16 Developer/2000: Build Forms II
Menu Properties
......................................................................................................................................................
Menu Properties
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Property Description
Title Specifies up to 40 characters to appear as a top title for the menu
(Forms uses the menu name if you leave this property blank. Use for
full-screen and bar menus only.)
Sub-title Specifies up to 40 characters to be displayed below the title in a full-
screen menu
Bottom Title Specifies up to 72 characters to be displayed at the bottom of a full-
screen menu
Tear-Off Menu Enables the menu to be dragged from the menu bar and repositioned
elsewhere on the screen (Only available if your window manager sup-
ports this feature.)
......................................................................................................................................................
Developer/2000: Build Forms II 2-17
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Technical Note
You must display Radio menu items that belong to the same Radio group
contiguously on the same menu. Radio group names are internal names that
are not displayed at run time.
......................................................................................................................................................
2-18 Developer/2000: Build Forms II
Menu Item Properties
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Menu Item Properties Use
Enabled Specifies if the menu item is an active menu item or mouse
manipulable
Label Specifies the text that appears in the menu item
Menu Item Type Determines how this menu item displays (Choose from
Plain, Check, Radio, Separator, and Magic.)
Magic Item Specifies that one of the predefined menu items for custom
menus should be used
Menu Item Radio Group Determines which radio group this menu item belongs to
Command Type Determines the type of command that this menu item calls
(Choose from Null, Menu, PL/SQL, or SQL*Plus.)
Menu Item Code Specifies the command that this menu item invokes
Submenu Name Specifies the menu that this menu item invokes
Keyboard Accelerator Determines which logical function key is associated with
this menu item (Accelerator keys are named
ACCELERATOR1 through ACCELERATOR5.)
Icon in Menu Specifies if an icon is displayed in the menu item
Icon Name Specifies the name of the icon to display
Help Description The property that invokes the Help Editor, in which you can
write full-screen, context-sensitive Help text
......................................................................................................................................................
Developer/2000: Build Forms II 2-19
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Plain
Check
Radio
Magic
Separator
Magic Items
• About • Paste
• Undo • Help
• Clear • Quit
• Copy • Window
• Cut
......................................................................................................................................................
2-20 Developer/2000: Build Forms II
Menu Item Types
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Choosing a Menu Item Type
Menu Item Type Use
Plain Creates a standard text menu item. This is the Default menu item type.
Check Creates a menu item that has two possible states. Check menu item
functionality is defined using PL/SQL.
Radio Creates a set of mutually exclusive buttons each representing a different
action. To assign a Radio item to a group, enter the name of the group
in the Menu Item Radio Group field in the Properties window.
Separator Creates a separating horizontal line for grouping menu items.
Magic Creates a menu item with predefined functionality.
Magic Items
Some Magic menu items include default functionality. Because a Magic item
provides a standard action 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.
......................................................................................................................................................
Developer/2000: Build Forms II 2-21
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-22 Developer/2000: Build Forms II
Menu Item Command Types
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
a menu item is composed of submenus, the command type must be set to
Menu (for example, all items on the Main menu must have the command
type set to Menu.). In that case, the Menu Item Code property is replaced by
the Submenu Name property.
Note: The command types of Form and Macro are available for
compatibility with SQL*Menu V4.0. and SQL*Menu V.5.0.
......................................................................................................................................................
Developer/2000: Build Forms II 2-23
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Technical Note
For more flexible or complex requirements, use the existing Toolbar canvas
in form modules.
......................................................................................................................................................
2-24 Developer/2000: Build Forms II
Implementing Menu Toolbars
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
items appear on a menu toolbar (a toolbar of iconified buttons that represent
individual items from your form menu).
You need to provide icons to represent the associated buttons on the menu
toolbar; if you use the default form menu, Form Builder attaches a default
menu toolbar to your form automatically.
Menu toolbars allow developer to easily provide toolbar shortcuts to menu
commands without duplicating code or effort.
Property Description
Visible in Horizontal Specifies the menu item should appear (represented by an icon) on
Menu Toolbar the horizontal toolbar of a form
Visible in Vertical Specifies the menu item should appear (represented by an icon) on
Menu Toolbar the vertical toolbar of a form
Icon Filename Specifies the name of the icon resource that you want to represent
the iconic button
......................................................................................................................................................
Developer/2000: Build Forms II 2-25
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-26 Developer/2000: Build Forms II
Storing the Menu Module
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
either of the following storage formats.
Storage Format Description
Database tables Representation within rows and columns that is portable between
databases
File with .mmb Menu module binary file, a binary representation that is portable
extension between operating systems
You can save your menu module definition by either of the following
actions:
• Click the Save icon in the Object Navigator
• Select File—>Save
......................................................................................................................................................
Developer/2000: Build Forms II 2-27
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-28 Developer/2000: Build Forms II
Attaching the Menu Module
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
effectively replacing the Default menu with your own.
......................................................................................................................................................
Developer/2000: Build Forms II 2-29
Lesson 2: Creating a Menu Module
......................................................................................................................................................
......................................................................................................................................................
2-30 Developer/2000: Build Forms II
Pop-Up Menus
......................................................................................................................................................
Pop-Up Menus
Pop-up menus are context-sensitive menus and are invoked when you press
the right mouse button. They are attached to a form's items and canvases.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
They allow 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.
......................................................................................................................................................
Developer/2000: Build Forms II 2-31
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
2-32 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
In this lesson, you learned how to add, create, and customize menu modules.
• The menu module components:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
- Main menu
- Menu
- Menu item
- Menu Toolbar
• The Default menu:
- Automatically used with every form module
- Can be customized
• Creating a menu module
• Properties:
- Menu module properties
- Menu properties
- Menu Item properties
• Implementing a Menu Toolbar
• Menu module storage:
- Database tables
- .mmb file extension
- .mmx file extension
- .mmt file extension
• Menu module and form module association:
- Using the form module properties of Menu Module and Menu
Source
• Creating a pop-up menu:
- Incorporate pop-up menus
- Rules to incorporate pop-up menus
- Pre-Popup-Menu trigger
......................................................................................................................................................
Developer/2000: Build Forms II 2-33
Lesson 2: Creating a Menu Module
......................................................................................................................................................
Practice 2 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
2-34 Developer/2000: Build Forms II
Practice Session Overview: Lesson 2
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Practice Contents
• Create a new menu for the ORDERS form using the screenshot to guide
you
• Compile and attach the menu to the ORDERS form
• Modify the menu for incorporate some menu items into a menu toolbar
• Add pop-up menus to the ORDERS form
......................................................................................................................................................
Developer/2000: Build Forms II 2-35
Lesson 2: Creating a Menu Module
......................................................................................................................................................
• File Menu:
Visible in
Menu Command Visible Horiz. Menu Icon
Label Item Type Type Menu Item Code in Menu Toolbar Filename
Save Plain PL/SQL DO_KEY(’COMMI Yes Yes save
T_FORM’);
Clear Plain PL/SQL DO_KEY(’ Yes Yes abort
CLEAR_FORM’);
Null Separator Null Yes Yes
Exit Plain PL/SQL DO_KEY( Yes Yes exit
’EXIT_FORM’);
Null Separator Null No Yes
......................................................................................................................................................
2-36 Developer/2000: Build Forms II
Practice Session: Lesson 2
......................................................................................................................................................
• Edit Menu:
Visible in
Menu Magic Command Visible Horiz. Menu Icon
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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
Null Separator Null No Yes
• Sort By Menu:
- For each of the items, set the Menu Item Radio Group property to
Order_By.
Menu
Menu Label Item Type Command Type Menu Item Code
Id Radio PL/SQL SET_BLOCK_PROPERTY(
’s_ord’, order_by, ’id’
) ;
Customer Id Radio PL/SQL SET_BLOCK_PROPERTY(
’s_ord’, order_by,
’customer_id’ ) ;
Sales Rep Id Radio PL/SQL SET_BLOCK_PROPERTY(
’s_ord’, order_by,
’sales_rep_id’ ) ;
......................................................................................................................................................
Developer/2000: Build Forms II 2-37
Lesson 2: Creating a Menu Module
......................................................................................................................................................
• Query Menu:
Visible in
Menu Command Horiz. Menu Icon
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
2-38 Developer/2000: Build Forms II
Managing Menu Modules
................................
3
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
3-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn how to modify menus dynamically, as well as
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 using menu built-ins
• Customize menu modules using substitution parameters
• Implement menu security using both database roles and the appropriate
built-ins
......................................................................................................................................................
Developer/2000: Build Forms II 3-3
Lesson 3: Managing Menu Modules
......................................................................................................................................................
......................................................................................................................................................
3-4 Developer/2000: Build Forms II
Using PL/SQL in Menu Item Code
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
addition to standard application functions such as navigation, validation, and
database interaction, you can use PL/SQL menu item commands to perform
any actions.
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
......................................................................................................................................................
Developer/2000: Build Forms II 3-5
Lesson 3: Managing Menu Modules
......................................................................................................................................................
• FIND_MENU_ITEM
• GET_MENU_ITEM_PROPERTY
• SET_MENU_ITEM_PROPERTY
• ITEM_ENABLED
• MENU_SHOW_KEYS
......................................................................................................................................................
3-6 Developer/2000: Build Forms II
Useful Built-in Menu Subprograms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Using some of these subprograms, you can get or change menu item
properties. Using others, you can hide, display, or replace the current menu.
Example
This procedure find 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;
......................................................................................................................................................
Developer/2000: Build Forms II 3-7
Lesson 3: Managing Menu Modules
......................................................................................................................................................
REPLACE_MENU
Character mode built-ins
• HIDE_MENU
• SHOW_MENU
• MENU_REDISPLAY
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 Developer/2000: Build Forms II
Showing and Hiding the Current Menu
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
without making it active. Using this procedure, you can
modify the display style and security.
HIDE_MENU Procedure hiding the current menu. Use only in character
mode.
SHOW_MENU Displays the current menu without activating it. Used only in
character-mode environments.
MENU_REDISPLAY Redraws the current menu on the screen. Used only in
character, or block-mode environments.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 3-9
Lesson 3: Managing Menu Modules
......................................................................................................................................................
UN Current username
PW Current password
AD Directory name
TT Terminal type
LN Language used
User-Named Substitution
Parameters
......................................................................................................................................................
3-10 Developer/2000: Build Forms II
Substitution Parameters
......................................................................................................................................................
Substitution Parameters
What Is a Substitution Parameter?
A substitution parameter is a two-character variable of type CHAR that is
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
referenced in a menu item command or in a PL/SQL program unit, and
substituted with a value at run time. A menu module provides some
predefined parameters, which automatically exist in every menu module.
You can also create in the Forms Builder (valid for a given menu module)
your own user-named parameters.
......................................................................................................................................................
Developer/2000: Build Forms II 3-11
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Parameter Properties
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
- Name
- Label - Maximum Length
- Case Restriction - Menu Parameter
- Conceal Data Initial Value
- Associated Menus - Required
- Hint
......................................................................................................................................................
3-12 Developer/2000: Build Forms II
Defining a User-Named Substitution Parameter
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Navigator:
1 Select the Parameters node.
2 Create a new parameter, by clicking the Create icon.
Forms displays a new parameter.
3 Set the desired properties for the parameter.
Property Description
Name The two-letter parameter name
Label The text prompt for the parameter value that is displayed in
the Enter Parameter Values dialog box
Case Restriction The property that converts the case of the user’s input to
either Uppercase, Lowercase, or None
Conceal Data The property determines whether the user’s input is echoed to
the screen
Associated Menus All menu names where the parameter can be used (full-screen
menus only)
Maximum Length Value maximum length
Menu Parameter Initial Value The default value for the parameter; displayed in the parame-
ter value field when the Enter Parameter Values dialog box is
displayed
Required Mandatory or not; set Yes if the value is required or set No to
allow the parameter value to be set to Null
Hint The text string displayed on the message line of the console
......................................................................................................................................................
Developer/2000: Build Forms II 3-13
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Substitution Parameter
Built-ins
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• QUERY_PARAMETER
• APPLICATION_PARAMETER
......................................................................................................................................................
3-14 Developer/2000: Build Forms II
Substitution Parameter Built-ins
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Built-in Description
QUERY_PARAMETER Displays the Query Parameter dialog box showing the
current values of the specified substitution parameters.
End users can set the value of any parameter you include
in the list
APPLICATION_PARAMETER Displays all the parameters associated with the current
menu, and their current values, in the Enter Parameter
Values dialog box
Example
This example invokes SQL*Plus and runs a command file (CF parameter).
Example
This example invokes Report Builder and enables the user to provide the
report name.
Query_Parameter(’&RN’);
Run_Product(reports, :RN, synchronous, runtime, filesystem,
pl_id, null);
......................................................................................................................................................
Developer/2000: Build Forms II 3-15
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Validating Substitution
Parameter Values
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
MENU_SUCCESS function:
• Returns TRUE if the user does not
cancel the Enter Parameter Values
dialog box
• Used in a WHILE loop
......................................................................................................................................................
3-16 Developer/2000: Build Forms II
Validating a Substitution Parameter Value
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
MENU_SUCCESS function status.
DECLARE
Status BOOLEAN:= TRUE;
BEGIN
WHILE Status
LOOP
QUERY_PARAMETER(’&p1’);
IF MENU_SUCCESS
THEN
IF TO_NUMBER(:p1) not between 100 and 5000
THEN
MESSAGE(’Qty must be in the range 100..5000’);
BELL;
ELSE
Status := FALSE;
END IF;
END IF;
END LOOP;
END;
......................................................................................................................................................
Developer/2000: Build Forms II 3-17
Lesson 3: Managing Menu Modules
......................................................................................................................................................
What Is a Role?
Users
Role
Privileges
3-14 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
3-18 Developer/2000: Build Forms II
Managing Menu Security
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
choose between two security policies for the users:
• Grant users access to all menu items in a module
• Grant users access only to specific menu items
When you want to deny a user access to a menu item, you can either hide the
item, or disable it.
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 only granted 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.
......................................................................................................................................................
Developer/2000: Build Forms II 3-19
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Technical Note
If Use Security is modified, you must recompile the menu module.
......................................................................................................................................................
3-20 Developer/2000: Build Forms II
Defining Security Roles
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
the Oracle Server, using SQL statements.
The following SQL commands implement roles.
Command Action
CREATE ROLE Creates a new role.
GRANT Assigns the role to a user. This command allows you
to give a set of privileges to a user at one time.
ALTER USER...DEFAULT ROLE Controls which role is assigned by default to users
when they connect to the database.
......................................................................................................................................................
Developer/2000: Build Forms II 3-21
Lesson 3: Managing Menu Modules
......................................................................................................................................................
......................................................................................................................................................
3-22 Developer/2000: Build Forms II
Assigning Access to Menu Items
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
1 Select the desired menu item in the Menu Editor or in the Object
Navigator.
2 Select the Item Roles property in the Properties window.
3 Click More... in the Menu Item Roles dialog box. This dialog box
contains the role names associated with the menu module.
4 Select the role in the list to assign a role to the selected menu item.
5 Set the Display without Privilege property to specify how Forms should
display the item if the current user does not have access to the item.
If set to Yes, the item is displayed disabled.
If set to No, the item is hidden completely.
Note: Roles assigned to an item are highlighted. All others are displayed as
usual. To assign the same roles to many items, select the items first by
“Shift-clicking” or “Control-clicking” in the Menu Editor or Object
Navigator, then select the roles through the Menu Item Roles property.
Note: For additional information on how to manipulate Oracle Server roles
at runtime, see Appendix E.
......................................................................................................................................................
Developer/2000: Build Forms II 3-23
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
3-24 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
PL/SQL in Menu Item Commands
• Typical PL/SQL uses
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Restrictions for PL/SQL in menu item commands
Substitution Parameters
• Using &UN, &PW, &AD, &SO, &TT, and &LN
• Creating user-named substitution parameters
• Programmatically controlling substitution parameters with
QUERY_PARAMETER and APPLICATION_PARAMETER
......................................................................................................................................................
Developer/2000: Build Forms II 3-25
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Practice 3 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
3-26 Developer/2000: Build Forms II
Practice Session Overview: Lesson 3
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Practice Contents
• Modify the menu for use with the EMPLOYEE form by creating a new
menu item to display Sales Representative information based on the
current SALES_REP_ID.
• 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.
......................................................................................................................................................
Developer/2000: Build Forms II 3-27
Lesson 3: Managing Menu Modules
......................................................................................................................................................
Import the text for the Image Activate menu item using the
c
pr3_1c.txt file. The menu item name must be IMAGE_ACTIVATE.
d Save and compile the menu module.
e Run the CUSTOMERS form and press the Orders button.
2 Defining a User-Named Substitution Parameter.
a Create a user-named substitution parameter called AA in your
M_SUMMIT menu module.
b Import the pr3_2b.txt file into a procedure called
SALES_REP_INFORMATION. This procedure checks if the sales
rep id item is empty. In this case, it uses the user-named substitution
parameter to prompt the user for a sales rep id. Then, the procedure
opens the EMPLOYEES form and passes the information by way of
a global variable.
c Create a new menu item to the right of the Image menu and use it to
call the SALES_REP_INFORMATION procedure.
Menu
Menu Label Item Type Command Type Menu Item Code
Sales Rep Plain PL/SQL sales_rep_information;
......................................................................................................................................................
3-28 Developer/2000: Build Forms II
Practice Session: Lesson 3
......................................................................................................................................................
gRun the CUSTOMERS form, calling the ORDERS form and test the
Sales Rep menu item.
If you have time...
3 Write startup code to enhance the functions.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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_3a1.txt file.
Modify the When-Button-Pressed trigger on the image button in the
control block of the ORDERS form to obtain the same result. You
can import the pr3_3a2.txt file. The other code needs to be deleted
before importing.
Save and compile your module.
4 Run the CUSTOMERS form and test the application.
The menu items Sort, Image Activate, and Sales Rep Information are not
relevant to the EMPLOYEES form and therefore should have no effect.
a Modify the Startup Code of the M_SUMMIT menu module to
disable these options when the EMPLOYEES form is opened. You
can import the pr3_4a.txt file, which contains the necessary code.
b Save and compile the module.
c Run the CUSTOMERS form and test your application.
......................................................................................................................................................
Developer/2000: Build Forms II 3-29
Lesson 3: Managing Menu Modules
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
3-30 Developer/2000: Build Forms II
Programming Function
................................
4
Keys
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 4: Programming Function Keys
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
4-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
The Developer/2000 Form Builder components allow you to redefine the
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
actions of function keys. This lesson shows you how to define Key triggers
to intercept and/or supplement the usual behavior of the function keys that
your users will use to navigate the Developer/2000 application.
Objectives
After completing this lesson, you should be able to do the following:
• Redefine function keys
• Determine when Key triggers should be used or avoided
• Coordinate function keys with corresponding interface controls
......................................................................................................................................................
Developer/2000: Build Forms II 4-3
Lesson 4: Programming Function Keys
......................................................................................................................................................
Key Triggers
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
4-4 Developer/2000: 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
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 wants to leave the form.
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;
......................................................................................................................................................
Developer/2000: Build Forms II 4-5
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-6 Developer/2000: Build Forms II
Defining Key Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
apply to Key triggers only.
Property Description
Display in “Keyboard Help” Specifies whether a Key trigger description is displayed in the
run-time Keys Help screen.
“Keyboard Help” Text Specifies the text that will be displayed in the run-time Keys
Help screen if the Display in the “Keyboard Help” property is
set to Yes. If you want the default description to be
displayed, leave this property blank.
......................................................................................................................................................
Developer/2000: Build Forms II 4-7
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-8 Developer/2000: Build Forms II
Characteristics of Key Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
handled by the terminal or window interface manager rather than by
Forms. Examples of such static function keys are [Clear Item], [Left],
[Right], and [Toggle Insert/Replace].
• You can define Key triggers at all three levels: form, block, and item.
• You can use SELECT statements, restricted built-in functions, and
unrestricted built-ins.
• Key triggers can fire in Enter Query mode.
Note: You cannot use all built-ins in Enter Query mode.
If you do not redefine a function key, a built-in function performs its default
functionality when you press the key. Therefore, in most cases, a built-in
function and a Key trigger are associated with a function key. The following
table gives some examples of this.
......................................................................................................................................................
Developer/2000: 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 Developer/2000: Build Forms II
Classification of Key Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Types of Key Triggers
Category Description
Function Key triggers Key triggers that are associated with existing function keys.
They fire when the associated function key is pressed.
Key-Fn triggers Key triggers that are associated with the logical Runform keys
F0 through F9. Before you can use these Key triggers, you or
the DBA must use Oracle Terminal to map these logical keys to
physical keys or key sequences. They fire when the associated
physical key or key sequence is pressed.
Key-Others trigger A Key trigger that is associated with all keys that can have Key
triggers associated with them, but are not currently redefined by
a function Key trigger at any level.
......................................................................................................................................................
Developer/2000: Build Forms II 4-11
Lesson 4: Programming Function Keys
......................................................................................................................................................
Technical Note
Do not use mouse-event Key triggers for important code.
......................................................................................................................................................
4-12 Developer/2000: Build Forms II
Classification of Key Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 which 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 only be activated by the mouse if a trigger is
defined that fires as a result of the mouse action.
......................................................................................................................................................
Developer/2000: Build Forms II 4-13
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-14 Developer/2000: Build Forms II
Using Key Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
reason is that mouse-event Key triggers can be circumvented with the
mouse. Use Key triggers only if you want to adjust the default user interface.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 4-15
Lesson 4: Programming Function Keys
......................................................................................................................................................
Syntax: DO_KEY(built_in_name)
Example: To customize actions when user
exits the form with [Exit Form], a button,
or a menu item:
1. Key-Exit
......................................................................................................................................................
4-16 Developer/2000: Build Forms II
Association with Other Interface Controls
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
manipulation with the mouse. In this case, you want to specify the PL/SQL
code to be executed only once. You can use the built-in function DO_KEY
to accomplish this.
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 pressing [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 using these methods:
a The When-Button-Pressed trigger on the associated Exit button
b The Menu-item code for the menu item that exit the form using
DO_KEY(’EXIT_FORM’);
......................................................................................................................................................
Developer/2000: Build Forms II 4-17
Lesson 4: Programming Function Keys
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
4-18 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
Understanding Key Triggers
• They fire when the associated function key is pressed.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• They are defined like any other trigger.
• Special properties are Display in “Keyboard Help” and “Keyboard Help”
Text.
......................................................................................................................................................
Developer/2000: Build Forms II 4-19
Lesson 4: Programming Function Keys
......................................................................................................................................................
Practice 4 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
4-20 Developer/2000: Build Forms II
Practice Session Overview: Lesson 4
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 4-21
Lesson 4: Programming Function Keys
......................................................................................................................................................
......................................................................................................................................................
4-22 Developer/2000: Build Forms II
Practice Session: Lesson 4
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Modify the message displayed, depending on the block where the
cursor is.
c Specify a new text that will be displayed in the run-time Show Keys
help screen.
......................................................................................................................................................
Developer/2000: Build Forms II 4-23
Lesson 4: Programming Function Keys
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
4-24 Developer/2000: Build Forms II
Responding to Mouse
................................
Events
5
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
5-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
The keyboard, menu, and mouse are the operator’s tools for interacting with
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
the Forms application. This lesson demonstrates how you can write an
application that responds to mouse events.
Objectives
After completing this lesson, you should be able to do the following:
• Describe mouse events
• Cause a form module to respond to mouse movement
• Cause a form module to respond to mouse button actions
......................................................................................................................................................
Developer/2000: Build Forms II 5-3
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Mouse Events
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
SET_APPLICATION_PROPERTY(CURSOR_STYLE,
’value’);
......................................................................................................................................................
5-4 Developer/2000: Build Forms II
What Are Mouse Events?
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
you can associate PL/SQL code (triggers).
A mouse event is an event that can be identified by a mouse movement or a
mouse button action.
......................................................................................................................................................
Developer/2000: 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 have an impact on the performance of your
form, because these triggers have the potential to fire frequently.
......................................................................................................................................................
5-6 Developer/2000: Build Forms II
Responding to Mouse Movement
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
The Three Mouse Movement Triggers
Trigger Use
When-Mouse-Enter Fires when the user moves the mouse into an
item or canvas-view
When-Mouse-Leave Fires when the user moves the mouse out of
an item or canvas-view
When-Mouse-Move Fires when the user moves the mouse within
an item or canvas-view
......................................................................................................................................................
Developer/2000: Build Forms II 5-7
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Navigation in a Block
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
2
7
3 6
4
5
1 MOUSE_FORM 5 MOUSE_RECORD_OFFS
ET
2 MOUSE_CANVAS 6 MOUSE_X_POS
3 MOUSE_ITEM 7 MOUSE_Y_POS
4 MOUSE_RECORD
Technical Note
SYSTEM.MOUSE_FORM is NULL if the platform is not a GUI platform.
......................................................................................................................................................
5-8 Developer/2000: Build Forms II
Responding to Mouse Movement
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Variable Use
SYSTEM.MOUSE_FORM Identifies the form module that the mouse is
currently in.
SYSTEM.MOUSE_CANVAS Identifies the canvas that the mouse is currently
on.
SYSTEM.MOUSE_ITEM Identifies the item that the mouse is currently in.
SYSTEM.MOUSE_RECORD Identifies the record number that the mouse is
currently in.
SYSTEM.MOUSE_RECORD_OFFSET Identifies the number of the record that the mouse
is currently in, relative to the first visible record.
Uses a 1-based index.
SYSTEM.MOUSE_X_POS Identifies the x coordinate of the mouse’s current
position. If the mouse is positioned on a canvas,
the x coordinate is measured relative to the canvas
top-left corner. If the mouse is in an item, the x
coordinate is measured relative to the item’s
top-left corner.
SYSTEM.MOUSE_Y_POS Identifies the y coordinate of the mouse’s current
position. If the mouse is positioned on a canvas,
the y coordinate is measured relative to the
canvas-top left corner. If the mouse is in an item,
the y coordinate is measured relative to the item’s
top-left corner.
......................................................................................................................................................
Developer/2000: 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
5-8 Copyright Oracle Corporation, 1998. All rights reserved.
Technical Note
Click and double-click occur only if the mouse stays on the item (or canvas)
throughout the down-up action.
......................................................................................................................................................
5-10 Developer/2000: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
The Mouse Button Action Triggers
Trigger Use
When-Mouse-Down Initiates an action when the user presses the
mouse button down while the mouse is point-
ing to an item or a canvas
When-Mouse-Up Initiates an action when the user presses and
releases the mouse button while the mouse is
pointing to an item or a canvas
When-Mouse-Click Initiates an action when the user clicks on an
item or canvas
When-Mouse-Doubleclick Initiates an action when the user double-
clicks an item or canvas
......................................................................................................................................................
Developer/2000: Build Forms II 5-11
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
SYSTEM.MOUSE_BUTTON_PRESSED
SYSTEM.MOUSE_BUTTON_MODIFIERS
Ctrl Alt
......................................................................................................................................................
5-12 Developer/2000: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
Use the following system variables to determine which of the mouse buttons
was pressed and which special key, if any, was used.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Variable Use
SYSTEM.MOUSE_BUTTON_PRESSED Identifies which mouse button was pressed
(values of 1-5, where 1 is the left mouse
button)
SYSTEM.MOUSE_BUTTON_MODIFIERS Identifies which special key was pressed to
modify the usual mouse button action
(possible values are: Shift+,
Caps Lock+, Control+, Alt+,
Command+, Super+, and Hyper+)
If the operator holds down the control and shift keys while pressing the
mouse button, SYSTEM.MOUSE_BUTTON_MODIFIERS contains the
value “Shift+Control+”.
......................................................................................................................................................
Developer/2000: Build Forms II 5-13
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Item-A highlighted
Items repositioned
......................................................................................................................................................
5-14 Developer/2000: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Implementing Drag and Drop Functionality
You can use the mouse button action triggers (When-Mouse-Down and
When-Mouse-Up) and the mouse position system variables to implement
drag and drop functionality in your form module.
You need to consider the following when implementing drag and drop:
• Changing the appearance of the item you want to drag and drop.
- Use the SET_ITEM_PROPERTY built-in and a visual attribute.
• Changing the appearance of the cursor during the drag and drop process.
- Use SET_APPLICATION_PROPERTY(cursor_style, ‘value’).
• Holding the name of the item being dragged and dropped.
- Use a global variable to store the initial value of
SYSTEM.MOUSE_ITEM.
• Setting the new position, according to the mouse position.
- Use SET_ITEM_PROPERTY(:global.variablename, position,
:SYSTEM.MOUSE_X_POS, :SYSTEM.MOUSE_Y_POS).
• Repositioning other items that may be affected.
......................................................................................................................................................
Developer/2000: Build Forms II 5-15
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
In this lesson, you saw how to write an application that responds to mouse
events.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• The 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
• Mouse movement triggers
- When-Mouse-Enter
- When-Mouse-Leave
- When-Mouse-Move
• Responding to mouse button actions
- Mouse button system variables
- Mouse button triggers
• When-Mouse-Click
• When-Mouse-Doubleclick
• When-Mouse-Up
• When-Mouse-Down
......................................................................................................................................................
Developer/2000: Build Forms II 5-17
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
Practice 5 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
5-18 Developer/2000: Build Forms II
Practice Session Overview: Lesson 5
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 5-19
Lesson 5: Responding to Mouse Events
......................................................................................................................................................
......................................................................................................................................................
5-20 Developer/2000: Build Forms II
Controlling Windows and
Programmatically
Canvases
................................
6
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
6-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
You should already be familiar with setting Window and Canvas properties
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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:
• Create trigger code to interact with windows
• Control windows programmatically
• Control canvases
• Design Spread Table to display large data blocks
......................................................................................................................................................
Developer/2000: Build Forms II 6-3
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Using Window-Interaction
Triggers
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Trigger Use
• System Variable
– :SYSTEM.EVENT_WINDOW
6-3 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
6-4 Developer/2000: Build Forms II
Using Window-Interaction Triggers
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
the form level.
Trigger Characteristic
When-Window-Activated Fires when a window is made the active window. Note
that window activation can occur independently of navi-
gation.
When-Window-Deactivated Fires when a user deactivates a window by setting the
input focus to another window.
When-Window-Closed Fires when a user closes a window using a window-man-
ager-specific Close command.
When-Window-Resized Fires when a window is resized, either by the user or
through a trigger. It also fires at form startup, but not
when a window is made into an icon.
......................................................................................................................................................
Developer/2000: Build Forms II 6-5
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
• FIND_WINDOW
• GET_WINDOW_PROPERTY
• HIDE_WINDOW
• MOVE_WINDOW
• RESIZE_WINDOW
• SET_WINDOW_PROPERTY
• SHOW_WINDOW
Technical Note
In Microsoft Windows, you can reference the multiple document interface
(MDI) application window with the FORMS_MDI_WINDOW name.
......................................................................................................................................................
6-6 Developer/2000: Build Forms II
Built-ins for Manipulating WINDOWS
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
FIND_WINDOW Returns the internal window ID (of datatype
WINDOW) of a window with the given name
GET_WINDOW_PROPERTY Returns the current value of the specified
window property for the given window
HIDE_WINDOW Hides the window
MOVE_WINDOW Moves the window to the location specified by
the given coordinates
RESIZE_WINDOW Changes the window to the specified width and
height
SET_WINDOW_PROPERTY Sets the specified window property for the
given window to a specified value
SHOW_WINDOW Makes the window visible at the current or
specified display position
......................................................................................................................................................
Developer/2000: Build Forms II 6-7
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
• FIND_CANVAS
• FIND_VIEW
• GET_CANVAS_PROPERTY
• GET_VIEW_PROPERTY
• HIDE_VIEW
• REPLACE_CONTENT_VIEW
• SCROLL_VIEW
• SET_CANVAS_PROPERTY
• SET_VIEW_PROPERTY
• SHOW_VIEW
6-5 Copyright Oracle Corporation, 1998. All rights reserved.
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.
......................................................................................................................................................
6-8 Developer/2000: Build Forms II
Built-ins for Manipulating Canvases
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Built-in Description
FIND_CANVAS Returns the internal canvas ID (of datatype CANVAS)
of a canvas with the given name
FIND_VIEW Returns the internal view ID (of datatype
VIEWPORT) of a canvas with the given name
GET_CANVAS_PROPERTY Returns the current value of the specified Canvas
property for the given canvas
GET_VIEW_PROPERTY Returns the current value of the specified View prop-
erty for the canvas
HIDE_VIEW Hides the canvas
REPLACE_CONTENT_VIEW Replaces the content canvas currently displayed in the
window with the specified content canvas
SCROLL_VIEW Moves the view of a given canvas to a different posi-
tion on its canvas (does not move the window to a
different position on the screen)
SET_CANVAS_PROPERTY Sets the specified Canvas property for the given can-
vas to a specified value
SET_VIEW_PROPERTY Sets the specified View property for the given canvas
to a specified value
SHOW_VIEW Makes the given canvas visible at the current display
position
......................................................................................................................................................
Developer/2000: Build Forms II 6-9
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Previous Next
tab page tab page
......................................................................................................................................................
6-10 Developer/2000: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
navigation from one tab page to another in a tab canvas. In other words,
when the user clicks a tab or presses the [Ctrl]+[PgUp] or [Ctrl]+[PgDown]
keys.
This trigger is very often used to perform actions when any tab page is
changed during item or mouse navigation; for example, to enable or disable
items or to set default or related item values.
Be aware that this trigger does not fire when the tab page is changed
programmatically and does not fire with implicit navigation.
Technical Note
When changing to another tab page, the cursor does not automatically move
to a different item. If you wish 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).
......................................................................................................................................................
Developer/2000: Build Forms II 6-11
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
• GET_TAB_PAGE_PROPERTY
– Returns the tab page label or the tab
page canvas
• SET_TAB_PAGE_PROPERTY
– Enables changing of the tab page
label
• FIND_TAB_PAGE
– Returns the tab page ID
......................................................................................................................................................
6-12 Developer/2000: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
returns a tab page ID when it finds a valid tab page
with the given name. You must define a variable of
type TAB_PAGE to accept the return value.
SET_TAB_PAGE_PROPERTY Sets the tab page properties (ENABLED, LABEL,
VISIBLE, VISUAL_ATTRIBUTE) of the specified
tab canvas page.
GET_TAB_PAGE_PROPERTY Returns property values (CANVAS_NAME,
ENABLED, LABEL, VISIBLE,
VISUAL_ATTRIBUTE) for a specified tab page.
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;
GET_CANVAS_PROPERTY(’canvas_name’, TOPMOST_TAB_PAGE)
SET_CANVAS_PROPERTY(’canvas_name’, TOPMOST_TAB_PAGE, page_name)
......................................................................................................................................................
Developer/2000: Build Forms II 6-13
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Block 1
window window
Window 2
Block 2
Block 3
Cursor
location
......................................................................................................................................................
6-14 Developer/2000: Build Forms II
Windows and Blocks
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
following characteristics of 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.
......................................................................................................................................................
Developer/2000: 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:
......................................................................................................................................................
6-16 Developer/2000: Build Forms II
Manipulating Window Properties Programmatically
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Windows) at run-time.
BEGIN
SET_WINDOW_PROPERTY(forms_mdi_window, window_state, maximize);
SET_WINDOW_PROPERTY(forms_mdi_window, title, ’Summit Sporting
Goods.’);
END;
FUNCTION get_cursor_window
RETURN VARCHAR2
IS
BEGIN
RETURN (GET_VIEW_PROPERTY(GET_ITEM_PROPERTY(
NAME_IN(’system.cursor_item’),item_canvas),
window_name));
END;
......................................................................................................................................................
Developer/2000: Build Forms II 6-17
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
......................................................................................................................................................
6-18 Developer/2000: Build Forms II
Showing Multiple Windows
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
window is displayed.
The following examples show a form based on departments and employees.
The department block and employee block are located in separate windows.
DECLARE
v_first_window_x NUMBER;
v_first_window_y NUMBER;
BEGIN
DEFAULT_VALUE(’0’, ’global.first_window_x’);
DEFAULT_VALUE(’0’, ’global.first_window_y’);
v_first_window_x := :global.first_window_x;
v_first_window_y := :global.first_window_y;
SET_WINDOW_PROPERTY(’window1’, position, v_first_window_x,
v_first_window_y);
SET_WINDOW_PROPERTY(’window2’, position, v_first_window_x + 3,
v_first_window_y + 1);
SHOW_WINDOW(’window1’);
END;
BEGIN
SET_WINDOW_PROPERTY(’window2’,title,’Employees of Department’
||NVL(TO_CHAR(:dpt.id), ’??’));
END;
......................................................................................................................................................
Developer/2000: Build Forms II 6-19
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
......................................................................................................................................................
6-20 Developer/2000: 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
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
BEGIN
IF :SYSTEM.EVENT_WINDOW = ’WINDOW1’ THEN
DO_KEY(’exit_form’);
ELSIF :SYSTEM.EVENT_WINDOW = ’WINDOW2’ THEN
HIDE_WINDOW(’window2’);
END IF;
END;
BEGIN
IF :SYSTEM.EVENT_WINDOW = get_cursor_window THEN
RETURN;
ELSIF :SYSTEM.EVENT_WINDOW = ’WINDOW1’ THEN
GO_BLOCK(’s_dept’);
ELSIF :SYSTEM.EVENT_WINDOW = ’WINDOW2’ THEN
GO_BLOCK(’s_emp’);
END IF;
END;
......................................................................................................................................................
Developer/2000: Build Forms II 6-21
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
......................................................................................................................................................
6-22 Developer/2000: Build Forms II
Using Large Blocks
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
window with one content canvas and several stacked canvases in the
following manner:
1 Divide the items into logical groups and name each group.
2 Place the main group on the content canvas.
3 Place each of the other groups on a separate stacked canvas.
4 Give each stacked canvas the same size and position.
5 Provide a convenient means to navigate between the groups, such as
using a list item containing the names of all the groups.
......................................................................................................................................................
Developer/2000: Build Forms II 6-23
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
Characteristics and Uses of the Four Window-Interaction Triggers
• When-Window-Activated
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• When-Window-Deactivated
• When-Window-Closed
• When-Window-Resized
Use the SYSTEM.EVENT_WINDOW system variable to keep track of the
triggered window.
......................................................................................................................................................
Developer/2000: Build Forms II 6-25
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
Practice 6 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
6-26 Developer/2000: Build Forms II
Practice Session Overview: Lesson 6
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 topmost page.
......................................................................................................................................................
Developer/2000: Build Forms II 6-27
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................
b Make sure that when a user closes the orders window by way of the
system-menu box, the form is exited. You can import the pr6_1b.txt
file.
c Make sure that when a user closes the inventory window by way of
the system-menu box, the cursor always navigates to the orders
window. If cursor navigation succeeds, the inventory window must
be closed. You can import the pr6_1c.txt file.
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 which checks for the current window if
the new width and height are not larger than the initial one. You can
import the pr6_1d1.txt and pr6_1d2.txt files.
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 document.
c Modify the When-Tab-Page-Changed trigger to change the label on
the Comment tab page: when Comment is 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 Developer/2000: Build Forms II
Controlling Data Block
Relationships
................................
7
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
Developer/2000: Build Forms II 7-2
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
Introduction
Overview
You have seen how form modules consist of data blocks based on related
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
Objectives
After completing this lesson, you should be able to do the following:
• Define block coordination
• Create and modify relations
• Describe the characteristics and principles of relation-handling code
• Implement a coordination-type toggle
• Force one commit per master record
......................................................................................................................................................
7-3 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Relations
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Technical Note
Use the block names and not the table names when you specify the join
condition.
......................................................................................................................................................
Developer/2000: Build Forms II 7-4
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
Creating a Relation
What Is a Relation?
A relation is a Form Builder object that handles the relationship between
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 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. As
with implicitly created relations, PL/SQL program units and triggers are
created automatically when you explicitly create a relation.
......................................................................................................................................................
7-5 Developer/2000: Build Forms II
Creating a Relation
......................................................................................................................................................
Deletion Properties
Isolated
= Deleted
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Cascading
Nonisolated
Master-Detail No Detail Rec
Records
Nonisolated
Detail Rec
7-5 Copyright Oracle Corporation, 1998. All rights reserved.
Technical Note
It is advisable to use this Form Builder Feature to confirm the settings in
Oracle Server.
......................................................................................................................................................
Developer/2000: Build Forms II 7-6
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
Modifying a Relation
You can alter the relation properties to affect the way deletes and block
coordination are handled.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Master Deletes
You can prevent, propagate, or isolate deletion of a record in a master block
when corresponding records exist in the detail block by setting the Master
Deletes property. For example, you can delete all corresponding line items
when an order is deleted.
Property Use
Non-Isolated Prevents deletion of the master record when detail records exist
Cascading Deletes the detail records when a master record is deleted
Isolated Deletes only the master record
Note: Although deleting with the cascading property may remove many
detail records, the commit message shows only the number of records
deleted from the master block.
......................................................................................................................................................
7-7 Developer/2000: Build Forms II
Modifying a Relation
......................................................................................................................................................
Coordination Properties
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Join Condition
Technical Note
Changing a block name after the relation has been created results in
generation errors. Delete the relation and re-create it.
......................................................................................................................................................
Developer/2000: Build Forms II 7-8
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
Coordination
You can control how the detail records are display when a master block is
queried by setting the coordination property. For example, you can defer
querying the line items for an order until the operator navigates to the item
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
block.
Note: Setting the Deferred property to Yes enables the Auto Query check
box.
Join Condition
Use to:
• Create links between blocks using SQL
• Alter links between blocks using SQL
Define using:
• Usual SQL equi-join condition syntax
• Block names instead of the base table names
• Item names that exist in the form module instead of base table column
names
......................................................................................................................................................
7-9 Developer/2000: Build Forms II
Modifying a Relation
......................................................................................................................................................
Block Coordination
• Coordination-causing event
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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
7-8 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
Developer/2000: Build Forms II 7-10
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
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
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
Block-Coordination Phases
Phase Description
Clear Forms clears all detail blocks before it navigates to the new master record.
Possible changes in detail blocks will be deleted. If the Clear phase fails,
Forms stops coordination processing and does not navigate to the new master
record.
Populate Forms queries all detail blocks after it has navigated to the new master record,
unless the coordination type is Deferred.
......................................................................................................................................................
7-11 Developer/2000: Build Forms II
Block Coordination
......................................................................................................................................................
Characteristics of Relation-
Handling Triggers
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• On-Clear-Details
– Implements the Clear phase
• On-Populate-Details
– Implements the Populate phase
• On-Check-Delete-Master
– Implements the restricted-delete rule
• Effect of trigger failure
Technical Note
Relation-handling triggers fire only if you have defined a corresponding
relation.
......................................................................................................................................................
Developer/2000: Build Forms II 7-12
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Trigger Characteristic
On-Clear-Details Fires when a coordination-causing event occurs in a mas-
ter block, before Forms navigates to the new master
record. This trigger implements the Clear phase and is
defined at the form level. If it fails, the coordination-caus-
ing event is aborted.
On-Populate-Details Fires when a coordination-causing event occurs in a mas-
ter block, after Forms has navigated to the new master
record. However, it fires only if an On-Clear-Details trig-
ger is also defined. This trigger implements the Populate
phase and is defined for each master block. If it fails, it
can cause the wrong detail records to be displayed for the
current master record.
On-Check-Delete-Master Fires when you attempt to delete the current master
record, before Forms deletes the record. If it fails, the
record deletion is aborted.
......................................................................................................................................................
7-13 Developer/2000: Build Forms II
Characteristics of Relation-Handling Triggers
......................................................................................................................................................
Principles of Relation-Handling
Code
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
Developer/2000: Build Forms II 7-14
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
triggers.
--
-- Begin default relation program section
--
BEGIN
CLEAR_ALL_MASTER_DETAILS;
END;
--
-- End default relation program section
--
You can add PL/SQL code to relation-handling triggers before the “Begin
default relation program section” comment or after the “End default relation
program section” comment.
Note: Forms will not delete a relation-handling trigger to which you have
properly added PL/SQL code.
......................................................................................................................................................
7-15 Developer/2000: Build Forms II
Principles of Relation-Handling Code
......................................................................................................................................................
Obtaining Relation-Handling
Information
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 7-16
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
modify the default relation-handling triggers.
......................................................................................................................................................
7-17 Developer/2000: Build Forms II
Obtaining Relation-Handling Information
......................................................................................................................................................
Implementing a
Coordination-Type Toggle
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Implementing a
Coordination-Type Toggle
Call this procedure from:
• When-Checkbox-Changed trigger
• Menu item of type Check
......................................................................................................................................................
Developer/2000: Build Forms II 7-18
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
This example procedure can be used in a simple master-detail form and can
serve as a starting point for more complex situations; for example, you can
call this procedure from a When-Checkbox-Changed trigger on a check box
that represents the coordination type, or from a menu item of type Check.
PROCEDURE toggle_query_sync
(p_master_block in VARCHAR2)
IS
v_rel_name VARCHAR2(30);
v_rel_id RELATION;
BEGIN
v_rel_name := GET_BLOCK_PROPERTY(p_master_block,
first_master_relation);
IF v_rel_name IS NOT NULL THEN
v_rel_id := FIND_RELATION(v_rel_name);
IF GET_RELATION_PROPERTY(v_rel_id, deferred_coordination) =
’FALSE’ THEN
SET_RELATION_PROPERTY(v_rel_id,deferred_coordination,
property_true);
SET_RELATION_PROPERTY(v_rel_id,autoquery,property_true);
MESSAGE(’Query-synchronization mode: deferred.’);
ELSE
SET_RELATION_PROPERTY(v_rel_id,deferred_coordination,
property_false);
MESSAGE(’Query-synchronization mode: immediate.’);
END IF;
END IF;
END toggle_query_sync;
......................................................................................................................................................
7-19 Developer/2000: Build Forms II
Implementing a Coordination-Type Toggle
......................................................................................................................................................
......................................................................................................................................................
Developer/2000: Build Forms II 7-20
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
level constraints, such as a mandatory relationship).
You must call the procedure below from the On-Clear-Details trigger before
the “Begin default relation program section” comment. Note that if the On-
Clear-Details trigger fails, the change of master record is aborted.
PROCEDURE check_master_change
IS
v_master_record NUMBER;
BEGIN
-- Force update of record status.
VALIDATE(record_scope);
IF FORM_SUCCESS THEN
-- Check if master record has been modified.
v_master_record :=
GET_BLOCK_PROPERTY(NAME_IN(’system.master_block’),
current_record);
IF GET_RECORD_PROPERTY(v_master_record,
NAME_IN(’system.master_block’),status)
IN (’INSERT’, ’CHANGED’) THEN
MESSAGE(’You must commit first before you go to another
master record.’);
RAISE form_trigger_failure;
END IF;
ELSE
-- Validation error.
RAISE form_trigger_failure;
END IF;
END check_master_change;
......................................................................................................................................................
7-21 Developer/2000: Build Forms II
Forcing a Commit Per Master
......................................................................................................................................................
Summary
Creating relations
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Implicitly
• Explicitly
Relation properties
• For deletion
• For coordination
Block-coordination
• Coordination-causing events change
the master record
• Clear and Populate
7-16 Copyright Oracle Corporation, 1998. All rights reserved.
Summary
......................................................................................................................................................
Developer/2000: Build Forms II 7-22
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
Summary
Creating Relations
• Implicitly, when a block is created through the New Block facility
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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.
......................................................................................................................................................
7-23 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Practice 7 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
Developer/2000: Build Forms II 7-24
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Practice Contents
• Examining and changing relation properties
• Creating a relation explicitly
• 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.
......................................................................................................................................................
7-25 Developer/2000: Build Forms II
Practice Session: Lesson 7
......................................................................................................................................................
1 Open the ORDERS form and examine the properties of the relation
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 Create a relation called S_Item_S_Inventory explicitly between the
S_Item and S_Inventory blocks.
a Ensure that line item records can be deleted independently of any
related Inventory.
b Set the coordination so that the Inventory block is not queried until
you explicitly execute a query.
3 Implement a query coordination-type toggle.
a Add two check boxes to the control block with the following
properties:
......................................................................................................................................................
Developer/2000: Build Forms II 7-26
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
bMake sure that the first check box enables a user to toggle between
immediate coordination and deferred coordination. You can import
the pr7_3b.txt file.
c Make sure that the second check box enables a user to toggle
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
between automatic query and no automatic query for the detail
block. This check box should be disabled if the other check box
indicates immediate coordination. You can import the pr7_3c.txt file.
If you have time...
4 Synchronize the check boxes at form startup.
a Open the ORDERS form module.
b Create a procedure called INIT_RELATION_CHECK_BOXES.
This procedure sychronizes the IMMEDIATE and AUTO_QUERY
check boxes with the current default value. You can import the
pr7_4b.txt file.
c Call this procedure at form startup.
5 Implement foreign-key delete rules.
a Open the CUSTOMERS form module.
b Create a procedure called CHECK_DEL_CUS. This procedure
displays an error message as soon as a user tries to delete a customer
for which matching orders exist. You can import the pr7_5b.txt file.
c Call the procedure when a user presses the delete function-key.
......................................................................................................................................................
7-27 Developer/2000: Build Forms II
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
7-28 Developer/2000: Build Forms II
Building Multiple Form
Applications
................................
8
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
8-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
You have already seen that Developer/2000 applications frequently consist
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
of more than one form module. 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 relevant details of invoking forms
• Build robust multiple-form transactions
• Choose between different ways of invoking forms
• Pass data between forms using parameter lists
......................................................................................................................................................
Developer/2000: Build Forms II 8-3
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
OPEN_FORM to Invoke
Additional Forms
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
A B
• Modeless
• Different transaction
scopes
OPEN_FORM(’form_name ’,activate_mode,
session_mode, 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
......................................................................................................................................................
8-4 Developer/2000: Build Forms II
OPEN_FORM to Invoke Additional Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
same transaction scope or within a new transaction scope.
Syntax
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
......................................................................................................................................................
Developer/2000: Build Forms II 8-5
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Closing Forms
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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
8-5 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
8-6 Developer/2000: Build Forms II
Closing Forms
......................................................................................................................................................
Closing Forms
Syntax
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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)
......................................................................................................................................................
Developer/2000: Build Forms II 8-7
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
8-8 Developer/2000: Build Forms II
Navigating Between Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
blocks within one form.
......................................................................................................................................................
Developer/2000: Build Forms II 8-9
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Session
8-9 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
8-10 Developer/2000: Build Forms II
Transaction Processing for Opened Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
the Oracle Server. By default, one database session is created for this
connection. When you open forms within the same session, consider these
issues:
• If you issue a commit, all forms will be processed in the order in which
they were opened, starting with the current form.
• If an error occurs during commit processing, Form Builder sets the input
focus to the form that initiated the commit.
• Commit processing usually causes messages to occur for every open
form within the same session. Because Form Builder maintains a
message line per open form, a user may have to acknowledge messages
from non-current open forms. This could be confusing.
• If you issue a CLEAR_FORM command, Form Builder will usually
issue a ROLLBACK statement, which rolls back all the changes in the
database and releases all locks. However, non-current open forms are not
cleared.
......................................................................................................................................................
Developer/2000: Build Forms II 8-11
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
CALL_FORM to Invoke
Additional Forms
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
A B
• Modal
• Returns to calling
form
CALL_FORM(’form_name ’, display,
switch_menu, query_mode,
data_mode, paramlist);
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
......................................................................................................................................................
8-12 Developer/2000: Build Forms II
CALL_FORM to Invoke Additional Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
called form is exited, Form Builder returns to the calling form.
Syntax
Parameter Description
form_name The file holding the executable form module.
display Either HIDE (the default) or NO_HIDE (This defines whether the calling
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 from the called form.)
......................................................................................................................................................
Developer/2000: Build Forms II 8-13
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
8-14 Developer/2000: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
What Is Post-Only Mode?
When a calling form has pending updates or deletes that have not been
explicitly posted or committed, Form Builder runs the called form in
Post-Only mode. Additionally, any form called from a form running in
Post-Only mode will also be in Post-Only mode.
EXIT_FORM(ask_commit, to_savepoint);
Technical Note
Do not confuse call savepoints, which are set when a form is called or
started, with post savepoints, which are set at the start of a post.
......................................................................................................................................................
Developer/2000: Build Forms II 8-15
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Transaction Processing
for Called Forms
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Transaction Processing
for Called Forms
• Key-Exit on form
IF <form called> THEN
EXIT_FORM(ASK_COMMIT, NO_ROLLBACK);
ELSE
EXIT_FORM;
END IF;
......................................................................................................................................................
8-16 Developer/2000: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Redefine [Exit] so that it does not perform a rollback when the form is
called.
• You may want to adjust the labels of possible buttons and menu items
that correspond to [Commit] and [Exit].
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;
BEGIN
IF GET_APPLICATION_PROPERTY(calling_form) is not null THEN
EXIT_FORM(ask_commit, no_rollback);
ELSE
EXIT_FORM;
END IF;
END;
......................................................................................................................................................
Developer/2000: Build Forms II 8-17
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
NEW_FORM to Invoke
Additional Forms
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
A B
• Replaces calling
form
NEW_FORM(’form_name’, rollback_mode,
query_mode, data_mode,
paramlist);
......................................................................................................................................................
8-18 Developer/2000: Build Forms II
NEW_FORM to Invoke Additional Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
form.
Syntax
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.)
......................................................................................................................................................
Developer/2000: Build Forms II 8-19
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Form B
OPEN_FORM
S.P.
CALL_FORM
Form F
Form E
Form A+B+E = Call Form Stack
8-17 Copyright Oracle Corporation, 1998. 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.
•
......................................................................................................................................................
8-20 Developer/2000: Build Forms II
Controlling Open Forms and Called Forms Together
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Call Form Stack
When you call a form with CALL_FORM, the calling form is disabled until
the operator exits from the called form. However, a called form can in turn
call other forms. When successive forms are loaded by way of
CALL_FORM in this way, the resulting form hierarchy is known as the call
form stack.
......................................................................................................................................................
Developer/2000: Build Forms II 8-21
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
8-22 Developer/2000: Build Forms II
Different Ways of Invoking Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
open forms are modeless, a user can freely switch between them.
OPEN_FORM is most appropriate for invoking forms from the application-
system menu. A drawback of OPEN_FORM is that it may be difficult to
keep multiple open forms synchronized. For example, you may want the
current order in an Orders form always to belong to the current customer in a
Customers form.
......................................................................................................................................................
Developer/2000: Build Forms II 8-23
Lesson 8: 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
......................................................................................................................................................
8-24 Developer/2000: Build Forms II
Using Form Parameters
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
requires at startup. They are forms variables that you define at design time in
the Parameter Properties window.
......................................................................................................................................................
Developer/2000: Build Forms II 8-25
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
8-26 Developer/2000: 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.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
f50run32 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;
......................................................................................................................................................
Developer/2000: Build Forms II 8-27
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Parameter Lists
Parameter
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
List
OPEN_FORM( …, )
CALL_FORM( …, )
NEW_FORM( …, )
The default parameter list is DEFAULT
8-22 Copyright Oracle Corporation, 1998. All rights reserved.
Technical Note
You must define the parameters whose values are being passed to a form in
that form at design time.
......................................................................................................................................................
8-28 Developer/2000: 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.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
What Is a Parameter List?
A parameter list is a named programmatic construct that lists parameter
names (called keys), their types, and their values. You can specify parameter
lists in the calls to the following built-ins:
• CALL_FORM
• OPEN_FORM
• NEW_FORM
• RUN_PRODUCT
......................................................................................................................................................
Developer/2000: Build Forms II 8-29
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
CREATE_PARAMETER_LIST
Name Key Type Value
Parameter
ORDERS DATA_PARAMETER ‘RG_ORD’
list ID
ADD_PARAMETER
GET_PARAMETER_ATTR
DESTROY_PARAMETER_LIST
SET_PARAMETER_ATTR
DELETE_PARAMETER
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.
......................................................................................................................................................
8-30 Developer/2000: Build Forms II
Creating and Manipulating Parameter Lists
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Built-in Description
CREATE_PARAMETER_LIST Creates a parameter list with the given name and
returns the ID of this parameter list
DESTROY_PARAMETER_LIST Deletes the given, programmatically created,
parameter list (and all its parameters)
GET_PARAMETER_LIST Returns the internal parameter list ID (of type
PARAMLIST) of a parameter list with the given
name (This built-in is similar to the FIND_object
built-ins.)
ADD_PARAMETER Adds a parameter with a specified name (also
called key), type (TEXT_PARAMETER or
DATA_PARAMETER), and value (in CHAR for-
mat) to the given parameter list
DELETE_PARAMETER Deletes the parameter with the specified name from
the given parameter list
GET_PARAMETER_ATTR Gets the type and value of the parameter with the
specified name in the given parameter list
SET_PARAMETER_ATTR Sets the type and value of the parameter with the
specified name in the given parameter list
......................................................................................................................................................
Developer/2000: Build Forms II 8-31
Lesson 8: 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.
......................................................................................................................................................
8-32 Developer/2000: Build Forms II
Passing Data Between Forms
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
variable approach.
Example
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.
......................................................................................................................................................
Developer/2000: Build Forms II 8-33
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Summary
• Opening, calling, and closing forms:
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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
8-27 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
8-34 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
The Three Built-ins for Invoking a Form
• OPEN_FORM
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• CALL_FORM
• NEW_FORM
......................................................................................................................................................
Developer/2000: Build Forms II 8-35
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
Practice 8 Overview
• Implementing a button on CUSTOMER
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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
8-28 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
8-36 Developer/2000: Build Forms II
Practice Session Overview: Lesson 8
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Practice Contents
• Implement a button on CUSTOMER to call EMPLOYEE.
- 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.
......................................................................................................................................................
Developer/2000: Build Forms II 8-37
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................
......................................................................................................................................................
8-38 Developer/2000: Build Forms II
Defining Data Sources
................................
9
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 9: Defining Data Sources
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
9-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson introduces you to the different data source types that can be used
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 different 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 which returns a Ref cursor
• Select the appropriate data source for data block
......................................................................................................................................................
Developer/2000: Build Forms II 9-3
Lesson 9: Defining Data Sources
......................................................................................................................................................
Query DML
Table Table
FROM clause Company Name:
query
Company Code:
Stored Balance: Stored
procedure procedure
Transactional Transactional
trigger trigger
......................................................................................................................................................
9-4 Developer/2000: Build Forms II
Data Sources Types
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
DML operations. A base table is not the only source for a data block, and
you can specify the data source for the query separately from DML.
......................................................................................................................................................
Developer/2000: Build Forms II 9-5
Lesson 9: Defining Data Sources
......................................................................................................................................................
SELECT...
FROM...
(SELECT...
FROM...
WHERE...)
WHERE...
......................................................................................................................................................
9-6 Developer/2000: Build Forms II
Basing a Data Block on a From Clause Query
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
statement in the FROM clause of a SELECT statement.
A FROM clause is a valid query block data source, but it is not a valid DML
block data source. The value returned from a FROM clause is a subset of
records from the original query.
Example
......................................................................................................................................................
Developer/2000: Build Forms II 9-7
Lesson 9: Defining Data Sources
......................................................................................................................................................
Operations
Return data by way of
• Ref cursor
• Table of records
......................................................................................................................................................
9-8 Developer/2000: Build Forms II
Basing a Data Block on a Stored Procedure
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
What Is a Ref Cursor?
A Ref cursor defines a SELECT statement that is the source of the records.
You can use it to perform array fetches of SELECT statements opened by a
server-side procedure.
A Ref cursor is a pointer to a server-side cursor variable. It is analogous to a
pointer in C in that it is an address to a location in memory. The stored
procedure returns a reference to a cursor that is open and populated by a
SELECT statement to be used as a block data source.
A stored procedure that uses a Ref cursor can only be used as a query block
data source; it cannot be used for DML block data source. Using a Ref
cursor is ideal for queries that depend only on variations in SQL Select
statements and not PL/SQL.
......................................................................................................................................................
Developer/2000: Build Forms II 9-9
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-10 Developer/2000: Build Forms II
Example of Query Using a Ref Cursor Procedure
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
procedures logically.
......................................................................................................................................................
Developer/2000: Build Forms II 9-11
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-12 Developer/2000: Build Forms II
Example of Query Using a Table of Records Procedure
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
types and procedures.
......................................................................................................................................................
Developer/2000: Build Forms II 9-13
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-14 Developer/2000: Build Forms II
Example of DML Using a Stored Procedure
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
related data types and procedures. You should define procedures that update,
delete, and lock rows also.
......................................................................................................................................................
Developer/2000: Build Forms II 9-15
Lesson 9: Defining Data Sources
......................................................................................................................................................
SQL
SELECT
Procedure
Ref cursor
3
Fetched rows
4
Query 1 2 Cursor
Cursor
3
Table of records
4
......................................................................................................................................................
9-16 Developer/2000: Build Forms II
Deciding Whether to Use a Ref Cursor or a Table of Records
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
account the following considerations.
......................................................................................................................................................
Developer/2000: Build Forms II 9-17
Lesson 9: Defining Data Sources
......................................................................................................................................................
following:
• Data source type
• Query procedure
• Insert procedure
• Update procedure
• Delete procedure
• Lock procedure
......................................................................................................................................................
9-18 Developer/2000: Build Forms II
Data Block Wizard
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Forms I.
Use the New Data Block Wizard even if you want to create a date block
based on stored procedure. You just have to specify the following:
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 the 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.
......................................................................................................................................................
Developer/2000: Build Forms II 9-19
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-20 Developer/2000: Build Forms II
Data Block Properties
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Property Description
Query Data Source Type Specifies the Query Data Source Type for the data
block
Query Data Source Name Only used if 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 (Only used if
Query Data Source Type is Table, Subquery, or
Procedure.)
Query Data Source Arguments Specifies the names, data-types, and values of the
arguments that are to be passed to the procedure for
querying data (Only used if 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 (Only used if DML Data Target Type is
Table.)
(Insert, Update, Delete, Lock) Specifies the name of the procedure to be used (Only
Procedure Name used if DML Data Target Type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names and datatypes of the
Procedure Result Set Columns result set columns associated with the
procedure (Only used if DML Data Target
Type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names, datatypes, and values
Procedure Arguments of the arguments that are to be passed to the
procedure (Only used if DML Data Target
Type is Procedure.)
......................................................................................................................................................
Developer/2000: Build Forms II 9-21
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-22 Developer/2000: Build Forms II
Data Source Guidelines
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Create a dynamic view
• Perform validation and DML on the server side
......................................................................................................................................................
Developer/2000: Build Forms II 9-23
Lesson 9: Defining Data Sources
......................................................................................................................................................
......................................................................................................................................................
9-24 Developer/2000: Build Forms II
Data Source Guidelines
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• Will the block be used to perform Inserts, Updates, and Deletes?
• Will the block be used to perform both query and DML?
To decide, you should also consider the functional restrictions for each data
source type:
......................................................................................................................................................
Developer/2000: Build Forms II 9-25
Lesson 9: Defining Data Sources
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Summary
......................................................................................................................................................
9-26 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
New Data Sources
• Stored procedure (query and DML)
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• FROM clause query (query only)
......................................................................................................................................................
Developer/2000: Build Forms II 9-27
Lesson 9: Defining Data Sources
......................................................................................................................................................
Practice 9 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
9-28 Developer/2000: Build Forms II
Practice Session Overview: Lesson 9
......................................................................................................................................................
Practice Contents
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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
......................................................................................................................................................
Developer/2000: Build Forms II 9-29
Lesson 9: Defining Data Sources
......................................................................................................................................................
b Set the Query Data Source Type EMP block property to From Clause
Query.
c In the property Query Data Source Name 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 pr9_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)
......................................................................................................................................................
9-30 Developer/2000: Build Forms II
Practice Session: Lesson 9
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
c Remove the appropriate Transactional triggers.
d Save, run and test your module.
If you have time...
3 Create a package containing a stored procedure to return a Ref Cursor.
a Using the code in the file pr9_3a.sql in your labs directory, create the
Orders package body and package specification.
4 Modify the Ord_Sum block in module ord_sum.fmb to base it on the
Stored Procedure.
a Open module ord_sum.fmb. 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
(:Choose.View_Type) to the procedure to determine which SELECT
statement is used. These arguments should match the arguments to
the package procedure.
e Add a trigger so that the data in the Ord_Sum block is updated when
the list box value changes.
Hint: You need to execute a query in the Ord_Sum block.
......................................................................................................................................................
Developer/2000: Build Forms II 9-31
Lesson 9: Defining Data Sources
......................................................................................................................................................
5 Save and run your form. Observe the behavior of the record count in the
console and the scrollbar as you scroll through the records. What do you
deduce from this?
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
9-32 Developer/2000: Build Forms II
Working with Record
................................
Groups
10
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Lesson 10: Working with Record Groups
......................................................................................................................................................
Objectives
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
10-2 Developer/2000: Build Forms II
Introduction
......................................................................................................................................................
Introduction
Overview
Record groups are useful constructs for storing structured data, and they can
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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 will
also cover 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:
• Create record groups at design time
• Create and modify record groups programmatically
• Build dynamic list items by using record groups
• Apply record groups in other useful ways
• Create and use a global record group to communicate between forms
......................................................................................................................................................
Developer/2000: Build Forms II 10-3
Lesson 10: Working with Record Groups
......................................................................................................................................................
Record Groups
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Record Groups
• Record groups and LOVs
– Forms implicitly creates query record
groups
– Use SET_LOV_PROPERTY to replace
default record group
...
IF Get_LOV_Property(lov_id,GROUP_NAME) = ’GROUP1’
THEN
Set_LOV_Property(lov_id,GROUP_NAME, ’GROUP2’);
END IF;
...
......................................................................................................................................................
10-4 Developer/2000: 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
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 10-5
Lesson 10: Working with Record Groups
......................................................................................................................................................
......................................................................................................................................................
10-6 Developer/2000: Build Forms II
Using Record Groups
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Constructing Dynamic SELECT Statements
The SELECT statement on which a query record group is based can be
constructed programmatically at run-time. As a consequence, you can write
very generic program units; for example, accepting a table name as
parameter.
......................................................................................................................................................
Developer/2000: Build Forms II 10-7
Lesson 10: Working with Record Groups
......................................................................................................................................................
......................................................................................................................................................
10-8 Developer/2000: Build Forms II
Defining Record Groups at Design Time
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Forms displays the New Record Group dialog box.
2 Click the Based on the Query Below... radio button and then enter a
SELECT statement in the Query Text field.
3 Click OK.
Forms validates the SELECT statement and closes the dialog box.
Note: Use column aliases for expressions in the SELECT clause.
Otherwise, Forms will generate an unreadable name for the corresponding
column of the record group.
......................................................................................................................................................
Developer/2000: Build Forms II 10-9
Lesson 10: Working with Record Groups
......................................................................................................................................................
CREATE_GROUP CREATE_GROUP_FROM_QUERY
Record Record
ID Name
group ID group ID
DELETE_GROUP
10-8 Copyright Oracle Corporation, 1998. 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
10-9 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
10-10 Developer/2000: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Creating and Deleting Record Groups
Built-in Function Description
CREATE_GROUP Creates a non-query record group with the given
name and returns the ID of this record group
CREATE_GROUP_FROM_QUERY Creates a query record group with the given
name based on the given SELECT statement and
returns the ID of this record group (Note that
this built-in function does not populate the
record group.)
DELETE_GROUP Deletes the given, programmatically created,
record group
......................................................................................................................................................
Developer/2000: Build Forms II 10-11
Lesson 10: Working with Record Groups
......................................................................................................................................................
ID Name
SET_GROUP_CHAR_CELL
GET_GROUP_NUMBER_CELL
Technical Note
POPULATE_GROUP returns 0 when population succeeds and returns 1 if it
does not succeed.
......................................................................................................................................................
10-12 Developer/2000: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
query record group and returns a number
indicating success or failure (The retrieved
rows replace any existing rows in the record
group.)
POPULATE_GROUP_WITH_QUERY Executes the specified SELECT statement for
the given record group and returns a number
indicating success or failure (The retrieved
rows replace any existing rows in the record
group.)
SET_GROUP_CHAR_CELL, Sets the value for the record group cell
SET_GROUP_DATE_CELL, identified by the given record group column
SET_GROUP_NUMBER_CELL and row number (The record group column
must be of data type VARCHAR2 or LONG,
DATE, or NUMBER, respectively.)
Note: You can convert a non-query record group into a query record group
by using the POPULATE_GROUP_WITH_QUERY built-in function to
populate the non-query record group.
......................................................................................................................................................
Developer/2000: Build Forms II 10-13
Lesson 10: Working with Record Groups
......................................................................................................................................................
GET_
GROUP_
SET_GROUP_SELECTION ROW_
GET_GROUP_SELECTION COUNT
10-12 Copyright Oracle Corporation, 1998. All rights reserved.
......................................................................................................................................................
10-14 Developer/2000: Build Forms II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
record group
SET_GROUP_SELECTION Marks the specified row in the given record
group by associating a selection number with
the row
UNSET_GROUP_SELECTION Deselects the row with the specified row num-
ber in the given record group
RESET_GROUP_SELECTION Deselects all selected rows in the given record
group
GET_GROUP_SELECTION_COUNT Returns the number of selected rows in the
given record group
GET_GROUP_SELECTION Returns the row number of the row with the
specified selection number of the given record
group
......................................................................................................................................................
Developer/2000: Build Forms II 10-15
Lesson 10: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
Populate group
......................................................................................................................................................
10-16 Developer/2000: Build Forms II
Defining Query Record Groups Programmatically
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Note: The query record groups can also be defined at design time.
DECLARE
v_rg_id RECORDGROUP;
v_errcode NUMBER;
BEGIN
--Make sure that record group doesn’t already exist.
v_rg_id := FIND_GROUP(’customers’);
IF ID_NULL(v_rg_id) THEN
--Create query record group.
v_rg_id := CREATE_GROUP_FROM_QUERY(’customers’,
’SELECT id, name FROM s_customer ORDER BY id’);
END IF;
--Populate query record group with associated query.
v_errcode := POPULATE_GROUP(v_rg_id);
END;
You can replace the associated query of a query record group by calling the
POPULATE_GROUP_WITH_QUERY built-in function.
v_errcode := POPULATE_GROUP_WITH_QUERY(v_rg_id,
’SELECT id, name FROM s_customer
where region_id = 1 ORDER BY id’);
......................................................................................................................................................
Developer/2000: Build Forms II 10-17
Lesson 10: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
......................................................................................................................................................
10-18 Developer/2000: Build Forms II
Defining Non-Query Record Groups Programmatically
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
design time.
DECLARE
v_rg_id RECORDGROUP;
v_gc1_id GROUPCOLUMN;
v_gc2_id GROUPCOLUMN;
BEGIN
--Make sure that record group doesn’t already exist.
v_rg_id := FIND_GROUP(’customers’);
IF ID_NULL(v_rg_id) THEN
--Create non-query record group.
v_rg_id := CREATE_GROUP(’customers’);
--Add NUMBER and CHAR group column to record group.
v_gc1_id := ADD_GROUP_COLUMN(v_rg_id,’id’,number_column);
v_gc2_id := ADD_GROUP_COLUMN(v_rg_id,’name’,char_column,50);
ELSE
--Delete all existing group rows.
DELETE_GROUP_ROW(v_rg_id,all_rows);
--Find ids of group columns for later use.
v_gc1_id := FIND_COLUMN(’customers.id’);
v_gc2_id := FIND_COLUMN(’customers.name’);
END IF;
--Add one group row to record group.
ADD_GROUP_ROW(v_rg_id,1);
--Fill r g cells of group row 1 with item values.
SET_GROUP_NUMBER_CELL(v_gc1_id,1,:cus.id);
SET_GROUP_CHAR_CELL(v_gc2_id,1,:cus.name);
END;
You can convert the non-query record group into a query record group by
calling the POPULATE_GROUP_WITH_QUERY built-in function.
......................................................................................................................................................
Developer/2000: Build Forms II 10-19
Lesson 10: Working with Record Groups
......................................................................................................................................................
Cell value=
For all Given value
group Yes No
rows
Return row
number
Return NULL
......................................................................................................................................................
10-20 Developer/2000: Build Forms II
Manipulating Record Group Rows
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
FUNCTION get_value_grprow
/* Returns row number of group row that contains the
specified
value in the given group column.
Returns NULL if the value is not found. */
( p_rg_id in RECORDGROUP,p_gc_id in GROUPCOLUMN,
p_value in VARCHAR2)
RETURN number IS
v_grprow_count NUMBER;
BEGIN
v_grprow_count := GET_GROUP_ROW_COUNT(p_rg_id);
FOR v_grprow_no IN 1 .. v_grprow_count LOOP
IF GET_GROUP_CHAR_CELL(p_gc_id,v_grprow_no) = p_value THEN
RETURN(v_grprow_no);
END IF;
END LOOP;
RETURN(null);
END;
......................................................................................................................................................
Developer/2000: Build Forms II 10-21
Lesson 10: Working with Record Groups
......................................................................................................................................................
Row number
For all even?
group Yes No
rows
Mark row
as selected
......................................................................................................................................................
10-22 Developer/2000: Build Forms II
Manipulating Selected Record Group Rows
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
PROCEDURE select_even_rows
--Marks all group rows with even row numbers as selected.
(p_rg_id in RECORDGROUP)
IS
v_grprow_count NUMBER;
BEGIN
v_grprow_count := GET_GROUP_ROW_COUNT(p_rg_id);
FOR v_grprow_no IN 1 .. v_grprow_count LOOP
IF MOD(v_grprow_no,2) = 0 THEN
SET_GROUP_SELECTION(p_rg_id,v_grprow_no);
END IF;
END LOOP;
END;
The function below illustrates how you can loop through all selected rows of
a record group.
FUNCTION get_value_grpsel
/* Returns selection number of selected group row
that contains the specified value in the given group
column. Returns NULL if the value is not found. */
(p_rg_id in RECORDGROUP
,p_gc_id in GROUPCOLUMN
,p_value in VARCHAR2)
RETURN NUMBER IS
v_grpsel_count NUMBER;
v_grprow_no NUMBER;
BEGIN
--Only loop through the selected group rows.
v_grpsel_count := GET_GROUP_SELECTION_COUNT(p_rg_id);
FOR v_grpsel_no IN 1 .. v_grpsel_count LOOP
--Get row number of selected row.
v_grprow_no := GET_GROUP_SELECTION(p_rg_id,v_grpsel_no);
IF GET_GROUP_CHAR_CELL(p_gc_id,v_grprow_no) = p_value THEN
RETURN(v_grpsel_no);
END IF;
END LOOP;
RETURN(null);
END;
......................................................................................................................................................
Developer/2000: Build Forms II 10-23
Lesson 10: 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 non query record group.
Actually, it retains its data, but a subsequent POPULATE_GROUP is
considered an error.
......................................................................................................................................................
10-24 Developer/2000: Build Forms II
Defining Global Record Groups
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
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.
......................................................................................................................................................
Developer/2000: Build Forms II 10-25
Lesson 10: Working with Record Groups
......................................................................................................................................................
• ADD_LIST_ELEMENT
• DELETE_LIST_ELEMENT
• CLEAR_LIST
• GET_LIST_ELEMENT_LABEL
• GET_LIST_ELEMENT_VALUE
• GET_LIST_ELEMENT_COUNT
• POPULATE_LIST
• RETRIEVE_LIST
10-18 Copyright Oracle Corporation, 1998. All rights reserved.
POPULATE_LIST RETRIEVE_LIST
CHAR Column 1 CHAR Column 2
......................................................................................................................................................
10-26 Developer/2000: Build Forms II
Manipulating List Items Programmatically
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
items programmatically at run-time by using built-in functions. Some of
these functions require the use of record groups.
Built-in Function Description
ADD_LIST_ELEMENT Adds a list element (label and value) at the speci-
fied position (index) to the given list item
CLEAR_LIST Clears all list elements from the given list item
(After clearing, the list item will only contain the
null element.)
DELETE_LIST_ELEMENT Deletes the list element at the specified position
(index) from the given list item
GET_LIST_ELEMENT_COUNT Returns the number (in CHAR format) of list ele-
ments in the given list item, including list elements
with NULL values
GET_LIST_ELEMENT_LABEL Returns the label of the list element at the specified
position (index) in the given list item
GET_LIST_ELEMENT_VALUE Returns the value of the list element at the specified
position (index) in the given list item
POPULATE_LIST Clears the given list item and populates the list item
with the values from the specified record group
RETRIEVE_LIST Retrieves the list elements (labels and values) from
the given list item and stores them in the specified
record group
......................................................................................................................................................
Developer/2000: Build Forms II 10-27
Lesson 10: Working with Record Groups
......................................................................................................................................................
Yes ID NULL? No
Populate group
Yes Success? No
Populate list
......................................................................................................................................................
10-28 Developer/2000: Build Forms II
Implementing Dynamic List Items
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Note: The retrieved rows are transferred to the list item by way of a record
group.
PROCEDURE populate_list_with_query
--Populates the given list item with the specified query.
(p_list_item in VARCHAR2
,p_query in VARCHAR2)
IS
/* Name the record group after the list item (no
block prefix). */
cst_rg_name constant VARCHAR2(30) :=
GET_ITEM_PROPERTY(p_list_item,item_name);
v_rg_id RECORDGROUP;
BEGIN
v_rg_id := FIND_GROUP(cst_rg_name);
IF ID_NULL(v_rg_id) THEN
v_rg_id := CREATE_GROUP_FROM_QUERY(cst_rg_name,p_query);
END IF;
IF POPULATE_GROUP(v_rg_id) = 0 THEN
POPULATE_LIST(p_list_item,v_rg_id);
/* Force display of first list element label
in the list item. */
COPY(GET_LIST_ELEMENT_VALUE(p_list_item,1),p_list_item);
END IF;
END populate_list_with_query;
BEGIN
POPULATE_LIST_WITH_QUERY(’ord.customer_id’,
’SELECT name, to_char(id) FROM s_customer ORDER BY name’);
END;
Note: In this example, the customer name is the (visible) list label and the
customer ID is the (actual) list value.
......................................................................................................................................................
Developer/2000: Build Forms II 10-29
Lesson 10: Working with Record Groups
......................................................................................................................................................
Element value=
For all Item value?
list Yes No
elements
Return
......................................................................................................................................................
10-30 Developer/2000: Build Forms II
Adding Values to Combo Boxes
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
can be automatically added to the list of existing values of a combo box.
Note: The added list elements are lost when you exit from the form.
PROCEDURE add_combo_box_element
/* Adds a new list element at the end of the given combo-box list
if it is not already present in the combo-box list. */
(p_list_item in VARCHAR2)
IS
v_listel_count NUMBER;
BEGIN
/* First check if current list-item value is already present
in list. */
v_listel_count := GET_LIST_ELEMENT_COUNT(p_list_item);
FOR v_listel_idx IN 1 .. v_listel_count LOOP
IF GET_LIST_ELEMENT_VALUE(p_list_item, v_listel_idx)
= UPPER(NAME_IN(p_list_item)) THEN
RETURN;
END IF;
END LOOP;
/* Current list-item value not found in list;
add new list element at end of list. */
ADD_LIST_ELEMENT(p_list_item, v_listel_count + 1,
INITCAP(NAME_IN(p_list_item)),UPPER(NAME_IN(p_list_item)));
END;
BEGIN
ADD_COMBO_BOX_ELEMENT(:SYSTEM.TRIGGER_ITEM);
END;
......................................................................................................................................................
Developer/2000: Build Forms II 10-31
Lesson 10: Working with Record Groups
......................................................................................................................................................
Summary
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Summary
......................................................................................................................................................
10-32 Developer/2000: Build Forms II
Summary
......................................................................................................................................................
Summary
A record group is an internal Forms data structure that is similar to a
database table.
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
Three Record Group Types
• Query record group
• Non-query record group
• Static record group
......................................................................................................................................................
Developer/2000: Build Forms II 10-33
Lesson 10: Working with Record Groups
......................................................................................................................................................
Practice 10 Overview
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
......................................................................................................................................................
10-34 Developer/2000: Build Forms II
Practice Session Overview: Lesson 10
......................................................................................................................................................
Practice Contents
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
• 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.
......................................................................................................................................................
Developer/2000: Build Forms II 10-35
Lesson 10: Working with Record Groups
......................................................................................................................................................
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 run-time, using the design-
time query record group. You can import the pr10_1e.txt file.
f Call the procedure each time a new record is created. You can import
the pr10_1f.txt file.
If you have time...
2 Create a multi-record select list form. This practice shows how to create
a list of values where the user can select multi-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.
......................................................................................................................................................
10-36 Developer/2000: Build Forms II
Practice Session: Lesson 10
......................................................................................................................................................
These materials are protected by copyright and may not be copied or duplicated for any purpose except as specified in the Oracle Academic Initiative Program Agreement.
This form also contains an OK button and a Cancel button without
any code.
This form contains two visual attributes called DESELECTED and
SELECTED.
d Create a When-Mouse-Click trigger at the PROD_LOV_BLK block
level that selects or deselects a record when a user presses Ctrl+Click
for a product.
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 retrieve the internal
ID for each column in the record group.
Write the code to check whether the record selected is already in the
record group. If so, loop through each item in the record to keep the
visual attribute from being highlighted, and then remove the record
from the record group.
If the user selects a record that was not already in the group, write the
code to add the record to the record group and loop through each
item in the block to keep the color highlighted.
Use the SELECTED and DESELECTED visual attributes in your
code to change the color of a selected or deselected record.
You can import the pr10_2d.txt file.
e Create the code for the OK button. This button enables the user to
exit the form.
f Create the code for the CANCEL button in the PROD_LOV_BLK
block.
Create a When-Button-Pressed trigger that deletes the record group
before returning to the ITEM block. You can import the pr10_2f.txt
file.
g In the ORDERS form, modify the When-Button-Pressed trigger for
the CONTROL.PRODUCT_LOV_BUTTON. The new code should
check the existing products in the S_ITEM block, so that products
already ordered do not show up in the list. It then calls the
PROD_LOV_BLK form, passing the list of existing products using a
GLOBAL variable. You can import the pr10_2g.txt file.
......................................................................................................................................................
Developer/2000: Build Forms II 10-37
Lesson 10: Working with Record Groups
......................................................................................................................................................
......................................................................................................................................................
10-38 Developer/2000: Build Forms II