You are on page 1of 346

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

Volume 1 • Student Guide


...........................................................................................

44111GC10
Production 1.0
January 1998
M06178
Author Copyright  Oracle Corporation, 1998. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It is


Pascal Gibert
provided under a license agreement containing restrictions on use and disclosure
and is also protected by copyright law. Reverse engineering of the software is
prohibited. If this documentation is delivered to a U.S. Government Agency of the
Department of Defense, then it is delivered with Restricted Rights and the
following legend is applicable:
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
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.

Practice Session Overview: Lesson 2 2-35


Practice Session: Lesson 2 2-36
Lesson 3: Managing Menu Modules
Introduction 3-3
Using PL/SQL in Menu Item Code 3-5
Useful Built-in Menu Subprograms 3-7
Showing and Hiding the Current Menu 3-9
Substitution Parameters 3-11
Defining a User-Named Substitution Parameter 3-13
Substitution Parameter Built-ins 3-15
Validating a Substitution Parameter Value 3-17
Managing Menu Security 3-19
Defining Security Roles 3-21
Assigning Access to Menu Items 3-23
Summary 3-25
Practice Session Overview: Lesson 3 3-27
Practice Session: Lesson 3 3-28
Lesson 4: Programming Function Keys
Introduction 4-3
Key Triggers 4-5
Defining Key Triggers 4-7
Characteristics of Key Triggers 4-9
Classification of Key Triggers 4-11
Using Key Triggers 4-15
Association with Other Interface Controls 4-17
Summary 4-19
Practice Session Overview: Lesson 4 4-21
Practice Session: Lesson 4 4-22
Lesson 5: Responding to Mouse Events
Introduction 5-3
What Are Mouse Events? 5-5
Responding to Mouse Movement 5-7
Responding to Mouse Button Actions 5-11
Summary 5-17
Practice Session Overview: Lesson 5 5-19
Practice Session: Lesson 5 5-20

......................................................................................................................................................
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.

Practice 12 Solution A-50


Practice 13 Solution A-54
Practice 14 Solution A-57
Appendix B: Table Descriptions and Data
Summit Sporting Goods Database Diagram B-2
S_CUSTOMER Description B-3
S_CUSTOMER Data B-4
S_DEPT Description and Data B-8
S_EMP Description B-9
S_EMP Data B-10
S_IMAGE Description and Data B-13
S_INVENTORY Description B-14
S_INVENTORY Data B-15
S_ITEM Description B-19
S_ITEM Data B-20
S_ORD Description and Data B-22
S_PRODUCT Description B-23
S_PRODUCT Data B-24
S_REGION Description and Data B-28
S_TITLE Description and Data B-29
Appendix C: Project Builder Addendum
Introduction C-3
Creating Connections C-5
Team Development with Project Builder C-7
Generating and Printing Project Reports C-13
Summary C-15
Appendix D: Oracle Terminal 2 and Developer/2000 Forms
Appendix E: Using Oracle Server Roles at Run Time
Using Oracle Server Roles at Run Time E-3
Appendix F: EMP_PKG Package
Package Specification F-2
Package Body F-4
Appendix G: Implementing Online Help Reusable Component
Introduction G-3
The Online Help Class G-5
Creating the Database Objects G-7
Creating Online Help Content G-9

......................................................................................................................................................
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

Suggested Follow-Up Courses


• Developer/2000: Build Reports
• Developer/2000: Deploy Web-Based Applications
• Designer/2000: Design and Generate Developer/2000 Applications

How This Course Is Organized


Developer/2000: Build Forms II is an instructor-led course featuring lectures
and hands-on exercises. Online demonstrations and written practices
reinforce the concepts and skills introduced.

......................................................................................................................................................
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.

Title Part Number


Developer/2000 Guidelines for Building Application Release 2 A50994-1
Developer/2000 Getting Started Release 2 A50995-1

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

Uppercase Commands, func- Use the SELECT command to view information


tions, stored in the LAST_NAME column of the EMP
column names, table.
table names,
PL/SQL objects,
schemas

Lowercase, italic Filenames roleis the name of the role to be created.


syntax variables,
usernames,
passwords

Initial cap Triggers and button Assign a When—Validate—Item trigger to the


names ORD block.

Press Cancel.

Italic Books, names of For further information on the subject see:


courses and manuals, Oracle7 Server SQL Language Reference Man-
and emphasized ual.
words or phrases

Do not save changes to the database.

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
......................................................................................................................................................

Typographic Conventions Within Code


The following conventions are used in code:

Convention Object or Term Example


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.

Uppercase Commands, func- SELECT userid


tions FROM emp;

Lowercase, Syntax variables CREATE ROLE role


italic

Initial cap Oracle Forms trig- Form module: ORD


gers Trigger level: S_ITEM.QUANTITY item
Trigger name When-Validate-Item
...
Lowercase Column names, ...
table name, OG_ACTIVATE_LAYER
filenames, PL/SQL
objects (OG_GET_LAYER (‘prod_pie_layer’))
...

SELECT last_name
FROM s_emp;

DROP USER scott


IDENTIFIED BY tiger;

......................................................................................................................................................
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.

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
I-2 Copyright  Oracle Corporation, 1998. All rights reserved.

Course Objectives

• Exploit Oracle Server features in


applications
• Code triggers that respond to:
– Mouse movement and mouse button
actions
– Window manipulation
• Create and manage multiple form
applications
• Choose appropriate data sources for
data blocks
I-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

I-4 Copyright  Oracle Corporation, 1998. All rights reserved.

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-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

be able to do the following:


• List benefits of using Project Builder
• Create projects and subprojects
• Add files to a project
• Distinguish between implicit and explicit
dependencies
• Describe the Compile options
• Deliver a project
• Customize the Project Builder
environment
1-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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
......................................................................................................................................................

Project Builder 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.

1-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-4 Developer/2000: Build Forms II
Introducing Project Builder
......................................................................................................................................................

Introducing Project Builder


Project Builder Overview
For developers working in large, complex projects, managing the files that

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
......................................................................................................................................................

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 Collection of components
Subproject Projects contained within other projects

Project Entry Representation of project items in the


Project Navigator
Registry Storehouse of information
Type Category of files
Action Command string
Macro Variable to customize and extend actions

1-4 Copyright  Oracle Corporation, 1998. All rights reserved.

Project Builder Terminology


Project Subproject Subproject

Project Project Project


entries entries entries

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
......................................................................................................................................................

Project Builder Terminology


Project Builder is based upon the concepts of 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.
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
......................................................................................................................................................

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.

• View all files associated with an


application in a common Navigator
• Automate actions
• Share projects among team members
• Define commonly used connect strings
• Deliver your application to end users

1-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-8 Developer/2000: Build Forms II
Project Builder Benefits
......................................................................................................................................................

Project Builder Benefits


Project Builder helps ease the burden of managing large, complex
applications.

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.

Sharing Projects Among Team Members


Common storage areas, called registries, allow developers to share
information about projects.

Defining Commonly Used Connect Strings


With Project Builder, you can define all your most-used database connect
strings and store their definitions under the Connections node. You can then
assign a connection to projects, subprojects, types, or individual files by
dragging the connection from the Connections node and dropping it on the
desired project, subproject, type, or individual file.

Delivering Application to End Users


Project Builder is an uncomplicated, four-step process for packaging your
application for end users. You have the option of delivering your entire
application, or only delivering those files which have been updated from
previous release.

......................................................................................................................................................
Developer/2000: Build Forms II 1-9
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

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.

1-7 Copyright  Oracle Corporation, 1998. All rights reserved.

1 Launcher 3 Pop-up menu


2 Project Navigator 4 Property Palette

......................................................................................................................................................
1-10 Developer/2000: Build Forms II
Project Builder User Interface
......................................................................................................................................................

Project Builder User Interface


Project Builder has four main components: the Project Navigator, the pop-up
menus, the Property Palette, and the Launcher toolbar.

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 Pop-Up Menus


The pop-up menus are very useful to launch actions against entries from the
Project Navigator.
1 Select the entry.
2 Click the right mouse button.
3 Select one of the available actions shown in the pop-up menu.
Note: You can add the commands you consider most useful to the type-
specific pop-up menus available from the Project Navigator.

The Property Palette


Project Builder has the Property Palette for connections, types, entries, and
projects. In the Property Palettes, the user can view and modify properties,
actions, and macros. The user can also add new actions and macros to types,
entries, and projects.

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
......................................................................................................................................................

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.

1-8 Copyright  Oracle Corporation, 1998. All rights reserved.

Specifying User Defaults

1-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-12 Developer/2000: Build Forms II
Creating Projects and Subprojects
......................................................................................................................................................

Creating Projects and Subprojects


A project is a collection of pointers to the files that make an application, and
the project registry file is the physical file in which this information is stored.

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.

The Project Wizard


The Project Wizard provides an easy-to-use interface for creating a project.
To create a project using the Project Wizard, click the Project Wizard icon
on the toolbar and:
• Define the project.
• Specify user defaults.
• Add files to the project.
You can also create a new project without the Project Wizard by using the
New Project tool available on the toolbar and setting project properties in the
Property Palette.

Defining the Project


In the Project Wizard, you can choose to:
• Create a standalone project (the default)
• Create a subproject, a project that is part of a larger project
At this step, you must:
• Name your project.
• Select a default directory for the project registry file.
• Name the project registry file.

Specifying User Defaults


Next, you can specify:
• The Author of the project
• A default connection to datasource with your project information. This
connection will apply to all files within your project unless overridden
• Any comments that you want to add
Note: This information is optional, but can be used to identify and
document your projects in a team development environment.

......................................................................................................................................................
Developer/2000: Build Forms II 1-13
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

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.

• Add files through the Project Wizard.


• Add files to a project at any later time.
• Specify that implicit
components be
added to the
project
automatically.

1-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-14 Developer/2000: Build Forms II
Adding Project Files
......................................................................................................................................................

Adding Project Files


Accepting the Project Wizard
The last step allows you to either add files to your project from within 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.
Project Wizard (the default), or create an empty project. When you select
Finish, the Project Wizard creates your new project.

The Add Files Dialog Box


If you choose to add files to your project from within the Project Wizard,
you can immediately select files to be included as entries in your project.
You can also add other components at any later time.
Note: The dialog box always inserts the full path unless the module you
want to add is in the project directory.
In all other instances, the dialog box forces a full path. In that case, you can
change it manually to the relative path by:
• Selecting the item (for example, a subproject) in the Project Navigator
• Displaying the Property Palette
• Editing the Filename property

......................................................................................................................................................
Developer/2000: Build Forms II 1-15
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

Working with Project Files


• Open and edit 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 connect strings


• Add, modify, or remove files and types
• Add dependencies manually
• Edit file properties
• Define actions for types, or override the
actions
• Compile the project
• Package the project

1-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-16 Developer/2000: Build Forms II
Working with Project Files
......................................................................................................................................................

Working with Project Files


When your project is set up, you can use Project Builder to:
• Open and edit the 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.

Deduces dependencies from


• Deliverable Type property
• Build From <type> action
Example
Type FMB-Form Builder document
Deliverable Type FMX-Form Builder executable
Build From FMB ..\bin\f50gen32 ...

1-12 Copyright  Oracle Corporation, 1998. All rights reserved.

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-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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-14 Copyright  Oracle Corporation, 1998. All rights reserved.

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:

Compile Option Description


Compile Selection Select one or more files in the Project Navigator, and choose Com-
pile Selection from the Project menu. Project Builder recompiles
the selected files only.
Compile Incremental To compile modified files only, choose Compile Incremental from
the Project menu, or the equivalent toolbar button. Project Builder
automatically determines which files need to be built, by examin-
ing the file timestamps to determine which files have been modi-
fied, and rebuilding those files that are out of date.
Compile All To compile all files in the project, select the project in the Project
Navigator and choose Compile All. Project Builder compiles all
files, regardless of whether you have modified them since the previ-
ous compilation.

......................................................................................................................................................
Developer/2000: Build Forms II 1-21
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

Delivering the Project


• Set the Deliver File property
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.

– Specifies components that are the


deliverables
– Examples: .fmx files, .plx files, icons
• Specify the Deliver the Selected File(s)
action
– Defines how to package a deliverable
file
– Examples: PkZip, WinZip, Tar

1-15 Copyright  Oracle Corporation, 1998. All rights reserved.

Delivering the Project


• Set the PACKFILE macro
– Specifies the name of the .zip or .tar
file
• Deliver the project
– Choose
File—>Administration—>Deliver.
– Project Builder packages the files
based on the Deliver the Selected
File(s) action.

1-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

The Deliver File Property


To simplify this task, Project Builder includes the Deliver File property,
which allows you to indicate which entries represent files to be delivered, or
deployed, to the end user.
Usually the Deliver File property will be inherited from the type but, for
some files this may not be appropriate. In this case, you can simply override
the setting on individual entries, as with any other property. Alternatively,
you might choose to organize all the deliverables into a separate subproject,
and then set the Deliver File property on that subproject to Yes, which will
then be inherited by all the files in the subproject.

The PACKFILE Macro


Before packaging your files, you must define the PACKFILE macro to be the
name of the .zip or .tar file that is the result of the Deliver action.

Deliver the Project


To deliver the project, select File––>Administration––>Deliver from the
Project Builder menu.
Project Builder will apply the appropriate Package for delivery action to
each file. These actions will usually be defined to accept “multiple files”; for
example, if many entries have PkZip defined as the action, you usually do
not want to run PkZip once for each file. Instead, Project Builder runs PkZip
once, passing all of the files to it at one time.

......................................................................................................................................................
Developer/2000: Build Forms II 1-23
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

Practice 1-1 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.

• Creating an initial project


• Experimenting with the different Project
Navigator views
• Creating subprojects and adding items
to them

1-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-24 Developer/2000: Build Forms II
Practice Session Overview: Lesson 1-1
......................................................................................................................................................

Practice Session Overview: Lesson 1-1


This practice guides you through creating projects using Project Builder.

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
......................................................................................................................................................

Practice Session: Lesson 1


1 Create a connection to the database.
Create a new connection.
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.

b Name the connection “SUMMIT” and specify the connect string.


Your instructor should provide this information.
2 Create an initial project.
a Create a new project (use the Project Wizard).
b Name the project “Developer/2000: Build Forms II.” Assign to this
project the connection created earlier, and save it as summit.upd in
the Labs directory.
Note: Do not add files to this project.
3 Create a subproject and add files to it.
a Using the Project Wizard, create a subproject named “Summit
Application” that belongs to Developer/2000: Build Forms II.
b From the labs directory, add:
- all the .tif files
- all the .txt files
- all the .sql files
- all the .ico files
- all the .pll files
- all the .rdf files
- the .olb file
- the customers.fmb, orders.fmb, and employees.fmb files.
c Give some of the file items more useful titles.
4 Explore the Project Navigator.
a Examine the state of the Project Navigator. Note that Project Builder
has added executable versions of the Oracle source files that you
added to the project.
b Turn off the “Show implicit items” option. Note what happens to the
Project Navigator display.
c Experiment with the different views of Project Builder.

......................................................................................................................................................
1-26 Developer/2000: Build Forms II
Practice Session: Lesson 1
......................................................................................................................................................

5 Deliver the project.


aSelect all your files (except the source files like .fmb, .pll, .txt, and so
on), and make sure that the “Deliver File” property is set to Yes.
b Select the Summit Application subproject, and define 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.
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
......................................................................................................................................................

Inheritance in Project Builder


• Actions and macros can be defined 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.

types, projects, and components.


• Type action and macro definitions can
be overridden by the project or the
component.
• Every component also Type
inherits from the
<Any File> type. Project
• In Windows 95 and NT, file
type definitions are also Component
automatically inherited.
1-18 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Inheritance in Project Builder


Inheritance Overview
The Property Palette shows not only the properties, actions, and macros, but

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
......................................................................................................................................................

Defining New File Types


1. Choose File—>New—>Type
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. Enter details or select an example file.

1-19 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-30 Developer/2000: Build Forms II
Defining New Types
......................................................................................................................................................

Defining New Types


To define a new file type, select File––>New––>Type and specify the
following:

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

1-20 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

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.

• Actions can be
defined for a type,
project, or
components through
the Property Palette.
• Action definitions
often use macros.

1-21 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Modifying Types Using Actions


You can change or add new actions:
1 In the Project Navigator, select the type or object you wish to modify.

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
......................................................................................................................................................

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.

Simple macros
• myprinter = “ HPLASER_01”
Built-in macros
• n = Full filename
Predefined macros
• D2KEDITOR = {EDITOR ? {EDITOR} :
notepad}

1-22 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-36 Developer/2000: Build Forms II
Customizing Actions Using Macros
......................................................................................................................................................

Customizing Actions Using Macros


If an action needs to include special parameters, you can customize the
action with a macro. Project Builder provides several macros for you to

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
......................................................................................................................................................

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.

Macros can:
• Be defined for each
object through the
Property Palette
• Be conditional
• Reference other macros

1-23 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-38 Developer/2000: Build Forms II
Customizing Actions Using Macros
......................................................................................................................................................

Defining and Using a Macro


To define a macro, use the Add Macro dialog box to name your macro and
equate it to the string you want to execute when you use the macro.
To use a macro, insert the macro name, enclosed by braces, in the string

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
......................................................................................................................................................

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.

1-24 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-40 Developer/2000: Build Forms II
Customizing the Launcher
......................................................................................................................................................

Customizing the Launcher


You can add your own tools to the Launcher, change the organization of the
existing tools, by dragging and dropping, edit existing entries and remove

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.

Adding Launcher Icons


1 Choose Tools—>Preferences—>Launcher tab.
2 Click Add.
The Add Launcher Entry dialog box is displayed.
3 Enter the full pathname of the application, or click Insert Application to
browse your file system.
4 Enter the label that you want to display as the button text.
5 Select Icons Only to display this label as a tooltip, or select Icons and
Text to display the label below the icon in the Launcher.

Editing Launcher Icons


1 Choose Tools—>Preferences—>Launcher tab.
2 Select the node for the icon you want to change.
3 Click Edit.
4 Make the necessary changes to the Launcher entry.

......................................................................................................................................................
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.

• Project Builder basics


• Building a project
• Customizing the Project Builder
environment

1-25 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

Customizing the Project Builder Environment


• Customize the Launcher
• Describe inheritance and macros
• Add types, actions, and macros
Note: For additional information about Project Builder, see Appendix C.

......................................................................................................................................................
Developer/2000: Build Forms II 1-43
Lesson 1: Managing Projects with Project Builder
......................................................................................................................................................

Practice 1-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.

• Creating new types and actions


• Enabling Project Builder to act upon .sql
files
• Customizing the Launcher

1-26 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
1-44 Developer/2000: Build Forms II
Practice Session Overview: Lesson 1-2
......................................................................................................................................................

Practice Session Overview: Lesson 1-2


This practice guides through creating projects using Project Builder.

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
......................................................................................................................................................

Practice Session: Lesson 1


1 Create new types.
Add an Icon file type to Project Builder. Derive the type information
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.

from the list.ico file. This type is deliverable.


b Add a Tif file type to Project Builder. Derive the type information
from the Aceboot.tif file. This type is deliverable.
c Add a SQL file type to Project Builder. Derive the type information
from the Setup1.sql file. This type is not deliverable.
d Add an OLB file type to Project Builder. Derive the type information
from the Form_Builder_II.olb file. This type is deliverable.
2 Create a new action.
a Add a “Run script” action for the SQL file type. Enter SQL*PLUS
into the Name Field and add an appropriate description (for example:
Run Script). The action definition is:

Plus33w.exe {ORACONNECT} @{n}

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.

be able to do the following:


• Identify the different components of a
menu
• Create, save, and attach menu modules
• Set menu properties using the property
palette
• Create menu toolbars
• Create pop-up menus
2-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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
......................................................................................................................................................

Components of the Menu


Menu item 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.

Main
Individual menu Menu toolbar
menu
2-3 Copyright  Oracle Corporation, 1998. All rights reserved.

Hierarchical Structure of a Menu

Menu
Module

Individual Menu Menu Individual


menu item item menu

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
......................................................................................................................................................

Components of the Menu Module


What Is a Menu Module?
A menu module is a hierarchically structured object that provides a quick

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

What Is a Menu Item?


A menu item is an option that you can choose from a menu. Each menu item
has an associated command that enables the user to perform an action.

What Is a Menu Toolbar?


A menu toolbar is a toolbar of iconified buttons that represent some
individual items from your form menu. For a menu module, you can have a
vertical and a horizontal menu toolbar.

......................................................................................................................................................
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

2-5 Copyright  Oracle Corporation, 1998. All rights reserved.

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 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

What Is a Pull-Down Menu?


A pull-down menu comprises a set of options, displayed horizontally under
the application window title. Each option can represent a submenu or an
action. Selecting a submenu displays a vertical list. Selecting an action
executes the action.

What Is a Full-Screen Menu?


A full-screen menu displays each menu in a separate window. Only the
current item is highlighted, and the Enter Your Choice field contains the
chosen menu item number. Full-screen menus are commonly used in
character-mode applications and are rarely used for bitmapped applications.

What Is a Bar Menu?


A bar menu displays options horizontally under the application window title
line, but unlike the pull-down menu, when you select an item, the submenu
replaces the previous one, horizontally.

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.

Action Edit Query Block Record Field Help

Save Cut Enter Previous Previous Previous Help


Clear All Copy Execute Next Next Next Keys
Print Paste Cancel Clear Scroll Up Clear List
Print Edit Last Scroll Duplicate Display
Setup Display Criteria Down Error
Exit List Count Insert Debug
Hits Remove
Fetch Lock
Next Duplicate
Set Clear

2-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-8 Developer/2000: Build Forms II
The Default Menu
......................................................................................................................................................

The Default Menu


What Is the Default Menu?
The Default menu is not a separate menu module and is built in to every

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.

Examining the Default Menu


You can look at the structure of the Default menu by opening the file called
menudef.mmb. This file contains a menu module with an identical structure
to that of the Default menu. Once you have opened the menu def module,
you can see its objects in the Object Navigator.
You can see that the menu module consists of a main menu (starting point),
menus, and menu items.

......................................................................................................................................................
Developer/2000: Build Forms II 2-9
Lesson 2: Creating a Menu Module
......................................................................................................................................................

The Menu Editor


Display Create Create Switch
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 Down Right Orientation

Menu tab Expanded Collapsed


menu menu
2-8 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

The Menu Editor


What Is the Menu Editor?
The Menu Editor is a graphical design facility for laying out, modifying, and

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.

Two Ways to Display the Menu Editor


• Double-click the icon to the left of the menu module entry in the Object
Navigator.
• Select Tools—>Menu Editor.

Tools Specific to the Menu Editor Toolbar


You have seen the majority of the tools from the Menu Editor toolbar in the
Layout Editor; however, there are some that are specific to the Menu Editor.

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
......................................................................................................................................................

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.

2-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-12 Developer/2000: Build Forms II
Creating a Menu Module
......................................................................................................................................................

Creating a Menu Module


The first step when creating a menu is to define a new menu module using
the Object Navigator. Once the module is created, you need to create menus

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 Main Menu from the Menu Editor


To create menu items for the Main menu, select New Item from the Menu
Editor (it is usually selected already).
1 Type a menu label to replace the default label.
2 Click the Create Right icon.
3 Type a new label to replace the default label.
4 Repeat steps 2 and 3 to add more items to the Main menu.
Note: The label is the text that is displayed for the menu item at run time.
The label may differ from the name, which you can use programmatically
and which must follow PL/SQL naming conventions.

Creating an Individual Menu


1 In the Main menu, select the parent item.
2 Click the Create Down icon.
3 Type a new label to replace the default label.
4 Repeat steps 2 and 3 to add more menu items to the current individual
menu.
Note: Forms places a shaded rectangle, or handle, to the left of the first
menu item. You can use it to move the menu along with all its items.

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
......................................................................................................................................................

Menu Module 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.

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-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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
......................................................................................................................................................

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.

• Enabled • Menu Item Code


• Label • Submenu Name
• Menu Item Type • Keyboard
• Magic Item Accelerator

• Menu Item Radio • Icon in Menu


Group • Icon Filename
• Command Type • Help Description

2-12 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Menu Item Properties


Properties Specific to Menu 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.
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

Defining Menu Access Keys


Forms indicates an access key by underlining one special character in the
menu item. Users can then issue the menu item command by pressing a key
combination such as ALT-character.

Specifying the Underline Character


Development Run-time
execute query execute query
eXecute query eXecute query
Exe&cute Query Execute Query
Execute &Query Execute Query

......................................................................................................................................................
Developer/2000: Build Forms II 2-19
Lesson 2: Creating a Menu Module
......................................................................................................................................................

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.

Plain
Check

Radio

Magic

Separator

2-13 Copyright  Oracle Corporation, 1998. All rights reserved.

Magic Items

• About • Paste
• Undo • Help
• Clear • Quit
• Copy • Window
• Cut

2-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-20 Developer/2000: Build Forms II
Menu Item Types
......................................................................................................................................................

Menu Item Types


You can customize a menu by using different item types. In addition to plain
menu items, Form Builder supports four types of special 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.
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
......................................................................................................................................................

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.

Null Does not issue a command

Menu Invokes a submenu

PL/SQL Executes a PL/SQL command

Plus Spawns a process to SQL*Plus

Form Backward compatibility

Macro Backward compatibility

2-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-22 Developer/2000: Build Forms II
Menu Item Command Types
......................................................................................................................................................

Menu Item Command Types


Every menu item must have a valid command type. Most menu items
execute PL/SQL commands, so their command type is PL/SQL. However, if

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.

Choosing a Command Type


Command Type Description
Null Specifies that the menu item does not issue a command. The
NULL command is required for Separator menu items and
optional for all other types of items
Menu Invokes a submenu. Valid submenu name is the name of the sub-
menu to be invoked
PL/SQL (default) Executes a PL/SQL command. Valid menu item code is PL/SQL
statement, including calls to built-in and user-named
subprograms.
Plus Specifies that the menu item code spawn a process to SQL*Plus.

Note: The command types of Form and Macro are available for
compatibility with SQL*Menu V4.0. and SQL*Menu V.5.0.

Viewing Menu Item Commands


To view the menu item command associated with a menu item, you must
either:
• Double-click the icon to the left of the menu item entry in the Object
Navigator
• Use the Menu Item Code or Submenu Name property in the Property
Palette

......................................................................................................................................................
Developer/2000: Build Forms II 2-23
Lesson 2: Creating a Menu Module
......................................................................................................................................................

Implementing Menu Toolbars


Toolbar as part of 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.

• Contains only buttons corresponding to


menu items
• Is displayed above “ normal” toolbars
• Executes the same code as menu items
• Is enabled and disabled, visible and
hidden, in synchronization with
corresponding menu item

2-16 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Implementing Menu Toolbars


What Is a Menu Toolbar?
When you create a custom form menu, you can specify that some of its

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.

Menu Toolbar Orientation


You can assign menu items to a horizontal or, and a vertical menu toolbar.
Form Builder locates a horizontal menu toolbar at the very top of a form
(just beneath the pull-down form menu), while a vertical menu toolbar
appears at the far left of a form (to the left of any existing toolbar canvas).

Creating a Menu Toolbar


To create a menu toolbar, you have to set up the following menu item
properties.

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
......................................................................................................................................................

Menu Module Storage


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 module definition


• .MMB
• Database tables
Menu module executable
• .MMX
Menu module text
• .MMT

2-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-26 Developer/2000: Build Forms II
Storing the Menu Module
......................................................................................................................................................

Storing the Menu Module


Saving the Menu Module Definition
As with the form module, you can save your menu module definition to

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

Creating an Executable Version


Before you can use your customized menu module, you must create an
executable version. To do so,
• Select File—>Administration—>Compile File.
The resulting file that you create has the .mmx extension. A menu module
executable file, containing binary code is not portable between operating
systems.

......................................................................................................................................................
Developer/2000: Build Forms II 2-27
Lesson 2: Creating a Menu Module
......................................................................................................................................................

Form Module 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 Specify
module that menu
to use with module
this form is stored
module in the file
system

2-18 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Attaching the Menu Module


To use your customized menu module, you must attach it to a form module.
When you attach a customized menu module to a form module, you 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.
effectively replacing the Default menu with your own.

Attaching the Menu Module to the Form Module


1 Ensure that the menu module has been generated.
2 Select the form module to which you want to attach your menu.
3 Invoke the Property Palette for the form module.
4 Replace the value DEFAULT&SMARTBAR in the Menu Module
property with your menu module name.
5 Ensure that the Menu Source property has a value of:
a File, if the menu module is stored in the file system
b Database, if the menu module is stored in the database
6 Generate your form module.

......................................................................................................................................................
Developer/2000: Build Forms II 2-29
Lesson 2: Creating a Menu Module
......................................................................................................................................................

What Is a Pop-Up 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.

Menu that appears on the Cut Ctrl+X


Copy Ctrl+C
screen at the location it Paste Ctrl+V
was invoked Properties...
Layout Editor...
• Enables users to PL/SQL Editor...
access commonly used Help
functions easily
• Accessed by pressing
the right mouse button
(Microsoft Windows and
Motif)
2-19 Copyright  Oracle Corporation, 1998. All rights reserved.

Incorporating Pop-Up Menus


• Pop-up menus are:
– Top-level objects in the object
navigator, such as alerts, blocks, and
so on
– Built through the Property Palette or
Menu Editor
– Part of a form module as opposed to
a separate menu module
– Associated with items and canvases
using a new pop-up menu property
• Pre-Popup-Menu trigger provides
dynamic control
2-20 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.)

Incorporating Pop-Up Menus


1 In the Object Navigator of a form, click the Pop-up Menus node, and
click the Create button in the toolbar.
Form Builder creates a pop-up menu and gives it a default name, such as
MENU1.
2 In the Object Navigator or Menu Editor, create a main pop-up menu,
submenus (if any), and menu items.
3 Assign commands to the menu items.
4 Attach the menu to items and canvases with new Pop-Up Menu property.

Rules for Incorporating Pop-Up Menus


• To show pop-up menus for a canvas, the mouse must be on the canvas
only.
• Pop-up menu items can be parents of submenus (if the platform allows
it), magic menu items, or separators.
• Pop-up menus items cannot be check boxes, radio items, or iconic menu
items.

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.

• Menu module components


• The Default menu
• Creating a menu module
• Menu properties
• Menu module storage
• Menu module and form module
association
• Pop-up menu

2-21 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

• Creating a simple menu module


• Incorporating some of the menu items
in the menu toolbar
• Compiling and attaching the menu to
the ORDERS form
• Creating a pop-up menu

2-22 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
2-34 Developer/2000: Build Forms II
Practice Session Overview: Lesson 2
......................................................................................................................................................

Practice Session Overview: Lesson 2


This practice guides you through creating custom menus for the ORDERS
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.
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
......................................................................................................................................................

Practice Session: Lesson 2


1 Create a new menu module.
a Using the following screenshot as a guideline, create a new 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.

module called M_SUMMIT.

• 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.

Label Item Type Type Menu Item Code Toolbar Filename


Enter- Plain PL/SQL DO_KEY(’ Yes query
Query ENTER_QUERY’);
eXe- Plain PL/SQL DO_KEY(’EXECUT Yes execute
cute E_QUERY’);
Query

b Save as M_SUMMIT and compile the menu module.


c Attach the menu module to the ORDERS form.
d Save and compile the form module.
e Run the CUSTOMERS form and press the Orders button.
2 Add pop-up menus to the CUSTOMERS form.
a Open the CUSTOMERS form module.
b Copy the EDIT_MENU menu from the M_SUMMIT menu module
to the CUSTOMERS form. Attach this Pop-up menu to the
Comments item.
c Save and compile the form module.
d Run the CUSTOMERS form and click the right mouse button on the
comment item.

......................................................................................................................................................
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.

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
3-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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
......................................................................................................................................................

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.

• Similar to PL/SQL code in form triggers


• You can share code between a form
module and a menu module:
– Libraries
– User-defined triggers
– DO_KEY built-in

3-3 Copyright  Oracle Corporation, 1998. All rights reserved.

Using PL/SQL in Menu Item


Code
• Menu modules generated independently
• Restrictions:
– Cannot directly reference values of
form objects
– Must use NAME_IN built-in function
– Cannot use direct assignment for
form objects
– Must use COPY built-in procedure

3-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-4 Developer/2000: Build Forms II
Using PL/SQL in Menu Item Code
......................................................................................................................................................

Using PL/SQL in Menu Item Code


Using PL/SQL in Menu Item Commands
PL/SQL menu item commands are structurally similar to form triggers. In

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.

Sharing Code Between a Form Module and a Menu Module


You can share code between a form module and a menu module in three
ways:
• Setting up libraries and attaching them to the two modules.
• Creating user-defined triggers in the form module and calling them from
a standard trigger in a form module, or calling them from a menu item in
a menu module. Use EXECUTE_TRIGGER to fire the user-defined
trigger.
• Using the DO_KEY built-in to fire the corresponding trigger or function
from a menu item.

Restrictions
Menu modules are generated independently of form modules.
In PL/SQL command menu items:
• You cannot directly reference the value of form module objects.
• You must use the NAME_IN built-in function to determine the current
value of the object.
• You cannot use direct assignment to set the value of a form module
object.
• You must use the COPY built-in procedure.

Example

IF :s_emp.title = ’MANAGER’ THEN ...-- INCORRECT


IF NAME_IN(’s_emp.title’) = ’MANAGER’ THEN ... -- CORRECT

:s_product.name := ’PUMP’; -- INCORRECT


COPY(’PUMP’, ’s_product.name’); -- CORRECT

......................................................................................................................................................
Developer/2000: Build Forms II 3-5
Lesson 3: Managing Menu Modules
......................................................................................................................................................

Built-ins for Setting and Getting


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.

• FIND_MENU_ITEM
• GET_MENU_ITEM_PROPERTY
• SET_MENU_ITEM_PROPERTY
• ITEM_ENABLED
• MENU_SHOW_KEYS

3-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-6 Developer/2000: Build Forms II
Useful Built-in Menu Subprograms
......................................................................................................................................................

Useful Built-in Menu Subprograms


You can change certain menu characteristics dynamically at run-time using
built-in 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.

Setting and Getting Menu Item Properties


Built-in Description
FIND_MENU_ITEM This function gets the ID of a menu item. The receiving
variable must be declared as a menu item type. Use it as
soon as you reference the same menu item more than
once.
GET_MENU_ITEM_PROPERTY This function returns the current value of the given
property for a specified menu item.
SET_MENU_ITEM_PROPERTY This procedure modify the state of a menu-item-specific
characteristic.
ITEM_ENABLED This function returns the Boolean value TRUE when the
menu item is enabled and FALSE when the menu item
is disabled.
MENU_SHOW_KEYS This procedure displays the Keys screen for the menu
module at run-time.

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
......................................................................................................................................................

Built-ins for 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.

REPLACE_MENU
Character mode built-ins
• HIDE_MENU
• SHOW_MENU
• MENU_REDISPLAY

3-6 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Showing and Hiding the Current Menu


Built-in Description
REPLACE_MENU Procedure for replacing the current menu with a specific one,

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.

PROCEDURE Change_Root_To(root_menu_name VARCHAR2) IS


BEGIN
Replace_Menu(’MYAPPLSTD’, PULL_DOWN, root_menu_name);
END;

......................................................................................................................................................
Developer/2000: Build Forms II 3-9
Lesson 3: Managing Menu Modules
......................................................................................................................................................

Built-in Substitution 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.

UN Current username

PW Current password

AD Directory name

SO Current menu name

TT Terminal type

LN Language used

3-7 Copyright  Oracle Corporation, 1998. All rights reserved.

User-Named Substitution
Parameters

Design time Run time


3-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Predefined Substitution Parameters


You can use six predefined (built-in) substitution parameters. Form Builder
automatically processes them at run-time.
Parameter Description
UN Current username
PW Current password
AD Directory name containing the current menu module run-time file
SO Current menu name (selected option)
TT Terminal type used at connection
LN Language used (NLS_LANG parameter)

User-Named Substitution Parameters


User-named substitution parameters are processed at run-time by the user
through a dialog box. Alternatively, they can be processed programmatically
through built-in procedures.
Note: Substitution parameter values can be referenced in triggers and user-
defined subprograms.

......................................................................................................................................................
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-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-12 Developer/2000: Build Forms II
Defining a User-Named Substitution Parameter
......................................................................................................................................................

Defining a User-Named Substitution Parameter


Creating a User-Named Substitution Parameter
You can create a user-named substitution parameter from the Object

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-10 Copyright  Oracle Corporation, 1998. All rights reserved.

Referencing and Applying


Menu Parameters
• In a menu item command:
– Prefix the parameter name with &
Example: &param_name
• In a PL/SQL routine:
– Prefix the parameter name with &
when entered through a dialog box
– Prefix the parameter name with :
when entered in the PL/SQL editor
Example: :param_name
3-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-14 Developer/2000: Build Forms II
Substitution Parameter Built-ins
......................................................................................................................................................

Substitution Parameter Built-ins


Prompting for 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.
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

Syntax for Referencing Substitution Parameters


The syntax for referencing substitution parameters varies depending on how
you enter the value. Once assigned, the values of menu substitution
parameters can be referenced in triggers and user-named subprograms
defined in the current form, provided that the menu in which the parameters
are defined is the current menu.

Referencing a Parameter in a Menu Item Command


Prefix the parameter name with an ampersand (&).

Example
This example invokes SQL*Plus and runs a command file (CF parameter).

PLUS33W &UN/&PW @&CF

Referencing a Parameter in a PL/SQL Routine


Prefix the parameter name with the ampersand (&) if the value is entered
through the Enter Parameter Values dialog box. Prefix the parameter name
with a colon (:) if the value is entered programmatically.

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-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-16 Developer/2000: Build Forms II
Validating a Substitution Parameter Value
......................................................................................................................................................

Validating a Substitution Parameter Value


You can validate the substitution parameter values entered by the user using a WHILE
loop including the QUERY_PARAMETER procedure, and testing 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.
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
......................................................................................................................................................

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.

• Defining security roles


• Choosing roles for the menu module
• Assigning access to menu items
• Setting the Use Security property

3-13 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Managing Menu Security


What Is Menu Security?
Using menu security, you can set up access rights on menu items. You 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.
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.

Implementing Menu Security


First, define the different types of users who will use the menus, their
profiles, and their needs. Then follow the steps below:
1 Define security roles in the database.
2 Choose roles for the module in Form Builder.
3 Assign access to menu items.
4 Set the Use Security property.

......................................................................................................................................................
Developer/2000: Build Forms II 3-19
Lesson 3: Managing Menu Modules
......................................................................................................................................................

Menu Module Roles Window


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.

Select Menu Module Roles:

3-15 Copyright  Oracle Corporation, 1998. All rights reserved.

Use Security Property

• Set to Yes to enforce security.


• Set to No to ignore security.
– Enables the developer to test the
application

3-16 Copyright  Oracle Corporation, 1998. All rights reserved.

Technical Note
If Use Security is modified, you must recompile the menu module.

......................................................................................................................................................
3-20 Developer/2000: Build Forms II
Defining Security Roles
......................................................................................................................................................

Defining Security Roles


Defining New Roles
Menu security is based on the Oracle Server roles. You can create these from

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.

Assigning Roles to the Menu Module


To associate a particular role with a menu item, you must define all the roles
used in that menu module:
1 In the Object Navigator, select the menu module.
2 In the Properties window, select the Menu Module Roles property.
3 Click More... to open the Menu Module Roles dialog box.
4 Enter the names of the roles that you want to choose for this menu
module.
5 Click OK to accept the roles list.
Note: The role names must exist in the database roles.

Setting the Use Security Property


The Use Security property determines whether or not Form Builder should
take account of the specified roles at run-time.
When Use Security is set to Yes:
• Forms enforces security.
When Use Security is set to No:
• Forms ignores security.
• Your users can access all menu items.
• You can test your application without being a member of all roles.

......................................................................................................................................................
Developer/2000: Build Forms II 3-21
Lesson 3: Managing Menu Modules
......................................................................................................................................................

Menu Item Roles Window


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.

Select Menu Item Roles:

3-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-22 Developer/2000: Build Forms II
Assigning Access to Menu Items
......................................................................................................................................................

Assigning Access to Menu Items


After defining roles to use for the current menu module, you must specify
the role or the roles that will have access to each menu 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.
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.

• PL/SQL in menu item commands


• Built-ins for use with menus
• Substitution parameters
• Implementing menu security

3-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

Built-ins for Use with Menu Modules


• Showing and hiding the current menu:
- HIDE_MENU
- REPLACE_MENU
- SHOW_MENU
- MENU_REDISPLAY
• Getting and setting menu properties:
- FIND_MENU_ITEM
- GET_MENU_ITEM_PROPERTY
- SET_MENU_ITEM_PROPERTY

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

Implementing Menu Security


• Using database roles

......................................................................................................................................................
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.

• Enhancing the menu with a check


menu item
– Synchronizing the Image Activate
menu item with the Image button
• Modifying the menu for use with the
Employee form
• Disabling irrelevant menu items
according to form context
• Creating a User-named substitution
parameter

3-19 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
3-26 Developer/2000: Build Forms II
Practice Session Overview: Lesson 3
......................................................................................................................................................

Practice Session Overview: Lesson 3


This practice guides you through enhancing custom menus for the ORDERS and
EMPLOYEE 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.
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
......................................................................................................................................................

Practice Session: Lesson 3


1 Defining a Check Menu Item.
a Open the M_SUMMIT menu module and create a new menu item to
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 right of Query and rename it Image.


b Create a new menu item under Image and name it Image Activate.

Menu Label Menu Item Type Command Type


Image Activate Check PL/SQL

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;

dSave and compile the module.


e Open the EMPLOYEES form module and attach the menu module to
it.
Note: Some options of the M_SUMMIT menu module are not suitable for
this form and will be discussed later.
f Save and compile the form module.

......................................................................................................................................................
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.

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 interface
controls

4-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

What is a Key trigger?


Example:
Using Key-Exit, display an alert and exit
the application if the user answer Yes.
SET_ALERT_PROPERTY(’question_alert’, ALERT_MESSAGE_TEXT,
’Do you really want to leave the form? ’);
IF SHOW_ALERT(’question_alert ’) = ALERT_BUTTON1 THEN
EXIT_FORM; -- default functionality
END IF;

4-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

What Is a Key Trigger?


A Key trigger, like any other trigger, is a subprogram that is executed when a
certain event occurs. In the case of a Key trigger, the event is pressing the
function key for which the trigger is defined. The trigger is usually named
after the event that causes it to fire. When the Key trigger is defined for a
function key, the usual functionality of the key is completely replaced by the
PL/SQL text of the trigger. In this respect, Key triggers resemble On
triggers.

Example
The form level Key-Exit trigger below displays an alert to ask to the end user
if he wants to leave the form.

SET_ALERT_PROPERTY(’question_alert’, ALERT_MESSAGE_TEXT, ’Do


you really want to leave the form?’);
IF SHOW_ALERT(’question_alert’) = ALERT_BUTTON1 THEN
EXIT_FORM; -- default functionality
END IF;

Note: If you also want to execute the default functionality of the function
key, you must ensure that the Key trigger includes the built-in function
associated with the key.

Example
The following form level Key-Menu trigger disables [Block Menu] for a
form.

BEGIN
NULL;
END;

......................................................................................................................................................
Developer/2000: Build Forms II 4-5
Lesson 4: Programming Function Keys
......................................................................................................................................................

Key Trigger Properties and


PL/SQL 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.

Display in “ Keyboard Help”


“ Keyboard Help” Text

4-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-6 Developer/2000: Build Forms II
Defining Key Triggers
......................................................................................................................................................

Defining Key Triggers


You define Key triggers in the same way that you define any other trigger.
However, the following two properties on the Properties window for 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
......................................................................................................................................................

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.

• You cannot redefine all function keys


with Key triggers.
• Key triggers are defined at all three
levels.
• A Key trigger can contain SELECT
statements and all built-ins.
• Key triggers can fire in Enter Query
mode.

4-5 Copyright  Oracle Corporation, 1998. All rights reserved.

Characteristics of Key Triggers

Function Key Built-in Key Trigger

[Accept] COMMIT_FORM Key-Commit

[Clear Form] CLEAR_FORM Key-Clrfrm

[Create Record] CREATE_RECORD Key-Crerec

[Delete Record] DELETE_RECORD Key-Delrec

4-6 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-8 Developer/2000: Build Forms II
Characteristics of Key Triggers
......................................................................................................................................................

Characteristics of Key Triggers


Rules of Key Triggers
• You cannot redefine all function keys with Key triggers. Some keys 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.
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.

Function Keys, Their Associated Built-in Functions, and Key Triggers


Function Key Built-in Function Key Trigger
[Accept] COMMIT_FORM Key-Commit
[Create Record] CREATE_RECORD Key-Crerec
[Delete Record] DELETE_RECORD Key-Delrec
[Duplicate Record] DUPLICATE_RECORD Key-Duprec
[Enter Query] ENTER_QUERY Key-Entqry
[Execute Query] EXECUTE_QUERY Key-Exeqry
[List] LIST_VALUES Key-Listval
[Next Item] NEXT_ITEM Key-Next-Item
[Down] DOWN Key-Down
[Next Record] NEXT_RECORD Key-Nxtrec
[Exit] EXIT_FORM Key-Exit

Note: This list is incomplete.

......................................................................................................................................................
Developer/2000: Build Forms II 4-9
Lesson 4: Programming Function Keys
......................................................................................................................................................

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.

• Function Key triggers


• Key-Fn triggers and Oracle Terminal
• Key-Others triggers

4-7 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Classification of Key Triggers


You can distinguish between different types of Key triggers. Learning these
classifications will help you to understand when to use 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.

Note: For additional information about Oracle Terminal, see appendix D.

......................................................................................................................................................
Developer/2000: Build Forms II 4-11
Lesson 4: Programming Function Keys
......................................................................................................................................................

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.

Mouse-event Key triggers:


• Key-Next-Item • Key-Down
• Key-Prev-Item • Key-Scrup
• Key-Nxtrec • Key-Scrdown
• Key-Prvrec • Key-Nxtblk
• Key-Up • Key-Prvblk

4-8 Copyright  Oracle Corporation, 1998. All rights reserved.

Technical Note
Do not use mouse-event Key triggers for important code.

......................................................................................................................................................
4-12 Developer/2000: Build Forms II
Classification of Key Triggers
......................................................................................................................................................

What Are Mouse-Event Key Triggers?


Mouse-event Key triggers are function Key triggers whose associated
default functionality can also be activated directly with the mouse.

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
......................................................................................................................................................

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.

• Adjust user interface


• Disable a (set of) function keys
• Replace or extend functionality of
function keys
• Add additional function keys
• Be careful with Key-Others
• Do not use for validation

4-9 Copyright  Oracle Corporation, 1998. All rights reserved.

Specific Key Trigger Examples

• Call an LOV form


• Check for detail records before deleting
a master record
• Prevent duplication of the primary key
• Adjust toolbar buttons for Enter Query
mode

4-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-14 Developer/2000: Build Forms II
Using Key Triggers
......................................................................................................................................................

Using Key Triggers


You should use Key triggers sparingly. One reason is that often you must
define a lot of Key triggers to trap a certain event completely. Another

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

When Not to Use Key Triggers


• To perform validation; use validation triggers instead
• To amend navigation; use navigational triggers instead
• To perform data manipulation; use transactional triggers instead

Specific Key Trigger Examples


• Call an List of Values (LOV) form instead of the native Forms LOV,
using Key-Listval
• Check if detail records exist before deleting a master record, using
Key-Delrec
• Prevent duplication of the primary key when duplicating a record, using
Key-Duprec
• Adjust behavior of toolbar buttons when Enter Query mode is entered or
left, using Key-Entqry

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
......................................................................................................................................................

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.

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

-- custom actions when user tries to exit


EXIT_FORM;
...

4-11 Copyright  Oracle Corporation, 1998. All rights reserved.

Association with Other


Interface Controls
2. In When-Button-Pressed and Menu
item code:
DO_KEY(‘EXIT_FORM’);

•DO_KEY(‘Key-Exit’) gives run time


error
• Corresponding Interface Control
descriptions
4-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-16 Developer/2000: Build Forms II
Association with Other Interface Controls
......................................................................................................................................................

Association with Other Interface Controls


You can often activate the same functionality in various ways, for examples,
press a function key, choose a menu item, press a button, or perform direct

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’);

Interface Control Descriptions


If the same functionality is activated by various interface controls, you
should also make sure that the controls have the same descriptions.
Interface Control Property for Description Changeable at Run-Time?
Function key Show Keys Description No
Menu item Menu-item label Yes
Button Button label Yes
Mouse event Not applicable Not applicable

......................................................................................................................................................
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.

• Display in “ Keyboard Help” and


“ Keyboard Help” Text
• Key-Fn, Key-Others, and mouse-event
Key triggers
• Using Key triggers
• Function keys, buttons, menu items,
and mouse events
• Example: DO_KEY(‘EXIT_FORM’);

4-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Classification of Key Triggers


• Function Key triggers
• Key-Fn triggers
• Key-Others
• Mouse-event Key triggers

Uses for Key Triggers


• Disable function keys
• Replace or extend default behavior of function keys
• Add function keys using Key-Fn triggers
• Adjust set of function keys using Key-Others

Association with Other Interface Controls


• Function keys, buttons, menu items, mouse events
• Keys description, button label, menu-item label

......................................................................................................................................................
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.

• Examining the behavior of


[Duplicate Record] at run time
• Redefining [Duplicate Record]
– To create a new record before
duplication
– To clear primary key items after
duplication
• Changing the behavior of function keys
according to context
4-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
4-20 Developer/2000: Build Forms II
Practice Session Overview: Lesson 4
......................................................................................................................................................

Practice Session Overview: Lesson 4


This practice guides you though redefining function keys with Key triggers.
In the process, you will investigate the behavior of the Key-Others trigger.

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
......................................................................................................................................................

Practice Session: Lesson 4


1 Create and modify a Key trigger.
aOpen the ORDERS form module and replace the M_SUMMIT 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.

module with the DEFAULT&SMARTBAR menu.


b Run the form and make sure that you understand the default behavior
of [Duplicate Record], by invoking it once while the cursor is on a
queried record in the S_ORD block and again when the cursor is on a
new record.
c In the S_ORD block, redefine [Duplicate Record] in such a way that
a new record is created before duplication takes place, and the
primary key items are emptied after duplication.
d Duplicate your trigger at the form level and at the S_ITEM block
level.
e For the S_ITEM block, empty the item_id, product_id, description,
and price items after duplication.
f Avoid duplicating the code by using the Execution Hierarchy trigger
property.
If you have time...
2 Disable function keys.
a Make sure that only the function keys [Duplicate Record],
[Execute Query], [Enter Query], [Create Record], [Clear Block],
[Up], and [Down] can be used for the S_ORD master block. All
functions keys should be available for the S_ITEM detail block.
b Test whether you can exit from the form by pressing [Exit] key in the
master block.
c Add a Form-Level Key-Exit trigger performing the exit functionality
of the CONTROL.EXIT_BUTTON item.
d Test again whether you can exit from the form by pressing [Exit] in
the master block. Explain this behavior.
e Modify the When-Button-Pressed trigger of the
CONTROL.EXIT_BUTTON item to activate the same functionality
when you press the [Exit] function key.

......................................................................................................................................................
4-22 Developer/2000: Build Forms II
Practice Session: Lesson 4
......................................................................................................................................................

3 Create and modify a Key trigger.


a Create an Alert called DELETE_ALERT.
b For the S_ORD and S_ITEM blocks, redefine [Delete Record] in
such a way that the alert is displayed when a record is 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.
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.

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

5-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

• Point at which processing can be


influenced
• Identified by:
– Mouse movement
– Mouse button action

5-3 Copyright  Oracle Corporation, 1998. All rights reserved.

Mouse Cursor Style


To change the cursor style dynamically:

SET_APPLICATION_PROPERTY(CURSOR_STYLE,
’value’);

DEFAULT GUI-specific arrow symbol


BUSY GUI-specific busy symbol
CROSSHAIR GUI-specific crosshair symbol
HELP GUI-specific help symbol
INSERTION GUI-specific insertion symbol

5-4 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
5-4 Developer/2000: Build Forms II
What Are Mouse Events?
......................................................................................................................................................

What Are Mouse Events?


An event is a point during a Forms process at which you can influence the
processing behavior. Every object can have processing events with which

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.

The Seven Mouse Events


The Forms mouse events can be divided in two groups: mouse movement
events and mouse button-initiated events.
The mouse movement events are:
• Entry into an item or canvas
• Exit from an item or canvas
• General movement
The events that correspond to mouse button actions are:
• Click
• Double-click
• Up
• Down

Mouse Cursor Style


Form Builder allows you to change dynamically the cursor style. Use the
following built-in to do it:

SET_APPLICATION_PROPERTY( CURSOR_STYLE, ’value’);

The valid settings for the cursor style property are:


• BUSY
• CROSSHAIR
• DEFAULT
• HELP
• INSERTION

......................................................................................................................................................
Developer/2000: Build Forms II 5-5
Lesson 5: Responding to Mouse Events
......................................................................................................................................................

Mouse Movement 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.

When-Mouse-Enter

When-Mouse-Leave

When-Mouse-Move

5-5 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Responding to Mouse Movement


You can initiate an action whenever mouse movement occurs by defining the
mouse movement 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 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

Uses of the Mouse Movement Triggers


• Use When-Mouse-Move in conjunction with
SYSTEM.MOUSE_X_POS to return the exact position of the mouse
within an item.
• Use When-Mouse-Leave to update an item value without causing the
cursor to navigate out of the current item.

......................................................................................................................................................
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

5-6 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

The Mouse Position System Variables


Use the following system variables to determine when the mouse has
moved, where it has moved from, and where it has moved to.

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
......................................................................................................................................................

Mouse Button Action Triggers


When-Mouse-Down
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-Mouse-Up

When-Mouse-Click
click

When-Mouse-Doubleclick
click click

5-7 Copyright  Oracle Corporation, 1998. All rights reserved.

Mouse Event Trigger Sequence


1. When-Mouse-Down

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
......................................................................................................................................................

Responding to Mouse Button Actions


You can initiate an action whenever a mouse button action occurs by defining the mouse
button action 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 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

Firing Sequence for Mouse Button Action Triggers


When you double-click an item or canvas, you are potentially causing the
following triggers to fire in the order in which they are listed. Similarly
when you click an item or canvas, the triggers which precede the
When-Mouse-Click trigger, will fire.
• When-Mouse-Down
• When-Mouse-Up
• When-Mouse-Click
• When-Mouse-Down
• When-Mouse-Up
• When-Mouse-Doubleclick

......................................................................................................................................................
Developer/2000: Build Forms II 5-11
Lesson 5: Responding to Mouse Events
......................................................................................................................................................

Mouse Button Action


System Variables
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.

SYSTEM.MOUSE_BUTTON_PRESSED

SYSTEM.MOUSE_BUTTON_MODIFIERS

Ctrl Alt

5-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

The Mouse Button System Variables

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
......................................................................................................................................................

Drag and Drop


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 in original positions

Item-A highlighted

Items repositioned

5-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
5-14 Developer/2000: Build Forms II
Responding to Mouse Button Actions
......................................................................................................................................................

What Is Drag and Drop?


The drag and drop functionality is the ability for users to move items around
on the canvas and arrange them in the order they want.

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-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

• Invoke an editor when the operator


double-clicks an item
• Define mouse-event trigger to display
the Help canvas

5-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
5-18 Developer/2000: Build Forms II
Practice Session Overview: Lesson 5
......................................................................................................................................................

Practice Session Overview: Lesson 5


This practice guides you through using mouse-event triggers and mouse
system variables.

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
......................................................................................................................................................

Practice Session: Lesson 5


In this workshop, you provide additional functionality in your forms by
defining mouse-event 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.

1 In the CUSTOMERS form, define a mouse-event trigger on


S_CUSTOMER.COMMENTS that invokes the item’s editor when the
user double-clicks on the item.
2 In the ORDERS form convert the CONTROL.SHOW_HELP_BUTTON
button into a display item. This item should be capable of displaying a
single large character. Change the item and choose a font that allows
large character sizes (such as Times New Roman). Set the font size to
24. Set Bevel to none. Adjust the item size so that one character is visible
inside it. The item’s background color should match the toolbar, and its
text color should be green. This item appears as “S”.
3 In the ORDERS form, define a When-Mouse-Enter trigger at form level
that assigns a value of “?” to the display item
CONTROL.SHOW_HELP_BUTTON.
4 Alter the When-Mouse-Enter trigger so that it fires only when entering
CV_ORDER canvas (you may wish to include Toolbar also).
5 Create a When-Mouse-Enter trigger on
CONTROL.SHOW_HELP_BUTTON that uses the SHOW_VIEW
built-in to display the CV_HELP. Remove the When-Button-Pressed
trigger.
6 Create a When-Mouse-Leave trigger on
CONTROL.SHOW_HELP_BUTTON that hides the CV_HELP. Use the
HIDE_VIEW built-in to achieve this. Delete the
CONTROL.HIDE_HELP_BUTTON button.
7 Save, compile, and run the ORDERS form to test.
The stacked canvas, CV_HELP, displays only if the current item will not
be obscured. Ensure, at least, that the first entered item in the form is one
that will not be obscured by CV_HELP.
If you have time...
8 Modify the When-Mouse-Enter and When-Mouse-Leave triggers to
display the Cv_Help canvas, even if the current item is obscured. You
can import the pr5_8_1.txt and pr5_8_2.txt files.

......................................................................................................................................................
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.

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

6-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

When-Window-Activated Enforces navigation

When-Window-Deactivated Deactivates a window

When-Window-Closed Closes a window

When-Window-Resized Maintains visual


standards

• 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
......................................................................................................................................................

Using Window-Interaction Triggers


You can use four window-interaction triggers to provide extra functionality
whenever a user interacts with a window. These triggers should be defined at

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.

The common uses for those triggers are the following:


Trigger Use
When-Window-Activated Enforces navigation to a window; captures initial window
properties
When-Window-Deactivated Deactivates a window
When-Window-Closed Closes a window
When-Window-Resized Maintains visual standards; captures window properties

Keeping Track of the Triggered Window


The SYSTEM.EVENT_WINDOW system variable contains the name of the
last window for which a window-interaction trigger fired. You can use this
system variable to perform different actions for different windows in your
window-interaction triggers.

......................................................................................................................................................
Developer/2000: Build Forms II 6-5
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

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
• GET_WINDOW_PROPERTY
• HIDE_WINDOW
• MOVE_WINDOW
• RESIZE_WINDOW
• SET_WINDOW_PROPERTY
• SHOW_WINDOW

6-4 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Built-ins for Manipulating WINDOWS


Built-in 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.
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
......................................................................................................................................................

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.

• 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
......................................................................................................................................................

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
......................................................................................................................................................

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.

When-Tab-Page-Changed trigger fires


when a user:
• Clicks a tab
• Uses the Next Tab Page or Previous Tab
Page function keys
Page 1 Page 2 click 3
Page

Previous Next
tab page tab page

6-6 Copyright  Oracle Corporation, 1998. All rights reserved.

Working with Tab-Style


Canvases

Tab canvases system variables:


• :SYSTEM.TAB_NEW_PAGE
• :SYSTEM.TAB_PREVIOUS_PAGE

6-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-10 Developer/2000: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................

Working with Tab-Style Canvases


When-Tab-Page-Changed Trigger
This new form-level trigger fires when there is explicit item or mouse

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.

Tab Canvases System Variables


Within the When-Tab-Page-Changed trigger, you can reference system
variables to determine where you are coming from and going to.
• :SYSTEM.TAB_NEW_PAGE returns the name of the tab page that you
are going to.
• :SYSTEM.TAB_PREVIOUS_PAGE returns the name of the tab page
that you are coming from.
These system variables return only the page name, not the canvas name, so
you must name all tab pages uniquely across the form if you need to be able
to identify them programmatically.

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
......................................................................................................................................................

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.

• 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-8 Copyright  Oracle Corporation, 1998. All rights reserved.

Other Arguments for Canvas


Built-ins
• GET_CANVAS_PROPERTY
– Identify the topmost tab page
• SET_CANVAS_PROPERTY
– Bring a page to the top
programmatically

6-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-12 Developer/2000: Build Forms II
Working with Tab-Style Canvases
......................................................................................................................................................

Built-ins for Manipulating Tab-Style Canvases


Built-in Description
FIND_TAB_PAGE Searches the list of tab pages in a given tab canvas and

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.

Note: The tab page is named using the syntax ‘CanvasName.PageName’.


Example

DECLARE
tp_id Tab_Page;
BEGIN
tp_id := Find_Tab_Page(’Canvas2.TabPage1’);
IF Get_Tab_Page_Property(tp_id, enabled) =’FALSE’ THEN
Set_Tab_Page_Property(tp_id, enabled,property_true);
END IF;
END;

Other Arguments for Canvas Built-ins


If you want to make a tab page the top-most on its underlying tab canvas,
you can use the built-in procedure SET_CANVAS_PROPERTY and set the
canvas property TOPMOST_TAB_PAGE. You can also get the top-most tab
page using the built-in function GET_CANVAS_PROPERTY.

GET_CANVAS_PROPERTY(’canvas_name’, TOPMOST_TAB_PAGE)
SET_CANVAS_PROPERTY(’canvas_name’, TOPMOST_TAB_PAGE, page_name)

where page_name is either a constant, in single quotes, or a variable.

......................................................................................................................................................
Developer/2000: Build Forms II 6-13
Lesson 6: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Windows and Blocks


Window 1
Active Nonactive
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 1
window window

Window 2
Block 2

Block 3
Cursor
location

6-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-14 Developer/2000: Build Forms II
Windows and Blocks
......................................................................................................................................................

Windows and Blocks


Form Builder processes many events based on blocks (and items), which can
be completely independent of windows (and canvases). Keep in mind 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.
following characteristics of windows and blocks.

Connection Between Windows and Blocks


• A window can contain multiple canvases and multiple items can be
located on a canvas.
• A block can contain multiple items and an item is located on one and
only one canvas (except for null canvas items).
• A window can contain multiple blocks and a block can be located on
several windows.
Note: In general, put blocks in separate windows. If blocks are closely
related (through a foreign-key relationship), put them in the same window.

Window Activation and Block Navigation


You can use the When-Window-Activated trigger to activate another
window automatically (see the Closing Windows example later in this
lesson).

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
......................................................................................................................................................

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.

• Maximizing MDI application window


SET_WINDOW_PROPERTY (forms_mdi_window,
window_state, maximize);

• Locating the Cursor window


GET_VIEW_PROPERTY (GET_ITEM_PROPERTY (NAME_IN
(’system.cursor_item’), item_canvas),
window_name);

6-11 Copyright  Oracle Corporation, 1998. All rights reserved.

Technical Note
You can also maximize the MDI window application with the
WINDOW_STATE command line parameter:

f50run32 module=customer.fmx userid=my_name/my_password@my_database


window_state=maximize

......................................................................................................................................................
6-16 Developer/2000: Build Forms II
Manipulating Window Properties Programmatically
......................................................................................................................................................

Manipulating Window Properties Programmatically


You can use the window-interaction triggers and the built-ins for windows to
manipulate your windows (and the MDI application window on Microsoft

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.

Manipulating the MDI Application Window at Form Startup


The When-New-Form-Instance trigger below implements the following
functionality:
• Maximizing the MDI application window
• Setting the window title of the MDI application window

When-New-Form-Instance Trigger at Form Level

BEGIN
SET_WINDOW_PROPERTY(forms_mdi_window, window_state, maximize);
SET_WINDOW_PROPERTY(forms_mdi_window, title, ’Summit Sporting
Goods.’);
END;

Locating the Cursor Window


The cursor may be located in a nonactive window. In this case, you can use
the following GET_CURSOR_WINDOW function to find this window.

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
......................................................................................................................................................

Cascaded Windows with


Context
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-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-18 Developer/2000: Build Forms II
Showing Multiple Windows
......................................................................................................................................................

Showing Multiple Windows


When using several windows, you should consider how to position them
with respect to each other and how to indicate the context in which a certain

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.

Relative Window Positioning


When-New-Form-Instance Trigger at Form Level

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;

Display Context in Window Title


When-New-Block-Instance Trigger on EMP Block

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
......................................................................................................................................................

Window with Close Option on


System Menu Box
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-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

When-Window-Closed Trigger at Form Level

BEGIN
IF :SYSTEM.EVENT_WINDOW = ’WINDOW1’ THEN
DO_KEY(’exit_form’);
ELSIF :SYSTEM.EVENT_WINDOW = ’WINDOW2’ THEN
HIDE_WINDOW(’window2’);
END IF;
END;

When-Window-Activated Trigger at Form Level

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
......................................................................................................................................................

Large Single-Record 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.

6-14 Copyright  Oracle Corporation, 1998. All rights reserved.

Large Multirecord Block

6-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-22 Developer/2000: Build Forms II
Using Large Blocks
......................................................................................................................................................

Using Large Blocks


Using Large Single-Record Blocks
One way to deal with single-record blocks with many items is to use one

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.

Using Large Multirecord Blocks


If you are using multirecord blocks with many items, use one window with
one content canvas and one stacked canvas in the following manner:
1 Determine which items must serve as context items.
2 Put nonscrollable elements (context items, vertical block scroll bar,
buttons) on the content canvas.
3 Put scrollable elements (other items) on the stacked canvas.
4 Position the stacked canvas neatly on the content canvas and give it a
horizontal canvas scroll bar.

......................................................................................................................................................
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

6-16 Copyright  Oracle Corporation, 1998. All rights reserved.

Summary

• Windows and blocks


– Multiple blocks correspond to
multiple windows.
– Window activation does not induce
navigation.
– Transaction management is block-
oriented.

6-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Built-ins for Manipulating Windows


• FIND_WINDOW
• GET_WINDOW_PROPERTY
• SET_WINDOW_PROPERTY
• HIDE_WINDOW
• SHOW_WINDOW
• MOVE_WINDOW
• RESIZE_WINDOW

Built-ins for Manipulating Canvases


• FIND_CANVAS, FIND_VIEW
• GET_CANVAS_PROPERTY
• GET_VIEW_PROPERTY
• SET_CANVAS_PROPERTY
• SET_VIEW_PROPERTY
• HIDE_VIEW
• SHOW_VIEW
• REPLACE_CONTENT_VIEW
• SCROLL_VIEW

Windows and Blocks


• Windows may contain multiple blocks and blocks may be located on
several windows.
• Forms will not automatically navigate to an item located in an activated window.
• Transaction management is block-oriented rather than window-oriented.

......................................................................................................................................................
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.

• Building a multiple-window form


– Using window interaction triggers
– Using window and canvas-view
built-ins
• Controlling window size using window
built-ins
• Enhancing the tab canvas functionality

6-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
6-26 Developer/2000: Build Forms II
Practice Session Overview: Lesson 6
......................................................................................................................................................

Practice Session Overview: Lesson 6


This practice guides you through managing multiple windows and canvases
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.
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
......................................................................................................................................................

Practice Session: Lesson 6


1 Manipulate a multiple-window form.
aOpen the ORDERS form 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.

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.

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-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

• Logical objects that handle relationship


between two blocks
• Created implicitly with a master-detail
form module
• Created explicitly with the New Relation
dialog box

7-3 Copyright  Oracle Corporation, 1998. All rights reserved.

The New Relation Dialog Box

7-4 Copyright  Oracle Corporation, 1998. All rights reserved.

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.

Creating a Relation Explicitly


1 Select the master block entry in the Object Navigator.
2 Click the Create icon.
The New Relation window is displayed.
3 Specify the name of the relation.
4 Specify the name of the master block.
5 Specify the name of the detail block.
6 Choose your master delete property.
7 Choose your coordination property.
8 Specify the join condition.
9 Click OK.
The new relation, new triggers, and new program units are highlighted in the
Object Navigator.

......................................................................................................................................................
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.

What Happens When You Modify a Relation?


• Changing the Master Deletes property from the default of Non-Isolated
to Cascading replaces the On-Check-Delete-Master trigger with the Pre-
Delete trigger.
• Changing the Master Deletes property from the default of Non-Isolated
to Isolated results in the removal of the On-Check-Delete-Master trigger.

......................................................................................................................................................
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.

Default Deferred Deferred


with auto without
query auto query

7-6 Copyright  Oracle Corporation, 1998. All rights reserved.

Join Condition

Creates primary-foreign key link between


blocks
Define using:
• Block and item names
• SQL equijoin syntax

7-7 Copyright  Oracle Corporation, 1998. All rights reserved.

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.

Coordination Property Use


Default Forces coordination of blocks to occur when-
ever the master record is changed by the user
or a trigger
Deferred with Auto Query Postpones potentially expensive detail query
processing until the cursor visits the related
blocks
Deferred without Auto Query Allows entry of additional query criteria in
the detail block prior to querying
Prevent Masterless Operations Ensures that the detail block cannot be que-
ried or used to insert records when a master
record is not displayed

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.

Implementation of Block Coordination


Forms implements block coordination through the following elements:
• The Copy Value from Item property on the foreign-key item in the detail
block, which specifies the corresponding primary-key item in the master
block
• Relation-handling triggers, which fire during the Clear and Populate
phases of block coordination
• Relation-handling procedures, which are called from relation-handling
triggers
Note: The elements above are controlled through the Relation object.

......................................................................................................................................................
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

7-9 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Characteristics of Relation-Handling Triggers


Forms automatically creates and maintains relation-handling triggers to
implement block coordination and restricted-delete foreign-key rules.

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.

Note: If you specify a cascade-delete foreign-key rule for a relation, Form


Builder uses a Pre-Delete trigger to implement this. However, this is a
commit trigger, not a relation-handling trigger. It can also be used outside
the context of relations.

......................................................................................................................................................
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.

Three relation-handling procedures:


• CLEAR_ALL_MASTER_DETAILS
• QUERY_MASTER_DETAILS
• CHECK_PACKAGE_FAILURE
Adding your own code to relation-
handling triggers
• Forms adds comments around code.
• You add your own code before or after
these comments.
7-10 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Developer/2000: Build Forms II 7-14
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................

Principles of Relation-Handling Code


Forms automatically creates and maintains the PL/SQL code that is executed
in the relation-handling triggers. You can add your own code to these

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.

Three Relation-Handling Procedures


Procedure Called From
CLEAR_ALL_MASTER_DETAILS On-Clear-Details trigger defined on the form
level
QUERY_MASTER_DETAILS On-Populate-Details trigger defined for each
master block
CHECK_PACKAGE_FAILURE On-Populate-Details trigger and the previous
procedures

Note: The CLEAR_ALL_MASTER_DETAILS procedure gives you an


example of how to recursively walk through a hierarchical tree of blocks.

Adding Your Own Code to Relation-Handling Triggers


Forms adds comments around the PL/SQL code that it generates for
relation-handling, for example:

--
-- 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.

System variables for relation-handling:


• SYSTEM.MASTER_BLOCK
• SYSTEM.COORDINATION_OPERATION

Built-ins for relation-handling:


• GET_FORM_PROPERTY
• GET/SET_BLOCK_PROPERTY
• GET/SET _RELATION_PROPERTY
7-11 Copyright  Oracle Corporation, 1998. All rights reserved.

Technical Note
You can use these system variables in the On-Clear-Details trigger only.
Assign their values to global variables to broaden the scope.

......................................................................................................................................................
Developer/2000: Build Forms II 7-16
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................

Obtaining Relation-Handling Information


You can use system variables and built-ins to obtain more information about
block-coordination and relation properties. This is useful if you want to

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.

System Variables for Relation-Handling


Name Description
SYSTEM.MASTER_BLOCK Contains the name of the master block that
drives the current block coordination.
SYSTEM.COORDINATION_OPERATION Contains the name of a block
coordination-causing event that occurred on
the driving master block. Value
examples of this system variable include
NEXT_RECORD, SCROLL_DOWN,
MOUSE, DELETE_RECORD, and
EXECUTE_QUERY.

Built-ins for Relation-Handling


Name Properties Concerning Relations
GET_FORM_PROPERTY FIRST_BLOCK,
LAST_BLOCK
GET_BLOCK_PROPERTY COORDINATION_STATUS(*),
NEXTBLOCK,
PREVIOUSBLOCK,
FIRST_DETAIL_RELATION,
FIRST_MASTER_RELATION
GET_RELATION_PROPERTY AUTOQUERY(*),
DEFERRED_COORDINATION(*),
MASTER_DELETES(*),
PREVENT_MASTERLESS_OPERATION(*),
DETAIL_NAME, MASTER_NAME,
NEXT_DETAIL_RELATION,
NEXT_MASTER_RELATION

(*): You can also set those properties.

......................................................................................................................................................
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.

Define procedure that toggles between


immediate and deferred coordination
• Use GET_BLOCK_PROPERTY to obtain
relation name.
• Use GET_RELATION_PROPERTY to
obtain current coordination type.
• Use SET_RELATION_PROPERTY to
switch to other coordination type.

7-12 Copyright  Oracle Corporation, 1998. All rights reserved.

Implementing a
Coordination-Type Toggle
Call this procedure from:
• When-Checkbox-Changed trigger
• Menu item of type Check

7-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Developer/2000: Build Forms II 7-18
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................

Implementing a Coordination-Type Toggle


You can use relation-handling built-ins to offer users the choice between
immediate coordination and deferred coordination.

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
......................................................................................................................................................

Forcing a Commit Per Master


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 a procedure that:


• Updates the commit status by
performing validation
• Checks the commit status of the master
record
• Raises FORM_TRIGGER_FAILURE in
case of changes

7-14 Copyright  Oracle Corporation, 1998. All rights reserved.

Forcing a Commit Per Master

Call the procedure:


• In the On-Clear-Details trigger
• Before the “ Begin default relation
program section” comment

7-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Developer/2000: Build Forms II 7-20
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................

Forcing a Commit Per Master


In some cases, you must commit changes in master-detail forms before a
change of master record takes place (for example, when checking database-

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

Elements involved in block-coordination


• Copy Value from Item property
• Relation-handling triggers and
procedures
Characteristics of relation-handling
triggers
Obtaining relation-handling information

7-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Elements Involved in the Implementation of Block Coordination


• The Copy Value from Item property
• Relation-handling triggers and procedures

Characteristics of Relation-Handling Triggers


• On-Clear-Details implements the Clear phase.
• On-Populate-Details implements the Populate phase.
• On-Check-Delete-Master implements restricted-delete rules.

Principles of Relation-Handling Code


• The three relation-handling procedures are
CLEAR_ALL_MASTER_DETAILS, QUERY_MASTER_DETAILS,
and CHECK_PACKAGE_FAILURE.
• Add your own code to relation-handling triggers before or after
comments generated by Forms.

Obtaining Relation-Handling Information


• There are two system variables for relation-handling.
• Built-ins for relation-handling can be used to get relation names and to
get or set relation properties.

......................................................................................................................................................
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.

• Examining and changing relation


properties
• Creating a relation explicitly
• Implementing a coordination-type
toggle for a master-detail form
• Implementing foreign-key delete rules
for a master-detail form

7-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
Developer/2000: Build Forms II 7-24
Lesson 7: Controlling Data Block Relationships
......................................................................................................................................................

Practice Session Overview: Lesson 7


This practice guides you through choosing the appropriate user-initiated and
forms event triggers to implement the desired form functionality.

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
......................................................................................................................................................

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:

Property Check Box 1 Check Box 2


Name IMMEDIATE AUTO_QUERY
Enabled Yes No
Label Immediate Auto Query
Value When Checked Y Y
Value When Unchecked N N
Check Box Mapping of CHECKED UNCHECKED
Other Value
Keyboard Navigable No No
Mouse Navigate No No
DataType CHAR CHAR
Initial Value Y Y
DataBase Item No No
Canvas TOOLBAR TOOLBAR

......................................................................................................................................................
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.

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

8-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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);

8-3 Copyright  Oracle Corporation, 1998. All rights reserved.

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 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-4 Developer/2000: Build Forms II
OPEN_FORM to Invoke Additional Forms
......................................................................................................................................................

OPEN_FORM to Invoke Additional Forms


This built-in procedure opens another form in a modeless fashion; that is, a
user can freely switch between open forms. You can open a form within 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.
same transaction scope or within a new transaction scope.

Syntax

OPEN_FORM(’form_name’, activate_mode, session_mode, data_mode,


paramlist);

Parameter Description
form_name The file holding the executable module
activate_mode Either ACTIVATE (the default) or NO_ACTIVATE
session_mode Either NO_SESSION (the default) or SESSION
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a Parameter List
(This argument is optional.)

Characteristics of OPEN_FORM
• Is a restricted procedure
• Causes opened form to be modeless
• Can start a new database session

......................................................................................................................................................
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)

Characteristics of the CLOSE_FORM Procedure


• CLOSE_FORM is a restricted procedure that is not valid in Enter Query
mode.
• When the specified form is the current form, CLOSE_FORM is
equivalent to EXIT_FORM.
• You cannot close a form that has called another form with
CALL_FORM.

......................................................................................................................................................
Developer/2000: Build Forms II 8-7
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

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.

• Built-ins for navigation between forms:


– NEXT_FORM
– PREVIOUS_FORM
– GO_FORM

8-6 Copyright  Oracle Corporation, 1998. All rights reserved.

Navigating Between Forms

• Navigational and validation aspects:


– Each open form has a current item
– No validation when navigating
between forms
– No triggers fire when navigating
between forms, except When-
Window-Activated/Deactivated, and
When-Form-Navigate triggers
– Clicking the noncurrent item in the
other form
8-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-8 Developer/2000: Build Forms II
Navigating Between Forms
......................................................................................................................................................

Navigating Between Forms


You can programmatically navigate between multiple forms that have been
opened with the OPEN_FORM built-in, just as you can navigate 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.
blocks within one form.

Built-ins for Navigation Between Forms


Built-in Description
NEXT_FORM Navigates to the open form with the next highest sequence num-
ber. (Forms are placed in sequence in the order that they were
invoked at run-time.) If there is no form with a higher sequence
number, the built-in navigates to the form with the lowest
sequence number.
PREVIOUS_FORM Navigates to the open form with the next lowest sequence number.
If there is no form with a lower sequence number, this built-in
navigates to the form with the highest sequence number.
GO_FORM Navigates to the specified form. You can use the form-module
name or the form-module ID as the form specification.

Navigational and Validation Aspects of Inter-Form Navigation


• In a multiple-form application, each open form has one item that is the
current item for that form.
• When navigating between open forms, no validation occurs in the
starting form. Upon returning to the starting form and attempting to
navigate within that form, normal validation is enforced.
• When navigating between (current items of) open forms, no triggers fire.
The only exceptions are the When-Window-Deactivated,
When-Window-Activated, and When-Form-Navigate triggers. Even the
navigational triggers do not fire when navigating between open forms.
• If a user clicks a noncurrent item of an open form, triggers that would
usually fire, when navigating from the current item to the target item,
fire. In this case, navigational triggers also fire and validation occurs as
required.

......................................................................................................................................................
Developer/2000: Build Forms II 8-9
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

Opening Forms Within the Same


Session
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.

• Commit processing in all forms within


the same session, in a certain order
• If error occurs, then focus set to
initiating form
• Messages per open form within the
same session
• CLEAR_FORM usually causes a
ROLLBACK statement

8-8 Copyright  Oracle Corporation, 1998. All rights reserved.

Opening Forms in Different


Sessions
Connection
Runform Server

Session
8-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-10 Developer/2000: Build Forms II
Transaction Processing for Opened Forms
......................................................................................................................................................

Transaction Processing for Opened Forms


Opening Forms Within the Same Session
At run-time, Form Builder automatically establishes a single connection to

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.

Opening Forms in Different Sessions


The multiple-session feature of Oracle Server allows a single client to
establish multiple database sessions within a single connection. All Oracle
Server transaction management and read-consistency features are
implemented at the session level. Therefore, commit processing, record
locking, and read-consistency behavior for two forms in different sessions is
the same as it would be for two independent forms with separate
connections.
• You can turn the Session option on for all Runform invocations by
setting the FORMS50_SESSION environment variable to True.
• Forms Runform must be running with the Session option turned on when
you execute OPEN_FORM with the SESSION_MODE parameter set to
SESSION.

......................................................................................................................................................
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);

8-10 Copyright  Oracle Corporation, 1998. All rights reserved.

Characteristics of CALL_FORM
• Unrestricted
• Valid in Enter Query mode
• Savepoint issued
• Modal with respect to calling form
• Does not cause navigation and
validation
• Forms called from query-only form are
always query-only
• Exiting a called form

8-11 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-12 Developer/2000: Build Forms II
CALL_FORM to Invoke Additional Forms
......................................................................................................................................................

CALL_FORM to Invoke Additional Forms


This built-in procedure calls another form in a modal fashion with respect to
the calling form; that is, a user cannot work in the calling form. When 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.
called form is exited, Form Builder returns to the calling form.

Syntax

CALL_FORM(’form_name’, display, switch_menu, query_mode,


data_mode, paramlist);

Parameter Description
form_name The file holding the executable form module.
display Either HIDE (the default) or NO_HIDE (This defines whether the 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
......................................................................................................................................................

Save Not Allowed in


Post-Only Mode 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.

A Calling form has unapplied changes.


Save not Allowed.

8-12 Copyright  Oracle Corporation, 1998. All rights reserved.

Transaction Processing for


Called Forms

• Characteristics of Post-Only mode:


– Commit not allowed, only a post
– Full rollback not allowed, only a
rollback to savepoint
• Rollback behavior of called forms
• Call savepoints and post savepoints

8-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-14 Developer/2000: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................

Transaction Processing for Called Forms


If you call forms, you need to understand the commit and rollback
processing between the 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.

Characteristics of Post-Only Mode


If a form runs in Post-Only mode, Forms does not allow certain commit
processing operations to prevent losing locks in the calling form.
• A commit is not allowed, only a post. An error message appears on the
status line: “A calling form has unapplied changes. Save not allowed.” If
a user makes changes in the called form and then exits from the form,
Forms usually asks if the user wants to Apply (post), rather then Save
(commit), the changes that were made.
• A full rollback is not allowed, only a rollback to savepoint.

Rollback Behavior of Called Forms


If a user exits from a called form, Form Builder issues a rollback to the call
savepoint that was set when the form was called. This means that all changes
posted in the called form are rolled back upon exit from the called form.

This is because of the EXIT_FORM built-in default arguments:

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.

Examples of adjusting default transaction


processing:
• Key-Commit on form

IF <form called> THEN


POST;
ELSE
COMMIT_FORM;
END IF;

8-14 Copyright  Oracle Corporation, 1998. All rights reserved.

Transaction Processing
for Called Forms
• Key-Exit on form
IF <form called> THEN
EXIT_FORM(ASK_COMMIT, NO_ROLLBACK);
ELSE
EXIT_FORM;
END IF;

– Adjust labels of corresponding


buttons and menu items
8-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-16 Developer/2000: Build Forms II
Transaction Processing for Called Forms
......................................................................................................................................................

Adjusting Default Transaction Processing for Called Forms


The characteristics of Post-Only mode and the rollback behavior of called
forms require that you adjust default transaction processing as follows:
• Redefine [Commit] so that it performs a post when the form is called.

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;

Key-Exit Trigger at Form Level

BEGIN
IF GET_APPLICATION_PROPERTY(calling_form) is not null THEN
EXIT_FORM(ask_commit, no_rollback);
ELSE
EXIT_FORM;
END IF;
END;

......................................................................................................................................................
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-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-18 Developer/2000: Build Forms II
NEW_FORM to Invoke Additional Forms
......................................................................................................................................................

NEW_FORM to Invoke Additional Forms


This built-in procedure exits from the current form and executes the
specified new form. The current form is completely replaced by the new

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

NEW_FORM(’form_name’, rollback_mode, query_mode, data_mode,


paramlist);

Parameter Description
form_name The file holding the executable form module
rollback_mode Either TO_SAVEPOINT (the default), NO_ROLLBACK, or
FULL_ROLLBACK
query_mode Either NO_QUERY_ONLY (the default) or QUERY_ONLY (This
defines whether the called form should run in Query Only mode.)
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a Parameter List
(This argument is optional.)

......................................................................................................................................................
Developer/2000: Build Forms II 8-19
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

Controlling Opened and


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.

Form A Form C Form D


OPEN_FORM
S.P.
CALL_FORM
CALL_FORM

Form B
OPEN_FORM
S.P.
CALL_FORM
Form F

Form E
Form A+B+E = Call Form Stack
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
......................................................................................................................................................

Controlling Open Forms and Called Forms Together


When you invoke multiple forms with OPEN_FORM and CALL_FORM in
the same application, you should be aware of certain restrictions.

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.

Restrictions on Using OPEN_FORM with CALL_FORM


• Navigation: Any attempt to navigate programmatically to a disabled
form in a call form stack is disallowed.
• Calling forms: An open form cannot execute the CALL_FORM built-in
if a call form stack has been initiated by another open form. In other
words, you can have only one call form stack per Runform session.
• Rollback: Forms issues a savepoint when calling a form with
CALL_FORM. Any subsequent rollback, in any form, rolls back only
the changes that were made since this savepoint.

......................................................................................................................................................
Developer/2000: Build Forms II 8-21
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

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.

• When to use OPEN_FORM


• When to open a form in a new session
• When to use CALL_FORM
• When to use NEW_FORM

8-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-22 Developer/2000: Build Forms II
Different Ways of Invoking Forms
......................................................................................................................................................

Different Ways of Invoking Forms


When to Use OPEN_FORM
OPEN_FORM is the preferred method of invoking another form. Because

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.

When to Open a Form in a New Session


Creating new sessions is usually appropriate for forms that manage
transactions that are logically independent. If the open forms act on tables
that are closely related, data manipulation of all those forms could be
considered part of one transaction. Therefore, the forms should be opened in
the same session.
Note: You can also consider using CALL_FORM in this situation.

When to Use CALL_FORM


Use CALL_FORM if you want the invoked form to be modal. This is
appropriate if the invoked form is used to set data in the invoking form, for
example, in the case of an LOV form. Another reason may be that you want
to make it easier to keep the invoking and invoked forms synchronized.

When to Use NEW_FORM


NEW_FORM is not used very often in practice. The main advantage of this
built-in is that it conserves memory because the invoked form replaces the
invoking form. Avoid using this built-in unless you have a lack of memory.

......................................................................................................................................................
Developer/2000: Build Forms II 8-23
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

Using Form Parameters


• What is a form 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.

• How to create a form parameter

8-19 Copyright  Oracle Corporation, 1998. All rights reserved.

Passing Values to a Form

Runform Form B
command line Design-time
parameters
Form A P1

P2
Run time
P3
OPEN_FORM
Parameter CALL_FORM
list
NEW_FORM

8-20 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
8-24 Developer/2000: Build Forms II
Using Form Parameters
......................................................................................................................................................

Using Form Parameters


What Is a Form Parameter?
Form parameters provide a mechanism for supplying values that a 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.
requires at startup. They are forms variables that you define at design time in
the Parameter Properties window.

Creating a Form Parameter


1 In the Object Navigator, create a parameter.
2 In the Property Palette window for the parameter, set the desired values
for Name, Subclass Information, Parameter Data Type, Maximum
Length, Parameter Initial Value, and Comments.

Passing Parameter Values to a Form


You can start a form from the command line or invoke it from another form.
In both cases, it is possible to specify values for form parameters.
• Specify the parameters on the Runform command line.
• Programmatically assign the parameters to a parameter list and specify
the parameter list in the call to OPEN_FORM, CALL_FORM, or
NEW_FORM.

......................................................................................................................................................
Developer/2000: Build Forms II 8-25
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

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.

• Passing a form parameter at run time:


f50run32 module=orditem userid=scott/tiger cus_id=202

• Referencing form parameters from


within a module:
– :PARAMETER.parameter_name
– ‘PARAMETER.parameter_name’

8-21 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

Referencing Form Parameters


You can reference form parameters in a way similar to Forms variables.
• To reference the parameter contents, use bind-variable syntax:
:PARAMETER.parameter_name, where the reserved word
PARAMETER is the fixed part
• To reference the parameter name, put the fully qualified name between
single quotation marks: ‘PARAMETER.parameter_name’

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

CUS_ID TEXT_PARAMETER ‘204’

ORDERS DATA_PARAMETER ‘RG_ORD’

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

Two Parameter Types


Type Description
Text Parameter A simple parameter that has a scalar, noncomposite CHAR value.
You must use this type of parameter, unless you want to pass a
record group to another Oracle product.
Data Parameter A parameter whose value must always be the name of a record
group defined in the current form. Data parameters are used to
pass data to products invoked with the RUN_PRODUCT built-in.
You cannot pass data parameters to forms.

Default Parameter List


Each form includes a built-in parameter list named DEFAULT. The
DEFAULT parameter list contains all of the form parameters that were
defined in the form at design time. Like any other parameter list, the
DEFAULT parameter list can be specified in the call to the built-ins that can
invoke a form.

......................................................................................................................................................
Developer/2000: Build Forms II 8-29
Lesson 8: Building Multiple Form Applications
......................................................................................................................................................

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.

CREATE_PARAMETER_LIST
Name Key Type Value

CUS_ID TEXT_PARAMETER ‘204’

Parameter
ORDERS DATA_PARAMETER ‘RG_ORD’
list ID

ADD_PARAMETER
GET_PARAMETER_ATTR
DESTROY_PARAMETER_LIST
SET_PARAMETER_ATTR
DELETE_PARAMETER

8-23 Copyright  Oracle Corporation, 1998. All rights reserved.

Technical Note
You cannot create a parameter list named DEFAULT or one that already
exists. Use GET_PARAMETER_LIST and ID_NULL to check whether a
parameter list already exists.

......................................................................................................................................................
8-30 Developer/2000: Build Forms II
Creating and Manipulating Parameter Lists
......................................................................................................................................................

Creating and Manipulating Parameter Lists


You can only programmatically create and manipulate parameter lists using
the following 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
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
......................................................................................................................................................

Passing Data Between Forms


Form A Form B
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.

Run time OPEN_FORM(*) Design-time


Parameter list parameters

P1 P1
P2 P2
P3 P3

• If a parameter list exists, destroy it.


• Create a parameter list.
• Add a text parameter to a list with the
value of an item.
• Open a form with this parameter list.
8-24 Copyright  Oracle Corporation, 1998. All rights reserved.

Passing Data Between Forms


• Characteristics of form parameters:
– Can only be used as input parameters
– Have datatype CHAR, NUMBER, or DATE
– CHAR parameter can be up to 64 K
length
– Can be design-time objects
• Characteristics of global variables:
– Are programmatic constructs
– Have type CHAR(255)
– Are visible to all forms in the current
Runform session
8-25 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Passing Data Between Forms


You can pass data to other forms using form parameters, as shown in the
following example. The next section compares this approach with the global

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.

Form Parameters and Global Variables


• Form parameters can only be used as input parameters; the invoked form
cannot return modified form-parameter values to the invoking form.
Therefore, global variables are the preferred method for communicating
between forms.
• Advantages of form parameters include:
- They have a datatype of CHAR, NUMBER, or DATE.
- The length of a CHAR parameter can be up to 64K.
- They can be design-time objects.
- Global variables are always programmatic constructs of type
CHAR(255). They are visible to all the forms in the current Runform
session.

......................................................................................................................................................
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.

– OPEN_FORM, CALL_FORM, and


CLOSE_FORM
– Multiple database sessions per
connect possible
• Navigation
– NEXT_FORM, PREVIOUS_FORM, and
GO_FORM
• Restrictions on the call form stack

8-26 Copyright  Oracle Corporation, 1998. All rights reserved.

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

Opening, Calling, and Closing Forms


• OPEN_FORM
• CALL_FORM
• CLOSE_FORM

Built-ins for Navigation Between Forms


• NEXT_FORM
• PREVIOUS_FORM
• GO_FORM

Controlling Open Forms and Called Forms Together


• Restrictions on the call form stack

Transaction Processing for Open Forms


• Within the same session or different sessions

Transaction Processing for Called Forms


• Characteristics of Post-Only mode
• Rollback behavior of called forms: default rollback to savepoint

Using Form Parameters


• Passing parameter values to a form by way of Runform command line or
parameter list
• Referencing form parameters using PARAMETER.parameter_name

Using Parameter Lists


• The two parameter types: text parameters and data parameters
• The default parameter list named DEFAULT
• Built-ins for creating and manipulating parameter lists

......................................................................................................................................................
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
......................................................................................................................................................

Practice Session Overview: Lesson 8


This practice guides through managing several interacting forms within one
application.

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
......................................................................................................................................................

Practice Session: Lesson 8


1 Produce a multiple form application by linking the CUSTOMERS and
the EMPLOYEES 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 In the control block of the CUSTOMERS form, create a button


called EMPLOYEE_BUTTON.
b Define a trigger for CONTROL.EMPLOYEE_BUTTON that calls
the EMPLOYEES form with the current sales representative is ID.
- Create a parameter list called SALES.
- Add the SALES_ID parameter to the parameter list. The type of this
parameter is TEXT_PARAMETER, and it is initialized with the
value of the SALES_REP_ID item.
- Invoke the EMPLOYEES form using the call_form built-in.
You can import the pr8_1b.txt file.
c Open the EMPLOYEES form module.
d In the Object Navigator, create a parameter called SALES_ID.
e Add a trigger to ensure that queries on the employee block are
restricted by the value of SALES_ID parameter. You can import the
pr8_1e.txt file.
f Save and compile each form, then run the CUSTOMERS form
module and test your application.
If you have time...
2 Transaction processing for called forms.
a Make sure that any changes in the EMPLOYEES form that are
posted by a user are not rolled back by Forms upon exit. You can
import the pr8_2a.txt file.
b Make sure that when the CUSTOMERS form calls the
EMPLOYEES form, [Commit] performs a post. You can import the
pr8_2b.txt file.
c Save and compile each form, then run the CUSTOMERS form
module and test your application.

......................................................................................................................................................
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.

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
• Describe the advantages of using a
FROM clause query
• Base a data block on a stored procedure
that returns a Ref cursor
• Select the appropriate data source for a
data block
9-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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
......................................................................................................................................................

Data Source 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.

Query DML

Table Table
FROM clause Company Name:
query
Company Code:
Stored Balance: Stored
procedure procedure
Transactional Transactional
trigger trigger

9-3 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-4 Developer/2000: Build Forms II
Data Sources Types
......................................................................................................................................................

Data Sources Types


In the previous course, Developer/2000: Build Forms I, you learned, a data
block had a base table that served as the data source for both queries and

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.

Data Sources for Query Operations


For query operations, you can base your blocks on:
• Database tables or views
• Stored procedures
• Transactional triggers
• The FROM clause query (subquery)
You can also change the base table of a block dynamically at run-time.

Data Sources for DML Operations


For DML operations, you can base your blocks on:
• Database tables or views
• Stored procedures
• Transactional triggers
A data block based on a stored procedure can return data from a Ref cursor
or a PL/SQL table of records. If your data block has database-intensive
multiple validation lookup or derived fields, this method of partitioning
application logic onto the server can improve application performance.

......................................................................................................................................................
Developer/2000: Build Forms II 9-5
Lesson 9: Defining Data Sources
......................................................................................................................................................

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.

SELECT...

FROM...

(SELECT...

FROM...

WHERE...)
WHERE...

9-4 Copyright  Oracle Corporation, 1998. All rights reserved.

Why Use a From Clause Query?

Perform joins, lookups, and calculations


on the server (thus avoiding multiple
network trips) without having to define a
view for every one
• Improves developer productivity
• Reduces burden on DBA
• Improves performance

9-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-6 Developer/2000: Build Forms II
Basing a Data Block on a From Clause Query
......................................................................................................................................................

Basing a Data Block on a From Clause Query


You can use a FROM clause as the data source for a data block. A FROM
clause is a feature of the Oracle7.3 Server that allows you to nest a SELECT

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

SELECT deptno, sal_total


FROM
( SELECT deptno, SUM(sal) sal_total
FROM emp
HAVING SUM(sal) > 5000
GROUP BY deptno
)
ORDER BY deptno ;

Why Use a From Clause Query?


FROM clauses are used to perform:
• Joins
• Lookups
• Calculations
This is done without having to create a view on the server. FROM clauses
can also be used to prototype views and to increase performance.
Using a FROM clause as a block data source is similar to using an
updateable join-view as a block data source. However, a FROM clause
provides you with more control, because the presence of a DBA is not
required to define the view.
Note: The FROM clause produces results that are identical to an updateable
join-view from the client side, but that there is no defined view on the server.

......................................................................................................................................................
Developer/2000: Build Forms II 9-7
Lesson 9: Defining Data Sources
......................................................................................................................................................

Basing a Data Block on a


Stored Procedure for 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.

Operations
Return data by way of
• Ref cursor
• Table of records

Procedure Querying Data block


Empno Ename Job Hiredate
Company Name:
1234 Jones Clerk 01-Jan-95
Company Code:
1235 Smith Clerk 01-Jan-95 Balance:
1236 Adams Clerk 01-Jan-95
1237 Clark Clerk 01-Jan-95

9-6 Copyright  Oracle Corporation, 1998. All rights reserved.

Basing a Data Block on a


Stored Procedure for DML
Operations
Return data by way of
• Table of records

Procedure Updating Data block


Empno Ename Job Hiredate
Company Name:
1234 Jones Clerk 01-Jan-95
Company Code:
1235 Smith Clerk 01-Jan-95 Balance:
1236 Adams Clerk 01-Jan-95
1237 Clark Clerk 01-Jan-95

9-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-8 Developer/2000: Build Forms II
Basing a Data Block on a Stored Procedure
......................................................................................................................................................

Basing a Data Block on a Stored Procedure


You can base a data block on a stored procedure. A stored procedure returns
a data block by using either 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.
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.

What Is a Table of Records?


A table of records is a PL/SQL V2.3 variable that is essentially an array of
rows.
You can think of it as an image of a table in memory. The server-side
procedure constructs this array, usually based on parameters passed to it, and
passes back the resulting “set” of records to a data block. Forms treats the
resulting table of records exactly as if it were fetching a series of rows from
a table.
Unlike a view or a Ref Cursor, you are not limited to what you can express
as a SQL SELECT statement. Anything you can code in PL/SQL is possible;
for example, a tree-walk that includes a join.
Using a table of records is extremely efficient in terms of the savings on
network traffic, because it takes a single round trip (from client to server) to
execute the stored procedure and a single round trip to return the records.

......................................................................................................................................................
Developer/2000: Build Forms II 9-9
Lesson 9: Defining Data Sources
......................................................................................................................................................

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.

Define a package specification with:


• The objects returned by the Ref cursor
• The Ref cursor
• The query procedure
– Data returned through the first
argument that is an IN OUT argument
Define a package body:
• Write the code for the query procedure
9-8 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-10 Developer/2000: Build Forms II
Example of Query Using a Ref Cursor Procedure
......................................................................................................................................................

Example of Query Using a Ref Cursor Procedure


This is an example of a stored procedure that returns a Ref cursor as a block
data source. A package is used to group the related data types and

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.

-- Define Package Specification


PACKAGE emp_pkg IS
-- Defines the objects returned by the Ref Cursor
TYPE emprec IS RECORD ( empno emp.empno%TYPE,
ename emp.ename%TYPE );

-- Defines the Ref Cursor


TYPE empcur IS REF CURSOR RETURN emprec;

-- Defines the procedure used for querying records


PROCEDURE empquery_refcur ( block_data IN OUT empcur,
p_deptno IN NUMBER);
END;

-- Defines Package Body


PACKAGE BODY emp_pkg IS
PROCEDURE empquery_refcur ( block_data IN OUT empcur,
p_deptno IN NUMBER)
IS
BEGIN
OPEN block_data FOR
SELECT empno, ename
FROM emp
WHERE deptno = NVL( p_deptno, deptno )
ORDER BY empno;
END;
END;

......................................................................................................................................................
Developer/2000: Build Forms II 9-11
Lesson 9: Defining Data Sources
......................................................................................................................................................

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.

Define a package specification with:


• The structure of each row of the table
• The table of records
• The procedure used for querying
records
– Data returned through the first
argument; that is, an IN OUT
argument
Define a package body:
• Write the code for the query procedure
9-9 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-12 Developer/2000: Build Forms II
Example of Query Using a Table of Records Procedure
......................................................................................................................................................

Example of Query Using a Table of Records Procedure


This is an example of a stored procedure that returns a table of records as a
block data source. A package is used to logically group the related data

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.

-- Define Package Specification


PACKAGE emp_pkg IS
-- Defines each row of the table
TYPE emprec IS RECORD ( empno emp.empno%TYPE,
ename emp.ename%TYPE );
-- Defines the Table of records
TYPE emptab IS TABLE OF emprec INDEX BY BINARY_INTEGER;
-- Defines the procedure used for querying records
PROCEDURE empquery_tab ( block_data IN OUT emptab,
p_deptno IN NUMBER );
END;
-- Defines Package Body
PACKAGE BODY emp_pkg IS
PROCEDURE empquery_tab ( block_data IN OUT emptab,
p_deptno IN NUMBER )
IS
i NUMBER;
CURSOR empsel IS
SELECT empno, ename
FROM emp
WHERE deptno = NVL( p_deptno, deptno );
BEGIN
OPEN empsel;
i := 1;
LOOP
FETCH empsel INTO block_data(i).empno,
block_data(i).ename;
EXIT WHEN empsel%NOTFOUND;
i := i + 1;
END LOOP;
END;
END;

......................................................................................................................................................
Developer/2000: Build Forms II 9-13
Lesson 9: Defining Data Sources
......................................................................................................................................................

Example of DML 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.

Define a package specification with:


• The structure of each row of the table
• The table of records
• A procedure to insert rows
• A procedure to update rows
• A procedure to delete rows
• A procedure to lock rows
Define a package body:
• Write the code for each DML procedure
9-10 Copyright  Oracle Corporation, 1998. All rights reserved.

Note: See Appendix F: EMP_PKG Package for a complete example of the


code.

......................................................................................................................................................
9-14 Developer/2000: Build Forms II
Example of DML Using a Stored Procedure
......................................................................................................................................................

Example of DML Using a Stored Procedure


This is an example of a stored procedure that inserts rows using a table of
records as a block data source. A package is used to logically group 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.
related data types and procedures. You should define procedures that update,
delete, and lock rows also.

-- Define Package Specification


PACKAGE emp_pkg IS
-- Defines each row of the table
TYPE emprec IS RECORD ( empno emp.empno%TYPE,
ename emp.ename%TYPE,
mgr emp.mgr%TYPE,
deptno emp.deptno%TYPE );
-- Defines the Table of records
TYPE emptab IS TABLE OF emprec INDEX BY BINARY_INTEGER;
-- Defines the procedure used for inserting records
PROCEDURE empinsert ( block_data IN emptab );
END;

-- Defines Package Body


PACKAGE BODY emp_pkg IS
PROCEDURE empinsert ( block_data IN emptab )
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt LOOP
INSERT INTO emp (empno, ename, mgr, deptno)
VALUES (block_data(i).empno, block_data(i).ename,
block_data(i).mgr, block_data(i).deptno);
END LOOP;
END;
END;

......................................................................................................................................................
Developer/2000: Build Forms II 9-15
Lesson 9: Defining Data Sources
......................................................................................................................................................

Returning a Ref Cursor


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.

SQL
SELECT

Procedure

Query 1 2 Ref cursor

Ref cursor
3

Fetched rows
4

9-11 Copyright  Oracle Corporation, 1998. All rights reserved.

Returning a Table of Records


Any
PL/SQL
Code
Procedure

Query 1 2 Cursor

Cursor
3

Table of records
4

9-12 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-16 Developer/2000: Build Forms II
Deciding Whether to Use a Ref Cursor or a Table of Records
......................................................................................................................................................

Deciding Whether to Use a Ref Cursor or a Table of


Records
When deciding whether to use a Ref cursor or a table of records, take into

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.

Queries or DML on a Table


Executing queries or DML on a table takes one round-trip per array size of
rows returned.

Queries with Stored Procedure Returning a Ref Cursor


Executing queries using a stored procedure that returns a Ref cursor takes
one round-trip to execute the stored procedure(1, 2), plus one round-trip
(3, 4) per array size of rows returned.

Queries or DML with Stored Procedure Using PL/SQL Tables of Records


Executing queries or DML with stored procedures using PL/SQL tables of
records takes one round-trip to execute the stored procedure (1,2) plus one
round-trip (3,4) for all the rows.

Performance Implications of Ref Cursors or Table of Records


If you are dealing with a large number of rows, the down side of PL/SQL
tables of records is that all the rows must be processed at once. For querying,
this means you might retrieve rows that the user does not need and never
displays.
• Ref cursor: Number of records fetched depends on Array Fetch property
value.
• Table of Records: All records are fetched.
If you want to view all records, table of records is more efficient. However,
if the table of records returns 10,000 records and you only look at 3, it is not
an efficient option. For querying and DML, you use an unnecessary amount
of memory because all the rows must be in memory at the same time.

......................................................................................................................................................
Developer/2000: Build Forms II 9-17
Lesson 9: Defining Data Sources
......................................................................................................................................................

Data Block Wizard


Use the Data Block Wizard to specify 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.

following:
• Data source type
• Query procedure
• Insert procedure
• Update procedure
• Delete procedure
• Lock procedure

9-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-18 Developer/2000: Build Forms II
Data Block Wizard
......................................................................................................................................................

Data Block Wizard


The Data Block Wizard simplifies and automates the process of creating
blocks. You saw how to use it in the previous course, Developer/2000: Build

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
......................................................................................................................................................

Data Block Properties for


Queries
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-14 Copyright  Oracle Corporation, 1998. All rights reserved.

Data Block Properties for DML

9-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-20 Developer/2000: Build Forms II
Data Block Properties
......................................................................................................................................................

Data Block Properties


Data Block Properties for Queries

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.)

Data Block Properties for DML

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
......................................................................................................................................................

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.

Base data block on a from clause


query to:
• Create a “ dynamic” view
• Perform validation and DML on the
server side

9-16 Copyright  Oracle Corporation, 1998. All rights reserved.

Data Source Guidelines

Base data block on a stored


procedure to:
• Increase control and security
• Specify SELECT statement at run time
• Query or update multiple tables
• Perform complex computations
• Perform validation and DML on the
server side

9-17 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-22 Developer/2000: Build Forms II
Data Source Guidelines
......................................................................................................................................................

Data Source Guidelines


Using a From Clause Query
You base a data block on a from clause query to:

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

Using Stored Procedures


You base a data block on a stored procedure when you want to:
• Increase control and security
Using a stored procedure, you do not have to grant select access on the
table to the users, just EXECUTE privileges on the procedure.
• Specify a SELECT statement at run-time
Using a Ref cursor, if the logged-on user is a manager, open the cursor as
SELECT lastname, salary FROM s_emp; otherwise open the cursor as
SELECT lastname, null FROM s_emp.
• Base a block on multiple tables
Using a Ref cursor and depending on some parameter to the procedure,
the cursor could be opened either as SELECT * FROM open_orders
(current data) or SELECT * FROM closed_orders (old data).
• Perform complex computations and decisions
Using a table of records, return the salary of all employees that you
manage, but NULL for the salary of other employees.
• Perform validation and DML on the server side
If your data block has multiple validation lookup or derived fields that
are database-intensive, this method of partitioning the application logic
onto the server can vastly improve the performance of applications.
• Encapsulate logic within a subprogram
• Reduce traffic through array processing using a Ref cursor

......................................................................................................................................................
Developer/2000: Build Forms II 9-23
Lesson 9: Defining Data Sources
......................................................................................................................................................

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.

Data Source Query DML

Table YES YES

View YES YES

FROM Clause YES NO

Proc-Ref Cur YES NO

Proc-Table Rec YES YES

Transac. Trigger YES YES

9-18 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-24 Developer/2000: Build Forms II
Data Source Guidelines
......................................................................................................................................................

Data Source Type Restrictions


When deciding on a data block source, consider your requirements:
• Will the block be used only to query 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.
• 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:

Data Source Allows Query Allows DML


YES YES
Table
YES YES
View
YES NO
FROM Clause
YES NO
Procedure using a Ref Cursor
YES YES
Procedure using a Table of Records
YES YES
Transactional Trigger

......................................................................................................................................................
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.

New data sources:


• Stored procedure (query and DML)
• FROM clause query (query only)
Stored procedures return:
• Ref cursors—limited to single SELECT
statement
• Table of records—can be complex
procedure

9-19 Copyright  Oracle Corporation, 1998. All rights reserved.

Summary

Use Data Block Wizard to specify:


• Data source type
• Procedures for queries, updates,
deletes, and locking
• Master-detail relationships

9-20 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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)

Stored Procedures Return


• Ref cursors—limited to single SELECT statement
• Table of records—can be complex procedure

Using Data Block Wizard


• Specify data source type
• Specify procedures for queries, updates, deletes, and locking
• Specify master-detail relationships

......................................................................................................................................................
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.

• Modifying the EMP block to base it on a


nested SELECT statement
• Enabling DML on the EMP block
• Creating a package containing a stored
procedure to return a Ref cursor
• Basing a block on the previous stored
procedure

9-21 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
9-28 Developer/2000: Build Forms II
Practice Session Overview: Lesson 9
......................................................................................................................................................

Practice Session Overview: Lesson 9


This practice guides through using other data sources.

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
......................................................................................................................................................

Practice Session: Lesson 9


1 Base the EMP block on a sub-query.
a Open the EMPLOYEES form 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.

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)

d Set the block KeyMode property to Updateable.


e Define the ID item as a primary key for the block.
f Save, run and test your module.

......................................................................................................................................................
9-30 Developer/2000: Build Forms II
Practice Session: Lesson 9
......................................................................................................................................................

2 Enable DML on the EMP block without using transactional triggers.


aSet the block DML Target Name.
b Set the Query Only, Update Allowed, Insert Allowed properties for
the S_DEPT items (NUM, NAME, REGION_ID).

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.

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
10-2 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Three record group types:

SOURCE Based on a Not Based


SELECT on a SELECT
TIME Statement Statement

Design Time QUERY STATIC

Run Time QUERY NON QUERY

10-3 Copyright  Oracle Corporation, 1998. All rights reserved.

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 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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.

Three Record Group Types


Type Description
Query Record Group A record group that has an associated SELECT statement.
The columns in the record group derive their properties from
the columns in this SELECT statement. The rows in the
record group are the rows retrieved by this SELECT
statement. This type of record group can be created at design
time and at run-time.
Non-query Record Group A record group without an associated query. The columns and
rows of the record group are defined programmatically at
run-time and can also be modified at run-time.
Static Record Group A record group without an associated query. The columns and
rows of the record group are defined at design time and
cannot be modified programmatically at run-time.

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.

Record Groups and LOVs


When you create a List of Values (LOV) based on a query, Form Builder
implicitly creates a query record group. In this case, the columns and rows
of the record group are determined by the LOV-SELECT statement. At
run-time, you can call the SET_LOV_PROPERTY built-in function to
replace the default record group of a LOV with another one. Use the
GROUP_NAME property.

......................................................................................................................................................
Developer/2000: Build Forms II 10-5
Lesson 10: Working with Record Groups
......................................................................................................................................................

Uses for 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
• Storing form-configuration information
• Communicating within a form
• Passing data to other forms
• Passing data to other Oracle products
• Populating or storing list items

10-5 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-6 Developer/2000: Build Forms II
Using Record Groups
......................................................................................................................................................

Using Record Groups


Record groups are very powerful constructs offered by Forms. Some useful
record group applications are listed below.

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.

Storing Form-Configuration Information


Because a record group is a structured data type, you can use it as a
convenient means for storing information about the current form. Such
information may describe the way in which the form is set up or configured,
and is usually retrieved at form start-up.

Communicating within a Form


Because a record group is a structured data type, you can use it to exchange
related data within a form. For example, different program units or different
invocations of the same program unit might access the record group data.
This offers you an alternative to a set of scalar variables, such as help items
or global variables.

Passing Data to Other Forms


You can create a global record group at run-time which is visible to all forms
in an application.

Passing Data to Other Oracle Products


You can use the RUN_PRODUCT built-in to pass data by way of a record
group to another Oracle product, specifically Report and Graphics. This
eliminates the need to perform a query again in the other Oracle product if it
has already been executed by Forms.

Populating or Storing List Items


You can transfer the values of a record group to a list item. Because the
record group may be based on a dynamically constructed SELECT
statement, this ability gives you the opportunity to create dynamic list items.
The data transfer is bi-directional; you can also transfer the values of a list
item to a record group. (This can be considered “storing” the list item.)

......................................................................................................................................................
Developer/2000: Build Forms II 10-7
Lesson 10: Working with Record Groups
......................................................................................................................................................

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.

10-6 Copyright  Oracle Corporation, 1998. All rights reserved.

Column Specification and


Record Group Property Sheet

10-7 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-8 Developer/2000: Build Forms II
Defining Record Groups at Design Time
......................................................................................................................................................

Defining Record Groups at Design Time


Creating a Query Record Group
1 In the Object Navigator, create a record group.

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.

Creating a Static Record Group


1 In the Object Navigator, create a record group.
Forms displays the New Record Group dialog box.
2 Click the Static Values radio button and then click OK.
Forms displays the Column Specification dialog box.
3 Enter the names of the columns in the Column Name list.
4 Specify the Data Type, Length, and Column Values properties for each
column.
Note that these properties apply to the column currently selected in the
Column Name list.
5 Click OK to accept the record group definition.

Modifying the SELECT Statement of a Query Record Group


1 In the Object Navigator, select the desired record group.
2 In the Properties window, call the Editor from the Record Group Query
property.
3 Modify the SELECT statement as desired and then click OK.

Modifying the Column Definitions of a Record Group


1 In the Object Navigator, select the desired record group.
2 In the Properties window, double-click the Column Specifications
property. Forms displays the Column Specification dialog box.
3 Select a column and modify its Data Type, Length, and Column Values
properties as desired and then click OK.

......................................................................................................................................................
Developer/2000: Build Forms II 10-9
Lesson 10: Working with Record Groups
......................................................................................................................................................

Creating and Deleting 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.

Name + SELECT id, name


Name
FROM s_customers

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.

Modifying the Structure

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
......................................................................................................................................................

Built-in Functions for Controlling Record Groups


You can create and modify query and non-query record groups
programmatically at run-time using the following built-in 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.
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

Modifying the Structure of Record Groups


Built-in Function Description
ADD_GROUP_COLUMN Adds a column of the specified data type (and
column width for CHAR columns) to the given
record group and returns the ID of this group
column
ADD_GROUP_ROW Adds a row with the specified row number to the
given record group
DELETE_GROUP_ROW Deletes the specified row or all rows of the given
record group

......................................................................................................................................................
Developer/2000: Build Forms II 10-11
Lesson 10: Working with Record Groups
......................................................................................................................................................

Populating Query 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.

SELECT ID, name


FROM s_customer
ID Name
201 Unisports
202 SImms Athletics
203 Delhi Sports POPULATE_GROUP
204 Womansport (_WITH_QUERY)

10-10 Copyright  Oracle Corporation, 1998. All rights reserved.

Getting and Setting Record


Group Cell Values

ID Name
SET_GROUP_CHAR_CELL

GET_GROUP_NUMBER_CELL

10-11 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Populating Record Groups


Built-in Function Description
POPULATE_GROUP Executes the query associated with the given

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.

Getting Record Group Cell Values


Built-in Function Description
GET_GROUP_CHAR_CELL, Returns the value for the record group cell
GET_GROUP_DATE_CELL, identified by the given record group column
GET_GROUP_NUMBER_CELL and row number (The record group column
must be of data type VARCHAR2 or LONG,
DATE, or NUMBER, respectively.)

......................................................................................................................................................
Developer/2000: Build Forms II 10-13
Lesson 10: Working with Record Groups
......................................................................................................................................................

Processing Record Group Rows


GET_GROUP_SELECTION_COUNT
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.

Selection No Row No ID Name


1 201 Unisports
1 2 202 Simms Athletics
3 203 Delhi Sports
2 4 204 Womansport

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
......................................................................................................................................................

Processing Record Group Rows


Built-in Function Description
GET_GROUP_ROW_COUNT Returns the number of rows in the given

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

Finding Record Group Objects


Built-in Function Description
FIND_GROUP Returns the internal record group ID (of type RECORDGROUP)
of a record group with the given name (This function can also be
used for record groups created at design time.)
FIND_COLUMN Returns the internal group column ID (of type
GROUPCOLUMN) of a record group column with the given
name (Note that this name must include the record group name as
a prefix. This function can also be used for group columns created
at design time.)

......................................................................................................................................................
Developer/2000: Build Forms II 10-15
Lesson 10: Working with Record Groups
......................................................................................................................................................

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.

Find record group

Yes ID NULL? No

Create group from query

Populate group

10-13 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-16 Developer/2000: Build Forms II
Defining Query Record Groups Programmatically
......................................................................................................................................................

Defining Query Record Groups Programmatically


The PL/SQL code below illustrates how you can create and populate a query
record group.

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
......................................................................................................................................................

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.

Find record group

Yes ID NULL? No

Create group Delete group rows

Add group columns Find group columns

Add group row

Set group cell values

10-14 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-18 Developer/2000: Build Forms II
Defining Non-Query Record Groups Programmatically
......................................................................................................................................................

Defining Non-Query Record Groups Programmatically


The PL/SQL code below illustrates how you can create and populate a non-
query record group. Note that non-query record groups cannot be defined at

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
......................................................................................................................................................

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.

Get number of group rows

Cell value=
For all Given value
group Yes No
rows
Return row
number

Return NULL

10-15 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-20 Developer/2000: Build Forms II
Manipulating Record Group Rows
......................................................................................................................................................

Manipulating Record Group Rows


The function below illustrates how you can loop through all rows of a record
group.

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
......................................................................................................................................................

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.

Get number of group rows

Row number
For all even?
group Yes No
rows
Mark row
as selected

10-16 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-22 Developer/2000: Build Forms II
Manipulating Selected Record Group Rows
......................................................................................................................................................

Manipulating Selected Record Group Rows


The following procedure illustrates how you can select the rows of a record
group.

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
......................................................................................................................................................

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.

• Record group visible to all forms in an


application
• “ Scope” parameter
– FORM_SCOPE (default)
– GLOBAL_SCOPE
...CREATE_GROUP(group_name, scope);
...CREATE_GROUP_FROM_QUERY(group_name,
query, scope);

10-17 Copyright  Oracle Corporation, 1998. All rights reserved.

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
......................................................................................................................................................

Defining Global Record Groups


A global record group allows creation at run-time of record groups that are
visible to all forms in an application.

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
......................................................................................................................................................

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.

• 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.

Using a Record Group with a


Labels
List Item Values

POPULATE_LIST RETRIEVE_LIST
CHAR Column 1 CHAR Column 2

10-19 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-26 Developer/2000: Build Forms II
Manipulating List Items Programmatically
......................................................................................................................................................

Manipulating List Items Programmatically


When you define a list item at design time, you specify the possible labels
and values on the Properties window. However, you can also manipulate list

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

Using a Record Group with a List Item


You can transfer information between a list item and a record group using
the POPULATE_LIST and RETRIEVE_LIST built-in functions. The record
group that is used as the second parameter for these functions must satisfy
these requirements:
• The record group must contain exactly two group columns of type
CHAR.
• The first group column must store the list element label.
• The second group column must store the list element value.

......................................................................................................................................................
Developer/2000: Build Forms II 10-27
Lesson 10: Working with Record Groups
......................................................................................................................................................

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.

Find record group

Yes ID NULL? No

Create group from query

Populate group

Yes Success? No

Populate list

Display first list label

10-20 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-28 Developer/2000: Build Forms II
Implementing Dynamic List Items
......................................................................................................................................................

Implementing Dynamic List Items


The procedure and trigger below illustrate how you can populate a list item
programmatically at run-time using a given SELECT statement.

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;

When-Create-Record on the ORD Block

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
......................................................................................................................................................

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.

Get number of list elements

Element value=
For all Item value?
list Yes No
elements
Return

Add list element with item value

10-21 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-30 Developer/2000: Build Forms II
Adding Values to Combo Boxes
......................................................................................................................................................

Adding Values to Combo Boxes


For a combo box, you can choose an existing value from the list, but also
type in a new value. The procedure and trigger below show how a new 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.
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;

When-Validate-Item on the ORD.PAYMENT_TYPE Item (combo box)

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.

A record group is a data structure similar


to a database table.
• Query, nonquery, and static records
• Defining record groups at design time
• Built-in functions for record groups
• Global record groups

10-22 Copyright  Oracle Corporation, 1998. All rights reserved.

Summary

• Uses for record groups:


– Constructing dynamic SELECT
statements
– Storing or passing data
– Populating or storing list items
• Manipulating list items
programmatically
– Built-in functions for list items

10-23 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
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

Defining Record Groups at Design Time


• Creating query and static record groups
• Modifying SELECT statements and column definitions of record groups

Built-ins for Controlling Record Groups


• Creating and deleting record groups
• Modifying the structure of record groups
• Populating record groups
• Getting record group cell values
• Processing record group rows
• Finding record group objects

Defining a Global Record Group


• Creating at run-time only
• Visible to all forms in an application
• Scope parameter

Uses for Record Groups


• Constructing dynamic SELECT statements
• Storing form configuration information
• Communicating within a form
• Passing data to other Oracle products
• Populating or storing list items

Manipulating List Items Programmatically


• Built-in for list items

......................................................................................................................................................
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.

• Converting a text item into a


dynamically populated list item
• Creating a list of values form where you
can select multiple values
simultaneously

10-24 Copyright  Oracle Corporation, 1998. All rights reserved.

......................................................................................................................................................
10-34 Developer/2000: Build Forms II
Practice Session Overview: Lesson 10
......................................................................................................................................................

Practice Session Overview: Lesson 10


This practice guides you through some useful record groups applications.

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
......................................................................................................................................................

Practice Session: Lesson 10


1 Create a dynamic list item. This functionality avoids having to create a
new item to display the department name.
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 Open the EMPLOYEES form module.


b Create a design time query record group that contains IDs and names
of departments. Name your record group DEPT_ID.
In the Object Navigator, create a record group; for example, based on the
query below:

SELECT name || ’ in region ’ || TO_CHAR(region_id) Name,


TO_CHAR(id) Id
FROM s_dept
ORDER BY 1

c Convert the text item DEPT_ID into a list item, Combo Box Style.
Resize it in the Layout Editor.
d Create an element in the list. Label: Dummy and Value: 0
e Create a procedure called LIST_FROM_DESIGNTIME_GROUP.
This procedure accepts the list item name as an argument and
populates the list item dynamically at 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
......................................................................................................................................................

c Examine this new module and save it as lov_product.fmb.


This new form contains a multi-record block based on the
S_PRODUCT table. Only the ID, NAME, and
SUGGESTED_WHLSL_PRICE columns are displayed.

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
......................................................................................................................................................

h In the LOV_PRODUCT form, create a When-New-Form-Instance


trigger to retrieve the list of products excluding the products that
exist in the S_ITEM block. You should use the global variable
created earlier. You can import the pr10_2h.txt file.
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 In the ORDERS form, modify the When-Button-Pressed trigger for


the CONTROL.PRODUCT_LOV_BUTTON. After you call the
form, the code creates records in the S_ITEM block for each row
selected in the record group. The code then deletes the record
group.You can import the pr10_2i.txt file.
j Save, run, and test your forms.

......................................................................................................................................................
10-38 Developer/2000: Build Forms II

You might also like