Вы находитесь на странице: 1из 642

Oracle iDS Forms:

Build Internet Applications II

Volume 1 Student Guide

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

40034GC11
Production 1.1
June 2001
DXXXXX
Author Copyright Oracle Corporation, 2001. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It is


Ian Purvis
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
Technical following legend is applicable:
Contributors and
Reviewers Restricted Rights Legend
Use, duplication or disclosure by the Government is subject to restrictions for
Cem Ayberkin 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
Gunnar Bohrs
252.227-7013, Rights in Technical Data and Computer Software (October 1988).
Brian Boxx
This material or any portion of it may not be copied in any form or by any means
Libor Danek without the express prior written permission of the Worldwide Education Services
Laurent Dereac group of Oracle Corporation. Any other copying is a violation of copyright law and
Brain Fry may result in civil and/or criminal penalties.

Pam Gamer If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with Restricted Rights, as defined in
Pascal Gibert
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Thierry Guibert
The information in this document is subject to change without notice. If you find
Ellen Gravina any problems in the documentation, please report them in writing to Education
Norris Gray Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Anthony Hargreaves Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Ali Hiemstra
Oracle Developer, Oracle Server, and PL/SQL are trademarks or registered
Barry Hiern
trademarks of Oracle Corporation.
Ursula Hovy
All other products or company names are used for identification purposes only,
Sarah Jones and may be trademarks of their respective owners.
Jan Keuben
Aija Lehtonen
Regis Louis
Kenji Makita
Jayne Marlow
Sergei Pechersky
Milos Randak
Jonas Reborg
Bryan Roberts
Candace Stover
Hiroyuki Sugiyama
Laura Tejero
Jack Walsh

Publisher
Shane Mattimoe
Contents
.....................................................................................................................................................

Contents
Preface
Profile xv
Related Publications xvi
Typographic Conventions xvii

Introduction
Introduction I-2
Course Content I-3

Lesson 1: Creating a Menu Module


Introduction 1-3
Components of the Menu Module 1-5
The Default Menu 1-7
The Menu Editor 1-9
Creating a Menu Module 1-11
Module Properties 1-13
Menu Properties 1-15
Menu Item Properties 1-17
Menu Item Types 1-19
Menu Item Command Types 1-21
Implementing Menu Toolbars 1-23
Storing the Menu Module 1-25
Attaching the Menu Module 1-27
Pop-up Menus 1-29
Summary 1-31
Practice Overview: Lesson 1 1-33
Practice 1 1-34

Lesson 2: Managing Menu Modules


Introduction 2-3
Using PL/SQL in Menu Item Code 2-5
Useful Built-in Menu Subprograms 2-7

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II iii
Contents
.....................................................................................................................................................

Showing and Hiding the Current Menu 2-9


Managing Menu Security 2-11
Defining Security Roles 2-13
Assigning Access to Menu Items 2-15
Summary 2-17
Practice Overview: Lesson 2 2-19
Practice 2 2-20

Lesson 3: Programming Function Keys


Introduction 3-3
Key Triggers 3-5
Defining Key Triggers 3-7
Characteristics of Key Triggers 3-9
Classification of Key Triggers 3-11
Using Key Triggers 3-15
Association with Other Interface Controls 3-17
Summary 3-19
Practice Overview: Lesson 3 3-21
Practice 3 3-22

Lesson 4: Responding to Mouse Events


Introduction 4-3
What Are Mouse Events? 4-5
Responding to Mouse Movement 4-7
Responding to Mouse Button Actions 4-11
Summary 4-15
Practice Overview: Lesson 4 4-17
Practice 4 4-18

Lesson 5: Controlling Windows and Canvases Programmatically


Introduction 5-3
Using Window-Interaction Triggers 5-5
Built-ins for Manipulating Windows 5-7
Built-ins for Manipulating Canvases 5-9

.....................................................................................................................................................
iv Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................

Working with Tab-Style Canvases 5-11


Windows and Blocks 5-15
Manipulating Window Properties Programmatically 5-17
Closing Windows 5-19
Manipulating Windows in Web-Deployed Forms 5-21
Sizing Windows for Web-Deployed Forms 5-23
Display Large Data Blocks in a Window 5-25
Managing Images for Web-Deployed Forms 5-27
Summary 5-29
Practice Overview: Lesson 5 5-31
Practice 5 5-32

Lesson 6: Defining Data Sources


Introduction 6-3
Data Source Types 6-5
Basing a Data Block on a FROM Clause Query 6-7
Basing a Data Block on a Stored Procedure 6-9
Example of a Query Using a REF Cursor Procedure 6-11
Example of Query Using a Table of Records Procedure 6-13
Example of DML Using a Stored Procedure 6-15
Deciding Whether to Use a REF Cursor or a Table
of Records 6-17
Data Block Wizard 6-19
Data Block Properties 6-21
Data Source Guidelines 6-23
Summary 6-27
Practice Overview: Lesson 6 6-29
Practice 6 6-30

Lesson 7: Working with Oracle8i Objects in Form Builder


Introduction 7-3
What Are Object Types? 7-5
Review of Objects 7-7
Object REFs 7-9

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II v
Contents
.....................................................................................................................................................

Supported Oracle8i Features 7-11


How Oracle Forms Developer Treats Objects 7-13
Object Type Displays 7-15
Creating Data Blocks Based on Oracle8i Objects 7-17
Selecting Object Table Columns 7-19
Selecting Object Column Attributes 7-21
Blocks with REF Lookups 7-23
The REF Column Value 7-25
LOVs for REFs 7-27
Summary 7-29
Practice Overview: Lesson 7 7-31
Practice 7 7-32

Lesson 8: Controlling Data Block Relationships


Introduction 8-3
Creating a Relation 8-5
Block Coordination 8-7
Coordinate Blocks Using REFs 8-9
Characteristics of Relation-Handling Triggers 8-11
Principles of Relation-Handling Code 8-13
Obtaining Relation-Handling Information 8-15
Implementing a Coordination-Type Toggle 8-17
Forcing a Commit Per Master 8-19
Summary 8-21
Practice Overview: Lesson 8 8-23
Practice 8 8-24

Lesson 9: Building Multiple Form Applications


Introduction 9-3
OPEN_FORM to Invoke Additional Forms 9-5
Closing Forms 9-7
Navigating Between Forms 9-9
Transaction Processing for Opened Forms 9-11
CALL_FORM to Invoke Additional Forms 9-13

.....................................................................................................................................................
vi Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................

Transaction Processing for Called Forms 9-15


NEW_FORM to Invoke Additional Forms 9-19
Controlling Open Forms and Called Forms Together 9-21
Different Ways of Invoking Forms 9-23
Using Form Parameters 9-25
Parameter Lists 9-29
Creating and Manipulating Parameter Lists 9-31
Passing Data Between Forms 9-33
Summary 9-35
Practice Overview: Lesson 9 9-37
Practice 9 9-38

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 Nonquery 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 Overview: Lesson 10 10-35
Practice 10 10-36

Lesson 11: Using Reusable Components


Introduction 11-3
Reusable Components 11-5
Reusable Components List 11-7

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II vii
Contents
.....................................................................................................................................................

The Calendar Class 11-11


Calendar Object Group Content 11-13
Built-in for Manipulating the Calendar 11-15
Summary 11-17
Practice Overview: Lesson 11 11-19
Practice 11 11-20

Lesson 12: Using Java with Web-Deployed Forms


Introduction 12-3
Java and Oracle Forms Developer 12-5
Java in Web-Deployed Forms 12-7
The Forms Applet 12-9
Defining Fonts for Web-Deployed Forms 12-11
Pluggable Java Components 12-13
What Is a Bean Area? 12-17
Hosting a JavaBean 12-19
How a JavaBean Communicates 12-21
Communicating with the JavaBean 12-23
Exploiting Oracle8i Features 12-25
How to Create JavaBeans 12-27
The Java Importer 12-29
The Java Importer Tool 12-31
Summary 12-33
Practice Overview: Lesson 12 12-35
Practice 12 12-36

Lesson 13: Using Server Features in Form Builder


Introduction 13-3
Using Oracle Database Server Functionality in Forms 13-5
Dealing with PL/SQL Code 13-7
PL/SQL8 Support 13-9
PL/SQL8 Scalar Data Types 13-11
Unsupported Oracle Forms Developer PL/SQL8 Features 13-13
Handling Errors Raised by the Oracle Database Server 13-15

.....................................................................................................................................................
viii Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................

Performing DDL with FORMS_DDL 13-19


Using FORMS_DDL 13-21
Summary 13-23
Practice Overview: Lesson 13 13-25
Practice 13 13-26

Lesson 14: Applying Timers


Introduction 14-3
Timers 14-5
Handling Timer Expiration 14-7
Creating a Timer 14-9
Modifying a Timer 14-11
Deleting a Timer 14-13
Summary 14-15
Practice Overview: Lesson 14 14-17
Practice 14 14-18

Lesson 15: Including Charts and Reports


Introduction 15-3
Including Charts by Using the Chart Wizard 15-5
Chart Item Properties 15-11
Reporting Within Form Builder 15-13
Report Object Properties 15-15
Working with Reports 15-17
Summary 15-23
Practice Overview: Lesson 15 15-25
Practice 15 15-26

Appendix A: Practice Solutions


Practice 1 Solutions A-2
Practice 2 Solutions A-6
Practice 3 Solutions A-9
Practice 4 Solutions A-11
Practice 5 Solutions A-12

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II ix
Contents
.....................................................................................................................................................

Practice 6 Solutions A-15


Practice 7 Solutions A-16
Practice 8 Solutions A-18
Practice 9 Solutions A-21
Practice 10 Solutions A-24
Practice 11 Solutions A-27
Practice 12 Solutions A-30
Practice 13 Solutions A-33
Practice 14 Solutions A-35
Practice 15 Solutions A-37

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_ITEM Description B-13
S_ITEM Data B-14
S_ORD Description and Data B-16
S_PRODUCT Description B-17
S_PRODUCT Data B-18
S_REGION Description and Data B-22
S_TITLE Description and Data B-23
Oracle8i Objects: Types, Tables B-24

Appendix C: Mouse Movement Events


Introduction C-2
Drag and Drop C-4
Summary C-6

Appendix D: Introduction to Oracle8i Object Features


Introduction D-3

.....................................................................................................................................................
x Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................

New Oracle8i Data Types D-5


Object Types D-7
Creating Oracle8i Objects D-11
Object Columns D-13
Object Views D-15
INSTEAD-OF Triggers D-17
Referencing Objects D-19
Displaying Oracle8i Objects in the Object Navigator D-21
Summary D-29

Appendix E: Menu Run-Time Parameters


Introduction E-3
Substitution Parameters E-5
Defining a User-Named Substitution Parameter E-7
Substitution Parameter Built-ins E-9
Validating a Substitution Parameter Value E-11
Summary E-13

Appendix F: Handling Server-Side Errors


Introduction F-3
Obtaining the Cause of Declarative-Constraint Violations F-5
Customizing Oracle Server Error Messages F-7
Example Procedure for Handling Oracle Server Errors F-9
Summary F-13

Appendix G: EMP_PKG Package


Package Specification G-2
Package Body G-4

Appendix H: Working with ActiveX Controls


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

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II xi
Contents
.....................................................................................................................................................

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: Using Oracle Server Roles at Run Time


Using Oracle Server Roles at Run Time I-3
Procedures for Managing Roles I-7

.....................................................................................................................................................
xii Oracle iDS Forms: Build Internet Applications II
Preface

.................................
Preface
.....................................................................................................................................................

Notes Page

.....................................................................................................................................................
xiv Oracle iDS Forms: Build Internet Applications II
Profile
.....................................................................................................................................................

Profile
Before You Begin This Course
Before you begin this course, you should have the following qualifications:
Thorough knowledge of:
- Creating simple applications with Oracle Forms Developer Form
Builder
- Creating SQL query statements
Working experience of:
- Creating PL/SQL constructs, including conditional statements,
procedures, and functions
- Creating PL/SQL stored (server) procedures and functions
Knowledge of using a graphical user interface (GUI)
Knowledge of using a Web browser, and downloading HTML pages
with a Uniform Resource Locator (URL)

Prerequisites
The following instructor-led training (ILT) course: Oracle 9iDS Forms:
Build Internet Applications I

Suggested Follow-up Courses


Oracle 9iDS Reports: Build Internet Reports
Oracle 9iAS Forms Services: Deploy Internet Applications

How This Course Is Organized


Oracle 9iDS Forms: Build Internet Applications II is an instructor-led
course featuring lectures and hands-on exercises. Online demonstrations and
written practices reinforce the concepts and skills introduced.

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II xv
Preface
.....................................................................................................................................................

Related Publications
Oracle Publications
Title Part Number
Oracle Forms Developer and Oracle Reports Developer Guide- A73073-02
lines for Building Applications, Release 6i
Oracle Forms Developer Getting Started, Release 6i A73154-01
Oracle Forms Server Release 6i Patch 2: Deploying Forms Appli- A86202-01
cations to the Web with the Oracle Internet Application Server

Additional Publications
read.me file
relnotes.pdf file

.....................................................................................................................................................
xvi Oracle iDS Forms: Build Internet Applications II
Typographic Conventions
.....................................................................................................................................................

Typographic Conventions
Typographic Conventions in Text
Convention Element Example
Bold italic Glossary term (if The algorithm inserts the new key.
there is a glossary)
Caps and lowercase Buttons, Click the Executable button.
check boxes, Select the Cant Delete Card check box.
triggers,
Assign a When-Validate-Item trigger . . .
windows
Open the Master Schedule window.
Courier new, Code output, Code output: debug.seti(I,300);
case sensitive directory names, Directory: bin (DOS), $FMHOME (UNIX)
(default is filenames,
Filename: Locate the init.ora file.
lowercase) passwords,
pathnames, Password: Use tiger as your password.
URLs, Pathname: Open c:\my_docs\projects
user input, URL: Go to http://www.oracle.com
usernames User input: Enter 300
Username: Log on as scott
Initial cap Graphics labels Customer address (but Oracle Payables)
(unless the term is a
proper noun)
Italic Emphasized words Do not save changes to the database.
and phrases, For further information, see Oracle7 Server
titles of books SQL Language Reference Manual.
and courses,
Enter user_id@us.oracle.com, where
variables
user_id is the name of the user.
Quotation marks Interface elements Select Include a reusable module
with long names component and click Finish.
that have only This subject is covered in Unit II, Lesson 3,
initial caps; lesson Working with Objects.
and chapter titles in
cross-references
Uppercase SQL column Use the SELECT command to view
names, commands, information stored in the LAST_NAME
functions, schemas, column of the EMP table.
table names

.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II xvii
Preface
.....................................................................................................................................................

Convention Element Example


Arrow Menu paths Select File>Save.
Brackets Key names Press [Enter].
Commas Key sequences Press and release these keys one at a time:
[Alt], [F], [D]
Plus signs Key combinations Press and hold these keys simultaneously:
[Ctrl]+[Alt]+[Del]

Typographic Conventions in Code


Convention Element Example
Caps and lowercase Oracle Forms When-Validate-Item
triggers
Lowercase Column names, SELECT last_name
table names FROM s_emp;
Passwords DROP USER scott
IDENTIFIED BY tiger;
PL/SQL objects OG_ACTIVATE_LAYER
(OG_GET_LAYER (prod_pie_layer))
Lowercase italic Syntax variables CREATE ROLE role
Uppercase SQL commands SELECT userid
and functions FROM emp;

Typographic Conventions in Navigation Paths


This course uses simplified navigation paths, such as the following example, to direct
you through Oracle Applications.

(N) Invoice>Entry>Invoice Batches Summary (M) Query>Find


(B) Approve

This simplified path translates to the following:


1 (N) From the Navigator window, select Invoice>Entry>Invoice Batches
Summary.
2 (M) From the menu bar, select Query>Find.
3 (B) Click the Approve button.

N = Navigator, M = Menu, B = Button

.....................................................................................................................................................
xviii Oracle iDS Forms: Build Internet Applications II
................................

Introduction
Lesson I:
......................................................................................................................................................

Introduction
Aim of the Course
After completing this course, you should be able to do the following:
Create, modify and attach menu documents to Oracle Forms
Developer Internet applications
Ensure application security with Oracle8i database roles
Code triggers that respond to function keys
Respond to mouse movement and mouse button actions
Manipulate windows and canvases
Choose appropriate data sources for data blocks
Work with Oracle8i objects in Form Builder
Create and manage multiple Internet form applications
Manage transaction processing in multiple Oracle Forms
Developer Internet applications
Create and modify Record Groups programmatically
Build forms with Reusable Components
Enhance the User Interface with JavaBeans
Manage Server side features
Create Timers
Include charts and reports in Oracle Forms Developer
Internet applications

......................................................................................................................................................
I-2 Oracle iDS Forms: Build Internet Applications II
Course Content
......................................................................................................................................................

Course Content
The lesson titles show the topics we cover in this course, and the usual
sequence of lessons. However, the daily schedule is an estimate, and may
vary for each class.

Day 1

Lesson
Number Lesson Name
1 Creating a Menu Module
2 Managing Menu Modules
3 Programming Function Keys
4 Responding to Mouse Events

Day 2

Lesson
Number Lesson Name
5 Controlling Windows and Canvases
Programmatically
6 Defining Data Sources
7 Working with Oracle8i Objects in Form Builder
8 Controlling Data Block Relationships
9 Building Multiple Form Applications

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-3
Lesson I:
......................................................................................................................................................

Day 3

Lesson
Number Lesson Name
10 Working with Record Groups
11 Using Reusable Components
12 Using Java with Web-Deployed Forms
13 Using Server Features in Form Builder
14 Applying Timers
15 Including Charts and Reports

......................................................................................................................................................
I-4 Oracle iDS Forms: Build Internet Applications II
................................

Creating a Menu Module


Lesson 1: Creating a Menu Module
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Identify the components of a menu
Create, save, and attach menu modules
Set menu properties by using the
Property Palette
Create menu toolbars
Create pop-up menus

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
By default, each form module uses the same menu structure, called the Default menu.
This lesson teaches you how to customize this menu and how to create your own menu
modules. You will also learn how to enhance your application by including menu
toolbars and pop-up menus.

Objectives
After completing this lesson, you should be able to do the following:
Identify the different components of a menu module
Create, save, and attach menu modules
Set menu properties by using the Property Palette
Create menu toolbars
Create pop-up menus

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-3
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Components of the Menu


Module
Menu item

Main Individual menu


menu
Menu toolbar

Copyright Oracle Corporation, 2001. All rights reserved.

Hierarchical Structure of a Menu

Menu
module

Individual Menu Menu Individual


menu item item menu

Menu
Submenu
items

Menu
items

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-4 Oracle iDS Forms: Build Internet Applications 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 and easy
method for operating your Forms application. Like the form module, the menu module
is one of the main components of an application.
Each menu module displays as 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 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 individual items from
your menu. For a menu module, you can have a vertical and a horizontal menu toolbar.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-5
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Default Menu

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-6 Oracle iDS Forms: Build Internet Applications 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 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. The Default
menu is internal to Oracle Forms Developer. You can replace the Default menu with a
custom menu. A custom menu is stored in a separate module that has a suffix of .mmb.
A custom menu that is exactly the same as the Default menu, menudef.mmb, ships
with Oracle Developer Forms.

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-7
Lesson 1: Creating a Menu Module
......................................................................................................................................................

The Menu Editor

Display Create Create Switch


menu Down Right Orientation

Menu tab Expanded Collapsed


menu menu

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
1-8 Oracle iDS Forms: Build Internet Applications 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 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, some are specific to the Menu Editor.

Tool Function
Display Determines the highest level menu that the Menu Editor displays. (Choose
Menu from all the menus in your menu module.)
Create Down Creates a new menu item below the currently active one
Create Right Creates a new menu item to the right of the currently active one
Switch Allows display of the top-level menu vertically or horizontally
Orientation

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-9
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Creating a Menu Module

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-10 Oracle iDS Forms: Build Internet Applications II
Creating a Menu Module
......................................................................................................................................................

Creating a Menu Module


The first step when creating a menu is to define a new menu module by using the
Object Navigator. Once the module is created, you need to create menus 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 Click the Create Right icon.
3 Replace the default label.
4 Select Menu>Create Down to add another item to the submenu.
5 Replace the default label.
6 Repeat steps 4 and 5 to add more submenu items.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-11
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Module Properties

Main Menu
Menu Directory
Menu Filename
Startup Code
Share Library with Form

Use Security
Module Roles

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-12 Oracle iDS Forms: Build Internet Applications II
Module Properties
......................................................................................................................................................

Module Properties

Property Description
Main Menu Property that specifies the name of the individual menu in the module
that is the main or starting menu at run time
For a pull-down menu, the main menu is automatically set to the name
of the first menu that you create. Users cannot navigate above this
menu in the menu hierarchy.
Menu Directory Path used by Forms as a pointer to the directory for the run-time .mmx
file; only used by menu modules that are saved to the database
Menu Filename Filename used by Forms as a pointer to the run-time .mmx file; only
used by menu modules that are saved to the database
Startup Code PL/SQL code executed when a menu module is loaded in memory
Share Library Property that enables the loading into memory of a single copy of a PL/
with Form SQL library, if this is the library used by the form module and the menu
module
Use Security When set to Yes, this property enforces security at run time. (Set this
property to No to test the menu module without having to be a member
of any database role.)
Module Roles Property that displays the Menu Module Roles dialog box, where you
can list the roles assigned to the menu module. (Roles defined must be
assigned to individual menu items in the Menu Editor.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-13
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Properties

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-14 Oracle iDS Forms: Build Internet Applications II
Menu Properties
......................................................................................................................................................

Menu Properties

Property Description
Tear-Off Menu Enables the menu to be dragged from the menu bar and repositioned
elsewhere on the screen (available only if your window manager
supports this feature)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-15
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Item Properties

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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Radio menu items must belong to a radio group. All of the radio items for a radio
group must be contiguous on the same menu. Radio group names are internal names
that are not displayed at run time.

......................................................................................................................................................
1-16 Oracle iDS Forms: Build Internet Applications II
Menu Item Properties
......................................................................................................................................................

Menu Item Properties


Properties Specific to Menu Item
Menu Item Property Function
Enabled Specifies whether the menu item is an active and mouse
manipulatable (Inactive menu items are displayed in grey.)
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

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-17
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Item Types

Plain
Check

Radio

Magic

Separator

Copyright Oracle Corporation, 2001. All rights reserved.

Magic Items

About Paste
Undo Help
Clear Quit
Copy Window
Cut

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-18 Oracle iDS Forms: Build Internet Applications 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.

Choosing a Menu Item Type


Menu Item Type Description
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 differ-
ent 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 the standard actions of a graphical user interface (GUI), a copy or
paste action is already defined at the menu level. All you need to do is set the
item to the Magic type and define the desired action (standard or specific).
Magic Item Command Type Default Functionality?
About Any except Menu No. You must assign a command to these
Undo items to perform the desired function.
Clear Null Yes. These items perform the default
Copy operations indicated by their names.
Paste
Cut
Help Menu No. You must define a submenu to be
called by the Magic Help item, and you
must assign commands to the items on
that submenu.
Quit Null Yes. The Quit command, by default, exits
from the form after asking the user to
save any changes.
Window Null or Menu Yes. The window item invokes a default
submenu that lists all open windows.
Users can activate a window by selecting
it from the submenu.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-19
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Item Command Types

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-20 Oracle iDS Forms: Build Internet Applications 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 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 this 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
submenu to be invoked.)
PL/SQL (default) Executes a PL/SQL command (Valid menu item code is a PL/SQL
block, 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, Plus and Macro are available for backward
compatibility only.

Web Design Tip


If you invoke the HOST command with Web-deployed forms, the required process
will run on the Forms Services machine, not on the client. The client will not be able to
view or participate in that process.

Viewing Menu Item Commands


To view the menu item command associated with a menu item, you must take one of
the following actions:
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.
Right-click on the menu item in the Object Navigator or Menu Editor
and select PL/SQL Editor from the pop-up menu.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-21
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Implementing Menu Toolbars

Toolbar as part of menu module:


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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
For more flexible or complex requirements, use the existing Toolbar canvas in form
modules.

......................................................................................................................................................
1-22 Oracle iDS Forms: Build Internet Applications II
Implementing Menu Toolbars
......................................................................................................................................................

Implementing Menu Toolbars


What Is a Menu Toolbar?
A menu toolbar is a set of iconic buttons that represent individual items from a menu.
When you create a custom form menu, you can specify that some of its items appear
on a menu toolbar.
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 developers 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 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.) 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 that the menu item should appear (represented by an
Menu Toolbar icon) on the horizontal toolbar of a form
Visible in Vertical Specifies that the menu item should appear (represented by an
Menu Toolbar icon) on the vertical toolbar of a form
Icon Filename Specifies the name of the icon resource that you want to represent
the iconic button. For Web-deployed forms, this should be a GIF
file, otherwise use an ICO file.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-23
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Menu Module Storage

Menu module definition:


.mmb
Stored in files or database tables
Menu module executable:
.mmx
Stored in files
Menu module text:
.mmt
Stored in files

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-24 Oracle iDS Forms: Build Internet Applications 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 either of the
following storage formats.
Storage Format Description
File with .mmb Menu module binary file, a binary representation of the menu structure
extension that is portable between operating systems
Database table A table representation of the menu structure that is portable between
databases

You can save your menu module definition by either of the following actions:
Clicking the Save icon in the Object Navigator
Selecting 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-25
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Form Module Properties

Menu
module Specify
to use with that menu
this form module
module is stored
in the file
system

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
1-26 Oracle iDS Forms: Build Internet Applications 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 effectively replacing the
Default menu with your own menu module.

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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-27
Lesson 1: Creating a Menu Module
......................................................................................................................................................

What Is a Pop-up Menu?

Menu that appears on the screen at the


location it was invoked
Enables users to
access commonly used
functions easily
Is accessed by pressing
the right mouse button
(Microsoft Windows and
Motif)

Copyright Oracle Corporation, 2001. All rights reserved.

Incorporating Pop-up Menus

Pop-up menus are:


Top-level objects in the object navigator,
such as alerts or Data Blocks
Built through the Property Palette or
Menu Editor
Defined in a form module
Associated with items and canvases
with a pop-up menu property
Pre-Popup-Menu trigger provides
dynamic control

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-28 Oracle iDS Forms: Build Internet Applications II
Pop-up Menus
......................................................................................................................................................

Pop-up Menus
Pop-up menus are context-sensitive menus. You attach pop-up menus to an item or
canvas, and display them by right click on that item or canvas. Pop-up menus enable
end users to quickly access common functions and commands.
Pop-up menus are top-level objects in the Object Navigator (similar to alerts, blocks,
canvases, and so on) and belong to a form module, as opposed to form menus, which
belong to a separate menu module.
Items on a pop-up menu should be contextual to the menus associated objects. For
example, you would not include text-editing items on the pop-up menu for a two-digit
numeric item. However, you might include such items on the pop-up menu for a
multiline text item.

Incorporating Pop-up Menus


1 In the Object Navigator of a form, click the Pop-up Menus node, and
click the Create button on 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. You can select plain text,
separators, check boxes, and option boxes for Menu items.
4 Attach the menu to items and canvases with a 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.

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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-29
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Summary

In this lesson, you should have learned to:


Identify Menu module components
The Default menu
Menu properties
Create a Menu module
Associate Menu and form modules
Create a Pop-up menu

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-30 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
In this lesson, you learned how to add, create, and customize menu modules.

The Menu Module Components


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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-31
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Practice 1 Overview

This practice covers the following topics:


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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
1-32 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 1
......................................................................................................................................................

Practice Overview: Lesson 1


This practice guides you through creating a custom menu, a menu toolbar and
a pop-up menu.

Practice Contents
Create a simple menu module
Incorporate menu items in the menu toolbar
Compile and attach a menu to a form
Create a pop-up menu

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-33
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Practice 1
1 Create a new menu module.
a Using the following screenshot as a guideline, create a new menu
module called M_SUMMITXX where XX is your student course
number.

File Menu

Visible in
Menu Visible Horiz.
Item Command Menu Item in Menu Icon
Label Type Type Code Menu Toolbar Filename
Save Plain PL/SQL DO_KEY(CO Yes Yes Save
MMIT_FORM
);
Clear Plain PL/SQL DO_KEY( Yes Yes Abort
CLEAR_FORM
);
Null1 Separator Null Yes Yes
Exit Plain PL/SQL DO_KEY( Yes Yes Exit
EXIT_FORM
);
Null2 Separator Null No Yes

......................................................................................................................................................
1-34 Oracle iDS Forms: Build Internet Applications II
Practice 1
......................................................................................................................................................

Edit Menu

Visible in
Menu Magic Command Visible Horiz. Menu Icon
Label Item Type Item Type in Menu Toolbar Filename
Cut Magic Cut Null Yes Yes Cut
Copy Magic Copy Null Yes Yes Copy
Paste Magic Paste Null Yes Yes Paste
Null3 Separator Null No Yes

Sort By Menu

Menu Menu Item


Item Radio Command
Menu Label Type Group Type Menu Item Code
Order Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
id ) ;
Customer Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
customer_id ) ;
Sales Rep Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
sales_rep_id ) ;

Query Menu

Visible in
Menu Command Horiz. Menu Icon
Label Item Type Type Menu Item Code Toolbar Filename
Enter Plain PL/SQL DO_KEY( Yes query
Query ENTER_QUERY);
eXe- Plain PL/SQL DO_KEY(EXECUT Yes execute
cute E_QUERY);
Query

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 1-35
Lesson 1: Creating a Menu Module
......................................................................................................................................................

Save as M_SUMMIT and compile the menu module.


b
c Attach the menu module to the ORDERS form.
d Save and compile the form module as ORDGXX where XX is your
student course number.
e Run and test your ORDERS form.
2 Add pop-up menus to the CUSTOMERS form.
a Open the CUSTOMERS form module. Save as CUSTGXX where
XX is your student course number.
b Copy the EDIT_MENU menu from your M_SUMMIT menu
module to your CUSTOMERS form. Attach this pop-up menu to the
Comments item.
c Save and compile the form module. Deploy your form to the Web to
test.

......................................................................................................................................................
1-36 Oracle iDS Forms: Build Internet Applications II
................................

Managing Menu Modules


Lesson 2: Managing Menu Modules
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Control the menu programmatically
Manage the interaction between the menu and
form documents
Implement application security through
the menu

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson, you will learn how to modify menus dynamically, as well as
how to control application security through menu access.

Objectives
After completing this lesson, you should be able to do the following:
Control the menu programmatically by using menu built-ins
Implement menu security by using both database roles and the
appropriate built-ins

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-3
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Using PL/SQL in Menu Item


Code

Similar to PL/SQL code in form triggers


You can share code between a form
module and a menu module by using
the following:
Libraries
User-defined triggers
DO_KEY built-in

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-4 Oracle iDS Forms: Build Internet Applications 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
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 form modules and menu modules in three
ways:
Setting up libraries and attaching them to the 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-5
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Built-ins for Setting and Getting


Menu Item Properties

FIND_MENU_ITEM
GET_MENU_ITEM_PROPERTY
SET_MENU_ITEM_PROPERTY
ITEM_ENABLED
MENU_SHOW_KEYS

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-6 Oracle iDS Forms: Build Internet Applications II
Useful Built-in Menu Subprograms
......................................................................................................................................................

Useful Built-in Menu Subprograms


You can change certain menu characteristics dynamically at run time by
using built-in subprograms.
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.
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 modifies 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 finds the ID of a menu item before setting multiple properties.
DECLARE
mi_id MenuItem;
BEGIN
mi_id := Find_Menu_Item(Preferences.AutoCommit);
/* Determine the current checked state of the AutoCommit menu
checkbox item and toggle the checked state */
IF Get_Menu_Item_Property(mi_id,CHECKED) = TRUE THEN
Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_FALSE);
ELSE
Set_Menu_Item_Property(mi_id,CHECKED,PROPERTY_TRUE);
END IF;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-7
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Built-ins for Showing and Hiding


the Current Menu

REPLACE_MENU
Character mode built-ins:
HIDE_MENU
SHOW_MENU
MENU_REDISPLAY

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
2-8 Oracle iDS Forms: Build Internet Applications II
Showing and Hiding the Current Menu
......................................................................................................................................................

Showing and Hiding the Current Menu


Built-in Description
REPLACE_MENU Replaces the current menu with a specific one, without mak-
ing it active (Use this procedure to modify the display style
and security.)
HIDE_MENU Hides the current menu
SHOW_MENU Displays the current menu without activating it
MENU_REDISPLAY Redraws the current menu on the screen

Example
Use a standard procedure to change which root menu in the current menu
application appears in the menu bar. A single menu application may have
multiple root menus, which an application can set dynamically at run time.
PROCEDURE Change_Root_To(root_menu_name VARCHAR2) IS
BEGIN
Replace_Menu(MYAPPLSTD, PULL_DOWN, root_menu_name);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-9
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Managing Menu Security

Defining security roles


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

Copyright Oracle Corporation, 2001. All rights reserved.

What Is a Role?

Users

Role

Privileges

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-10 Oracle iDS Forms: Build Internet Applications 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
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 granted only to some roles, only users belonging to
those roles can access those items.
Using this feature, you can deliver the same application for different kinds
of users.

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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-11
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Menu Module Roles Window

Select Menu Module Roles:

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

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

......................................................................................................................................................
2-12 Oracle iDS Forms: Build Internet Applications II
Defining Security Roles
......................................................................................................................................................

Defining Security Roles


Defining New Roles
Menu security is based on the Oracle server roles. You can create these 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 must exist in the database.

Setting the Use Security Property


The Use Security property determines whether 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-13
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Menu Item Roles Window

Select menu item roles:

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-14 Oracle iDS Forms: Build Internet Applications 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.
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, which 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.
For additional information on how to manipulate Oracle server roles at run
time, see Appendix I, Using Oracle Server Roles at Run Time.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-15
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Summary

In this lesson, you should have learned to:


Exploit Menu Built-ins
Include PL/SQL in menu items
Implement menu security

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-16 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
PL/SQL in Menu Item Commands
Typical PL/SQL uses
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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-17
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Practice 2 Overview

This practice covers the following topics:


Enhancing the menu with a check
menu item
Synchronizing the menu Display_Help
item with the form Help button
Hiding irrelevant menu items
according to form context

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
2-18 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 2
......................................................................................................................................................

Practice Overview: Lesson 2


This practice guides you through enhancing custom menus for the ORDERS and
CUSTOMERS forms.

Practice Contents
Add a check menu item.
Enhance the menu so that the Display Help menu item is synchronized
with the ORDERS Help button. If the Help button is enabled, a
checkmark should appear next to the Display Help menu item.
For the CUSTOMERS form, hide the menu items that are not relevant.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 2-19
Lesson 2: Managing Menu Modules
......................................................................................................................................................

Practice 2
1 Define a check menu item.
a Open your M_SUMMIT menu module and add a new menu item to
the Sort By menu; name it Display_Help.

Menu Label Menu Item Type Command Type


Display Help Check PL/SQL

b If Display_Help is selected, enable the ORDERS form toolbar HELP


button and set the toolbar canvas background color to grey.
If Display_Help is not selected, disable the ORDERS form toolbar
HELP button and set the toolbar canvas background color to red.
You can import the code from the pr2_1.txt file.
c Save and compile the menu module.
d Deploy your ORDERS form on the Web to test your menu.

2 Synchronize the menu module with the form.


a Write startup code for your M_SUMMIT menu module that
synchronizes the Display_Help menu item with the toolbar HELP
button. You can import the code from the pr2_2.txt file.
b Save and compile your menu module.
c Deploy your ORDERS form on the Web to test your menu.

3 Attach your M_SUMMIT menu to your CUSTOMERS form. The menu


item Sort_By is not relevant, and should not be visible to the user.
a Attach the menu module to your CUSTOMERS form.
b Modify the startup code of the M_SUMMIT menu module to hide
the SORT_BY menu when the CUSTOMERS form is opened. You
can import the code from the pr2_3.txt file to replace the
existing code. You may need to change the code to conform to the
exact names you gave to the Main Menu and its menu items. Also,
be sure the When-Button-Pressed trigger on the Orders button refers
to your Orders form.
c Save and compile the menu module.
d Deploy your CUSTOMERS form to the Web and test your
application. Execute a Query and click the Orders button to move to
the ORDERS form. Note that the Sort_By menu item is hidden when
the CUSTOMERS form is current, and is visible when the ORDERS
form is current.
4 With both the ORDERS and CUSTOMERS form modules, restore the
default menu, (DEFAULT&SMARTBAR).

......................................................................................................................................................
2-20 Oracle iDS Forms: Build Internet Applications II
................................

Programming
Function Keys
Lesson 3: Programming Function Keys
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Define key triggers and their uses
Program function keys
Describe the characteristics of key triggers
Classify key triggers
Associate function keys with interface controls

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
Form Builder enables you to redefine the actions of function keys. This
lesson shows you how to create key triggers to either intercept, or
supplement, the usual function key behavior with which your users navigate
the Oracle Forms Developer application.

Objectives
After completing this lesson, you should be able to do the following:
Define key triggers and their uses
Program function keys
Classify key triggers
Associate function keys with interface controls

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-3
Lesson 3: Programming Function Keys
......................................................................................................................................................

Key Triggers

What is a key trigger?


Example:
Using Key-Exit, display an alert and exit the
application if the user selects the Yes button.

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-4 Oracle iDS Forms: Build Internet Applications II
Key Triggers
......................................................................................................................................................

Key Triggers
If you press a function key, Forms usually performs the default function
associated with that key. You can modify the standard functionality of a
function key by defining a key trigger for that function key.

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 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 asking the end user
if he or she wants to leave the form.
SET_ALERT_PROPERTY(question_alert, ALERT_MESSAGE_TEXT, Do
you really want to leave the form?);
IF SHOW_ALERT(question_alert) = ALERT_BUTTON1 THEN
EXIT_FORM; -- default functionality
END IF;

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

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-5
Lesson 3: Programming Function Keys
......................................................................................................................................................

Key Trigger Properties


and PL/SQL Editor

Display in Keyboard Help


Keyboard Help Text

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-6 Oracle iDS Forms: Build Internet Applications 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 in the Property Palette for triggers
only apply to key triggers.
Property Description
Display in Keyboard Help Specifies whether a key trigger description is displayed in the
run-time Keys Help window
Keyboard Help Text Specifies the text that is displayed in the run time Keys Help
window 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.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-7
Lesson 3: Programming Function Keys
......................................................................................................................................................

Characteristics of Key Triggers

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.

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-8 Oracle iDS Forms: Build Internet Applications 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
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 association.

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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-9
Lesson 3: Programming Function Keys
......................................................................................................................................................

Classification of Key Triggers

Function key triggers


Key-Fn triggers and
Oracle Terminal
Key-Others triggers
Key mapping for
Web-deployed forms
is different to
Client Server

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
The function keys Fn do not necessarily map to F1, F2, F3, and so on.

......................................................................................................................................................
3-10 Oracle iDS Forms: Build Internet Applications II
Classification of Key Triggers
......................................................................................................................................................

Classification of Key Triggers


You can distinguish among different types of key triggers. Learning these
classifications will help you understand when to use key triggers.

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 Runtime keys
F0 through F9 (Before you can use these Key triggers, you or
the DBA must 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

Key Mapping
Key mapping is defined by a platform specific resource file. The key
definition file for the Microsoft Windows platform is FMRUSW.RES. You
should use Oracle Terminal to edit Client Server resource files. For Web
applications, you can edit the Java resource file, FMRWEB.RES, with any
suitable operating system editor.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-11
Lesson 3: Programming Function Keys
......................................................................................................................................................

Classification of Key Triggers

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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Since mouse-event key triggers are not executed when the mouse is used to
initiate window interaction, you should not place code that needs to be
executed every time the window interaction occurs in a mouse-event key
trigger.

......................................................................................................................................................
3-12 Oracle iDS Forms: Build Internet Applications 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.

Examples
The Key-Nxtblk trigger is a mouse-event key trigger, because the
NEXT_BLOCK functionality can also be activated using the mouse by
clicking in the next block. In this case, a possible Key-Nxtblk trigger
will not fire.
The Key-Exeqry trigger is not a mouse-event key trigger, because the
EXECUTE_QUERY functionality cannot be activated by simply
clicking the mouse. It can be activated by the mouse only if a trigger is
defined to fire as a result of the mouse action.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-13
Lesson 3: Programming Function Keys
......................................................................................................................................................

Using Key Triggers

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

Copyright Oracle Corporation, 2001. All rights reserved.

Specific Key Trigger Uses

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-14 Oracle iDS Forms: Build Internet Applications II
Using Key Triggers
......................................................................................................................................................

Using Key Triggers


You should use key triggers sparingly. Often you must define many key
triggers to trap a certain event completely. 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 Uses


Call a list of values (LOV) form instead of the native Forms LOV, using
Key-Listval
Check if detail records exist before deleting a master record if the master
block and detail block are in separate forms, 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 those function keys
for which a key trigger is defined at the form level.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-15
Lesson 3: Programming Function Keys
......................................................................................................................................................

Association with Other


Interface Controls

Syntax: DO_KEY(built_in_name)
Example: To customize actions when a user
exits the form with [Exit Form], a button,
or a menu item:
1. Key-Exit

--
-- custom
custom actions
actions when
when user
user tries
tries to
to exit
exit
EXIT_FORM;
EXIT_FORM;
...
...

Copyright Oracle Corporation, 2001. All rights reserved.

Association with Other


Interface Controls

2. In When-Button-Pressed and Menu item code:


DO_KEY(EXIT_FORM);
DO_KEY(EXIT_FORM);

DO_KEY(Key-Exit) gives run-time


error
Corresponding interface control
descriptions

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-16 Oracle iDS Forms: Build Internet Applications II
Association with Other Interface Controls
......................................................................................................................................................

Association with Other Interface Controls


You can often activate the same functionality in various ways, such as by
pressing a function key, choosing a menu item, clicking a button, or
performing direct manipulation with the mouse. In this case, you want to
specify that the PL/SQL code 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 that corresponds
to the built-in subprogram specified as its parameter. If no key trigger is
defined, the specified built-in is executed.

Syntax
DO_KEY(built_in_name)

Example
Exit a Form by clicking [Exit Form] or an Exit button, or by choosing a
menu item.
1 Define a Key-Exit trigger at form level.
2 Call DO_KEY by using:
a The When-Button-Pressed trigger on the associated Exit button
b The menu-item code for the menu item that exits the form using
DO_KEY(EXIT_FORM);

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-17
Lesson 3: Programming Function Keys
......................................................................................................................................................

Summary

In this lesson, you should have learned to:


Define key triggers in order to:
Enhance keyboard functionality
Replace keyboard key
Provide consistent functionality between
Function keys, buttons, menu items, and
mouse events
Display text in Keyboard Help
Define Key-Fn, Key-Others, and mouse-event key
triggers

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-18 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Understanding Key Triggers
They fire when the associated function key is pressed.
They are defined like any other trigger.
Special properties are Display in Keyboard Help and Keyboard Help
Text.

Classification of Key Triggers


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

Uses of 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-19
Lesson 3: Programming Function Keys
......................................................................................................................................................

Practice 3 Overview

This practice covers the following topics:


Enforcing consistent form run time
functionality by redefining [Exit Form]
Changing the behavior of function keys by
replacing [Enter Query] with a custom query form

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
3-20 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 3
......................................................................................................................................................

Practice Overview: Lesson 3


This practice guides you though redefining function keys with key triggers.

Practice Contents
Use a key trigger to redefine [Exit Form] to provide consistent behavior
between Menu and form modules.
Disable [Enter Query] mode, and replace with a custom query form.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 3-21
Lesson 3: Programming Function Keys
......................................................................................................................................................

Practice 3
1 Maintain consistent functionality in your form module by using key
triggers. Define a key trigger in your ORDERS form to give users
consistent functionality whenever they exit the form, either using the
menu or when the CONTROL.EXIT_BUTTON button is pressed.
a Redefine [Exit Form] in your ORDERS form so that an alert
message is displayed to users before allowing them to exit the form.
b Amend the entry in Keyboard Help to Exit Orders for the key
trigger.
c Save and compile your form. Deploy your form to the Web to test.
d Customize the Alert Text message in your key trigger and ensure that
it is displayed whenever the user exits the form using the
EXIT_BUTTON on the Control block.
e Save and compile your form module. Deploy to the Web and test
your form.

If you have time


2 Disable [Enter query] in your CUSTOMERS form by creating an
appropriate key trigger. Replace [Enter Query] functionality with a call
to the customized query form CUSTQUERY. This form allows the user
to select a CUSTOMER ID, a CUSTOMER NAME, or a SALES REP
ID. The user selections are returned to your CUSTOMER form using
global variables.
a Add the following code to your key trigger:
call_form(custquery,no_hide);
execute_query;
b The CUSTQUERY form will return three values, held in global
variables. The contents should be passed to your CUSTOMERS
form to allow the user to execute a restricted query. Use the
following global variables:
:global.custid;
:global.custname;
:global.repid;
c Define the global variables in your CUSTOMERS form to ensure
that the user can perform unrestricted queries.
d Save and compile your CUSTOMER form. Deploy your form to the
Web to test.

......................................................................................................................................................
3-22 Oracle iDS Forms: Build Internet Applications II
................................

Responding to Mouse
Events
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Objectives

After completing this lesson, you should be able do


the following:
Define mouse events
Cause a form module to respond to mouse
movement
Cause a form module to respond to mouse
button actions

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
The keyboard, menu, and mouse are the operators tools for interacting with
the Forms application. This lesson demonstrates how to write an application
that responds to mouse events.

Objectives
After completing this lesson, you should be able to do the following:
Define mouse events
Cause a form module to respond to mouse movement
Cause a form module to respond to mouse button actions

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-3
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Mouse Events

Point at which processing can be influenced


Identified by:
Mouse movement
Mouse button action

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-4 Oracle iDS Forms: Build Internet Applications II
What Are Mouse Events?
......................................................................................................................................................

What Are Mouse Events?


An event is a point at which Forms processing can be influenced. Every
object can have processing events with which you can associate PL/SQL
code (triggers).
A mouse event is an event that is identified by a mouse movement or a
mouse button action.

The Seven Mouse Events


The Forms mouse events is divided in two groups: mouse movement events
and mouse button action 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-5
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Mouse Movement Triggers

When-Mouse-Enter

When-Mouse-Leave

When-Mouse-Move

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-6 Oracle iDS Forms: Build Internet Applications II
Responding to Mouse Movement
......................................................................................................................................................

Responding to Mouse Movement


You can initiate an action whenever mouse movement occurs by defining
the mouse movement triggers.

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 the
SYSTEM.MOUSE_X_POS and SYSTEM.MOUSE_Y_POS system
variables 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

Web Design Tip


If you define mouse movement triggers in client server applications, this
may adversely affect the performance of your form. This is because these
triggers have the potential to fire frequently. For this reason, you should use
them sparingly; in Web-deployed forms these triggers are disabled.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-7
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Mouse Position System Variables

2 7

6
3

Copyright Oracle Corporation, 2001. All rights reserved.

1 MOUSE_FORM 5 MOUSE_RECORD_OFFSET
2 MOUSE_CANVAS 6 MOUSE_X_POS
3 MOUSE_ITEM 7 MOUSE_Y_POS
4 MOUSE_RECORD

Technical Note
The SYSTEM.MOUSE_FORM system variable is NULL if the platform is
not a GUI platform.

......................................................................................................................................................
4-8 Oracle iDS Forms: Build Internet Applications 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.
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 mouses current
position (If the mouse is positioned on a canvas,
the x coordinate is measured relative to the top
left corner of the canvas. If the mouse is in an
item, the x coordinate is measured relative to the
top left corner of the item.)
SYSTEM.MOUSE_Y_POS Identifies the y coordinate of the mouses current
position (If the mouse is positioned on a canvas,
the y coordinate is measured relative to the
top left corner of the canvas. If the mouse is in an
item, the y coordinate is measured relative to the
top left corner of the item.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-9
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Mouse Button Action Triggers

When-Mouse-Down

When-Mouse-Up

When-Mouse-Click
click

When-Mouse-Doubleclick
click click

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Click and double-click work only if the mouse stays on the item (or canvas)
throughout the down-up action.

......................................................................................................................................................
4-10 Oracle iDS Forms: Build Internet Applications 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.

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

Web Design Tip


When any mouse button action is initiated in a Web-deployed form, the Java
user interface refers to Forms Services to identify the appropriate mouse
button trigger. Even though you may not have defined the relevant mouse
button trigger, the user interface will generate this event if you have defined
at least one mouse button trigger in your form. You should therefore restrict
use of mouse button triggers.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-11
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Mouse Button Action


System Variables

SYSTEM.MOUSE_BUTTON_PRESSED

SYSTEM.MOUSE_BUTTON_MODIFIERS

Ctrl Alt

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-12 Oracle iDS Forms: Build Internet Applications II
Responding to Mouse Button Actions
......................................................................................................................................................

The Mouse Button System Variables


Use the following system variables to determine which mouse button was
pressed and which special key, if any, was used.
Variable Use
SYSTEM.MOUSE_BUTTON_PRESSED Identifies which mouse button was pressed
(values of 13, 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 [Ctrl] and [Shift] keys while pressing the
mouse button, SYSTEM.MOUSE_BUTTON_MODIFIERS contains the
value Shift+Control+.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-13
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Respond to mouse movement
Mouse position system variables
Mouse movement triggers
Respond to mouse button actions
Mouse button system variables
Mouse button triggers

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-14 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
In this lesson, you saw how to write an application that responds to mouse
events.

Mouse Events
Entry to a canvas or an item
Exit from a canvas or an item
Move the cursor
Click
Double-click
Up
Down
Responding to mouse movement
Mouse position system variables

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-15
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Practice 4 Overview

This practice covers the following topics:


Invoke an editor when the operator
double-clicks an item
Redefine the mouse cursor style according
to context

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
4-16 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 4
......................................................................................................................................................

Practice Overview: Lesson 4


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

Practice Contents
Define a mouse-event trigger to invoke an editor on the
S_CUSTOMER.COMMENTS item.
Modify the mouse cursor style whenever the ORDERS Help canvas is
displayed.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 4-17
Lesson 4: Responding to Mouse Events
......................................................................................................................................................

Practice 4
In this practice, you provide additional functionality in your forms by
defining mouse event triggers.

1 In your CUSTOMERS form, define a mouse event trigger on


S_CUSTOMER.COMMENTS that invokes the items editor when the
user double-clicks the item.
2 In your ORDERS form change the mouse cursor symbol to busy while
the HELP canvas is displayed.
a Ensure that the default symbol is restored whenever the user hides
the HELP canvas.
b The user can close the HELP canvas without pressing the
HIDEHELP button, by navigating to an item in another block. How
can you ensure that the mouse cursor is always restored?
c Save and compile your form modules. Deploy your forms to the Web
to test. You can call the ORDERS form from your CUSTOMERS
form.

......................................................................................................................................................
4-18 Oracle iDS Forms: Build Internet Applications II
................................

Controlling Windows
and Canvases
Programmatically
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Display a form document in multiple
windows
Write code to interact with windows
Manipulate windows programmatically
Manipulate canvas views programmatically
Control windows and canvases with
Web-deployed forms
Display large data blocks in a window

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
You should already be familiar with setting window and canvas properties at design
time. This lesson covers the triggers and built-ins that you can use to manage the
properties and behavior of windows and canvases at run time.

Objectives
After completing this lesson, you should be able to do the following:
Display a form module in multiple windows
Write code to interact with windows
Manipulate windows programmatically
Manipulate canvas views programmatically
Control windows and canvases with Web-deployed forms
Display large data blocks in a window

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-3
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Using Window-Interaction Triggers

System Variable
:SYSTEM.EVENT_WINDOW

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-4 Oracle iDS Forms: Build Internet Applications 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 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 by using a window-
manager-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 Captures initial settings of window properties; enforces
navigation to a particular item whenever the window is
activated
When-Window-Deactivated Deactivates a window
When-Window-Closed Closes a window programmatically
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.
Note: Help with triggers is available by pressing [Ctrl] + [H] and selecting PL/SQL
Reference - Triggers.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-5
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Built-ins for Manipulating


Windows

FIND_WINDOW
GET_WINDOW_PROPERTY
SET_WINDOW_PROPERTY
HIDE_WINDOW
SHOW_WINDOW
MOVE_WINDOW
RESIZE_WINDOW

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
In Microsoft Windows, you can reference the multiple document interface
(MDI) application window with the FORMS_MDI_WINDOW constant.
FORMS_MDI_WINDOW is used with certain built-in functions and
procedures that relate to windows.
In Web-deployed forms, you can obtain similar functionality by setting
the Forms Applet WIDTH and HEIGHT parameters in the base HTML page.
Definition of these Form Applet parameters is covered later in this course.

......................................................................................................................................................
5-6 Oracle iDS Forms: Build Internet Applications II
Built-ins for Manipulating Windows
......................................................................................................................................................

Built-ins for Manipulating Windows


Built-in Description
FIND_WINDOW Returns the internal window ID (of data type
WINDOW) of a window with the given name
GET_WINDOW_PROPERTY Returns the current value of the specified
window property for the given window
SET_WINDOW_PROPERTY Sets the specified window property for the
given window to a specified value
HIDE_WINDOW Hides the window
SHOW_WINDOW Makes the window visible at the current or
specified display position
MOVE_WINDOW Moves the window to the location specified by
the given coordinates
RESIZE_WINDOW Changes the window to the specified width and
height

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-7
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Built-ins for Manipulating


Canvases

FIND_CANVAS
GET_CANVAS_PROPERTY
SET_CANVAS_PROPERTY
FIND_VIEW
GET_VIEW_PROPERTY
SET_VIEW_PROPERTY
HIDE_VIEW
SHOW_VIEW
REPLACE_CONTENT_VIEW
SCROLL_VIEW

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
REPLACE_CONTENT_VIEW does not hide the stacked canvas already displayed
in the window. In contrast SHOW_VIEW and SET_VIEW_PROPERTY will display
the given canvas in front of any stacked canvas, if the canvas Visible property is set to
true.

......................................................................................................................................................
5-8 Oracle iDS Forms: Build Internet Applications II
Built-ins for Manipulating Canvases
......................................................................................................................................................

Built-ins for Manipulating Canvases


Built-in Description
FIND_CANVAS Returns the internal canvas ID (CANVAS data type)
of a canvas with the given name
GET_CANVAS_PROPERTY Returns the current value of the specified canvas prop-
erty for the given canvas
SET_CANVAS_PROPERTY Sets the specified canvas property for the given canvas
to a specified value
FIND_VIEW Returns the internal view ID (VIEWPORT data
type) of a canvas with the given name
GET_VIEW_PROPERTY Returns the current value of the specified view prop-
erty for the canvas
SET_VIEW_PROPERTY Sets the specified view property for the given canvas
to a specified value
HIDE_VIEW Hides the canvas
SHOW_VIEW Makes the given canvas visible at the current display
position
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)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-9
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Working with Tab-Style


Canvases

Page 1 click Page 2 Page 3

The When-Tab-Page-Changed trigger


fires when a user:

Clicks a tab

Uses either function key


Next tab Page
Previous Next
Previous Tab page Tab Page Tab Page

Copyright Oracle Corporation, 2001. All rights reserved.

Working with Tab-Style Canvases

Tab canvas system variables:


:SYSTEM.TAB_NEW_PAGE
:SYSTEM.TAB_PREVIOUS_PAGE

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-10 Oracle iDS Forms: Build Internet Applications II
Working with Tab-Style Canvases
......................................................................................................................................................

Working with Tab-Style Canvases


When-Tab-Page-Changed Trigger
This form-level trigger fires when there is explicit item or mouse navigation from one
tab page to another in a tab canvas; in other words, when the user clicks a tab or
presses [Ctrl] + [PgUp] or [Ctrl] + [PgDown].
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 to which
you are going.
:SYSTEM.TAB_PREVIOUS_PAGE returns the name of the tab page
from which you are coming.
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 you are changing to another tab page, the cursor does not automatically move to
a different item. To move the cursor you must include a GO_ITEM statement in the
When-Tab-Page-Changed trigger. This is intended functionality to allow users to view
other tab pages without navigating the cursor and therefore causing item navigation
and validation (as previously mentioned).

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-11
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Working with Tab-Style


Canvases

FIND_TAB_PAGE: Returns the tab page ID


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

Copyright Oracle Corporation, 2001. All rights reserved.

Other Arguments for Canvas


Built-Ins

Identify the topmost tab page


Bring a tab page to the top programmatically

If GET_CANVAS_PROPERTY(custab,
TOPMOST_TAB_PAGE)= Billing then
SET_CANVAS_PROPERTY(custab,
TOPMOST_TAB_PAGE,
Address);
end if;

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-12 Oracle iDS Forms: Build Internet Applications 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
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.)
GET_TAB_PAGE_PROPERTY Returns property values (CANVAS_NAME,
ENABLED, LABEL, VISIBLE,
VISUAL_ATTRIBUTE) for a specified tab page
SET_TAB_PAGE_PROPERTY Sets the tab page properties (ENABLED, LABEL,
VISIBLE, VISUAL_ATTRIBUTE) of the specified
tab canvas 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 by 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)
In the preceding syntax example, page_name is either a constant, in single quotes, or
a variable.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-13
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Windows and Blocks


Active Nonactive
Window 1 window window
Block 1

Window 2
Block 2

Block 3
Cursor
location

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-14 Oracle iDS Forms: Build Internet Applications 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 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
manner.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-15
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Manipulating Window Properties


Programmatically

Maximizing MDI application window

SET_WINDOW_PROPERTY
SET_WINDOW_PROPERTY (forms_mdi_window,
(forms_mdi_window,
window_state,
window_state, maximize);
maximize);

Locating the Cursor window


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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
You can also maximize the client server MDI window application with the
WINDOW_STATE command line parameter:
ifrun60.exe module=customer.fmx userid=my_name/my_password@my_database
window_state=maximize
You can switch from the MDI to the SDI window application by using the USESDI
command line parameter:
ifrun60.exe module=customer.fmx userid=my_name/my_password@my_database
usesdi=yes
With SDI window applications, you must size form module windows to allow for the
menu, menu toolbar, and console bar to display.

......................................................................................................................................................
5-16 Oracle iDS Forms: Build Internet Applications 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 Windows)
at run time.

Manipulating the Client Server 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

The 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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-17
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Window with Close Option


on System Menu Box

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-18 Oracle iDS Forms: Build Internet Applications II
Closing Windows
......................................................................................................................................................

Closing Windows
Use the Microsoft Windows close button, or system-menu box, to provide the user
with a means for closing windows. There is no default behavior in Forms when a user
clicks on the close button, therefore you must define a When-Window-Closed trigger.
The following examples show a form based on departments and employees. The
department block and the employee block are located in separate windows. The form
level triggers When-Window-Closed and When-Window-Activated implement the
following functionality:
Exiting from the form or hiding the window that is closed by the user
(Forms automatically activates another window.)
Forcing navigation in the newly activated window
Note: The function GET_CURSOR_WINDOW, discussed in an earlier example, is
used here.

The 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;

The 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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-19
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Control Window Functionality


with Web-Deployed Forms

WIDTH=650
HEIGHT=400
usesdi=no

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-20 Oracle iDS Forms: Build Internet Applications II
Manipulating Windows in Web-Deployed Forms
......................................................................................................................................................

Manipulating Windows in Web-Deployed Forms


When you build Web-deployed forms, some run-time behavior is determined by
Forms Applet parameters that you define in the base HTML file. The Forms Applet
downloads and executes your application into an Applet area on the client browser.
The parameters allow you to select either MDI or SDI options for your application and
to define the size of the Applet area; this area is used as a frame for your forms
windows.
The following parameters affect the run time behavior of Web form windows:

Parameter Value Description


usesdi YES Runs as a SDI Application
usesdi NO Runs as a MDI Application
width integer Width of the Applet area, in pixels
height integer Height of the Applet area, in pixels

The base HTML file is downloaded when a user requests your forms application from
the Web server. It contains information that would otherwise be supplied with the
client server RUNFORM command.
Information on building the base HTML file is covered in the course Oracle 9iAS
Forms Services: Deploy Internet Applications.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-21
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Running Web-Deployed Forms


in the Applet Window

usesdi=yes
separateFrame=true

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-22 Oracle iDS Forms: Build Internet Applications II
Sizing Windows for Web-Deployed Forms
......................................................................................................................................................

Sizing Windows for Web-Deployed Forms


Sizing the Applet Area
The size of the Applet area is determined by the WIDTH and HEIGHT parameters that
were passed to the Forms Applet. If you run the Forms Applet within a browser
HTML page, then the size of the Applet area cannot be changed at run time.
If it is running outside a browser HTML page, the Applet area will have its own
window; the user can resize this window. To run the Form Applet in a separate Applet
window, you can set the separateFrame parameter:

Parameter Value Description


separateFrame false Forms application runs in Applet area.
separateFrame true Forms application runs in a separate
window outside the browser.

If your form module canvases must be larger than the Applet window, then you should
either specify window scrollbars, or consider other Form Builder features such as Tab
canvases, Tree objects, and scrollable Stacked canvases. With these you can extend
the available canvas area within a form module without creating large canvases.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-23
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Display Large Data Blocks


in a Window

Applet area WIDTH = 750


Customer Canvas WIDTH = 2000

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-24 Oracle iDS Forms: Build Internet Applications II
Display Large Data Blocks in a Window
......................................................................................................................................................

Display Large Data Blocks in a Window


With stacked canvases, you can increase the canvas area within a form module,
without defining large form windows. To allow the user to view the entire contents of
large multiple records, you should place some of the text items on a scrollable canvas.
At run time, users can use the canvas scrollbar, or functionality provided by using the
SCROLL_VIEW built-in, to view their data.

Web Design Tip


When you design your base HTML file you can incorporate standard HTML features,
such as lines, tables, and frames. By placing the Form Applet within a specific frame,
you can give your Forms application a more integrated look and feel in your Web
page.
By deliberately sizing your form module window larger than the Applet area and by
preventing the user from moving or resizing the window, you can hide the window
title bar and frame from your Web users. This will enable you to present the form
application as an integral part of the HTML page.
For information on manipulating the base HTML file, attend the course Oracle 9iAS
Forms Services: Deploy Internet Applications.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-25
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Managing Images
for Web-Deployed Forms

Application images are specified outside the form


module
Splash screens
Background images
Form Module images are specified within the form
Image Items
Boilerplate Images

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-26 Oracle iDS Forms: Build Internet Applications II
Managing Images for Web-Deployed Forms
......................................................................................................................................................

Managing Images for Web-Deployed Forms


You can display images with Form Builder in image items or as a boilerplate object on
a canvas. With Web-deployed forms you can also specify Splash and Background
images.
The splash screen is only displayed while the Forms Applet is downloaded. You can
customize the splash screen image by specifying the splashScreen parameter for the
Forms Applet.
Background images are displayed in the Applet area until the application is
terminated. You can display a background image by specifying the backGround
parameter for the Forms Applet.

Parameter Description
splashScreen Identifies the file containing image to be displayed
backGround Identifies the file containing image background

Web Design Tip


Minimize the use of background objects on your canvases. There is an overhead in
downloading images, boilerplate text, and graphics, which can adversely affect
performance in Web-deployed forms. Therefore you should try to:
Use the Prompt item property instead of boilerplate text.
Define only common boilerplate graphics such as rectangles and lines.
For further information on the performance of Web-deployed forms, see the course
Oracle 9iAS Forms Services: Deploy Internet Applications.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-27
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Manage Window-interaction with
SYSTEM.EVENT_WINDOW
Window triggers
Window Built-ins
Manipulate canvases and tab canvases
with Built-ins

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Relate Windows to Data Blocks


Multiple blocks correspond to multiple
windows.
Window activation does not induce navigation.
Transaction management is block-oriented.
Manage Windows in Web-deployed forms
MDI and SDI windows
Sizing the Applet area
Managing Images

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Window-Interaction Triggers
When-Window-Activated
When-Window-Deactivated
When-Window-Closed
When-Window-Resized
Use the SYSTEM.EVENT_WINDOW system variable to keep track
of the triggered window.

Built-ins for Manipulating Windows


Manipulating Windows
Manipulating Canvases
Manipulating Views

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.

Web-deployed Forms
MDI and SDI windows
Applet Areas
Separate frames
Display Large Data Blocks
Splash Screens and Background Images

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-29
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Practice 5 Overview

This practice covers the following topics:


Building a multiple-window form
Using window interaction triggers
Using window and canvas-view built-ins
Enhancing the tab canvas functionality by
Customizing tab page navigation
Disabling tab pages

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
5-30 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 5
......................................................................................................................................................

Practice Overview: Lesson 5


This practice guides you through managing a multiple-window form and tab canvases
programmatically.

Practice Contents
Build a multiple-window form and use the appropriate window
interaction triggers and built-ins to:
- Exit the form when in the primary content canvas window
- Navigate to the primary content canvas window when closing
another window in the form
- Enforce navigation between form windows
Customize tab page navigation.
Disable the Customers comment tab page when there is no data to
display.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 5-31
Lesson 5: Controlling Windows and Canvases Programmatically
......................................................................................................................................................

Practice 5
1 Manipulate a multiple-window form.
a In your ORDERS form module, ensure that the form is exited when a
user closes the Orders window using the window system menu box.
An alert should be displayed to users asking them to confirm that
they wish to leave the application.
b If a user closes the Inventory window through the system menu box,
ensure that the form remains open with the cursor positioned in the
Orders window.
c Whenever the user navigates between the Order and Inventory
windows, place the cursor in the first navigable item within the
current window.
d Save and compile your form. Deploy your form to the Web to test.

2 In your CUSTOMERS form module, define triggers to manage tab page


navigation.
a Using an appropriate trigger, disable the COMMENTS tab page
whenever the COMMENTS item contains no text.
b The trigger should fire whenever the user navigates to another
record.
c Whenever the user moves from one tab page to another, ensure that
the mouse cursor is placed in the first navigable field within the
page.
d Save and compile your form. Deploy your form to the Web to test.

If you have time


3 How can you ensure that the user is returned to the first navigable item
within a tab page after navigating from the last navigable item?

4 How can you enforce item navigation dynamically within a tab page?

......................................................................................................................................................
5-32 Oracle iDS Forms: Build Internet Applications II
................................

Defining Data Sources


Lesson 6: Defining Data Sources
......................................................................................................................................................

Objectives

After completing this lesson, you should be able to


do the following:
Describe the various data source types
Base a data block on a FROM clause query
Describe the advantages of using a
FROM clause query

Copyright Oracle Corporation, 2001. All rights reserved.

Objectives

After completing this lesson, you should be able to


do the following:
Base a data block on a stored procedure
Return a REF cursor from a stored procedure
Return a table of records from a stored procedure
Select the appropriate data source for a
data block

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson introduces you to the different data source types that you can use
for data blocks. This lesson also provides you with some guidelines for
choosing the best data source for the job.

Objectives
After completing this lesson, you should be able to do the following:
Describe the various data source types
Base a data block on a FROM clause query
Discuss the advantages of using a FROM clause query
Base a data block on a stored procedure that returns a REF cursor
Select the appropriate data source for a data block

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-3
Lesson 6: Defining Data Sources
......................................................................................................................................................

Data Source Types

Query DML

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-4 Oracle iDS Forms: Build Internet Applications II
Data Source Types
......................................................................................................................................................

Data Source Types


In the previous course, Oracle 9iDS Forms: Build Internet Applications I,
you learned that a data block had a base table that served as the data source
for both queries and DML operations. A base table is not the only source for
a data block, however, 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-5
Lesson 6: Defining Data Sources
......................................................................................................................................................

Basing a Data Block


on a FROM Clause Query

SELECT...

FROM...

(SELECT...

FROM...

WHERE... WHERE...)

Copyright Oracle Corporation, 2001. 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 every time
Improves developer productivity
Reduces the burden on the DBA
Improves performance

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-6 Oracle iDS Forms: Build Internet Applications 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 query as the data source for a data block. A
FROM clause query is a feature of the Oracle Server that enables you to nest
a SELECT statement in the FROM clause of a SELECT statement.
A FROM clause query is a valid query block data source, but it is not a valid
DML block data source. The value returned from a FROM clause query 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 clause queries are used to perform:
Joins
Lookups
Calculations
This is done without having to create a view on the server. FROM clauses
queries can also be used to prototype views and to increase performance.
Using a FROM clause query as a block data source is similar to using a view
based on an updatable join as a block data source. However, a FROM clause
query provides you with more control, because the presence of a DBA is not
required to define the view.
Note: The FROM clause query produces results that are identical to an
updatable join-view from the client side, but for which there is no defined
view on the server.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-7
Lesson 6: Defining Data Sources
......................................................................................................................................................

Basing a Data Block on a Stored


Procedure for Query Operations

Return data by way of:


REF cursor
A Table of records

Procedure Querying Data block

Empno Ename Job Hire date


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

Copyright Oracle Corporation, 2001. All rights reserved.

Basing a Data Block on a Stored


Procedure for DML Operations

Return data by way of a table of records

Procedure Updating Data block

Empno Ename Job Hire date


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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-8 Oracle iDS Forms: Build Internet Applications 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
data by using either a REF cursor or a table of records.

What Is a REF Cursor?


A REF cursor defines a SELECT statement that is the source of the records.
You can use this cursor 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 be used only as a query block
data source; it cannot be used as a 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 a table of records 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-9
Lesson 6: Defining Data Sources
......................................................................................................................................................

Example of Query Using


a REF Cursor Procedure

Define a package specification with:


The objects returned by the REF cursor
The REF cursor
The query procedure: Data returned
through the first argument (IN OUT)
Define a package body: Write the code for
the query procedure

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-10 Oracle iDS Forms: Build Internet Applications II
Example of a Query Using a REF Cursor Procedure
......................................................................................................................................................

Example of a 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
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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-11
Lesson 6: Defining Data Sources
......................................................................................................................................................

Example of Query Using


a REF Cursor Procedure

Define a package specification with:


The objects returned by the REF cursor
The REF cursor
The query procedure: Data returned
through the first argument (IN OUT)
Define a package body: Write the code for
the query procedure

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-12 Oracle iDS Forms: Build Internet Applications 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 group the logically related data 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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-13
Lesson 6: Defining Data Sources
......................................................................................................................................................

Example of DML Using


a Table of Records Procedure

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 by writing the code for
each DML procedure

Copyright Oracle Corporation, 2001. All rights reserved.

Note
See Appendix F, Handling Server-Side Errors for code details.

......................................................................................................................................................
6-14 Oracle iDS Forms: Build Internet Applications 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 group the logically
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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-15
Lesson 6: Defining Data Sources
......................................................................................................................................................

Returning a REF Cursor

SQL
SELECT

Procedure

Query 1 2 REF cursor

REF cursor
3
Fetched rows
4

Copyright Oracle Corporation, 2001. All rights reserved.

Returning a Table of Records

Any
PL/SQL
code
Procedure

Query 1 2 Cursor

Cursor
3
Table of records
4

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-16 Oracle iDS Forms: Build Internet Applications 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
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 disadvantage 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: The number of records fetched depends on the Array Fetch
property value.
Table of records: All records are fetched.
If you want to view all records, a table of records is more efficient. However,
if the table of records returns 10,000 records and you look only 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-17
Lesson 6: Defining Data Sources
......................................................................................................................................................

Data Block Wizard

Use the Data Block Wizard to specify the following:


Data source type
Query procedure
Insert procedure
Update procedure
Delete procedure
Lock procedure

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-18 Oracle iDS Forms: Build Internet Applications 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, Oracle 9iDS Forms:
Build Internet Applications I.
Use the Data Block Wizard even if you want to create a data 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 rows
Insert procedure Name of the procedure used to insert rows
Update procedure Name of the procedure used to update rows
Delete procedure Name of the procedure used to delete rows
Lock procedure Name of the procedure used to lock rows

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-19
Lesson 6: Defining Data Sources
......................................................................................................................................................

Data Block Properties for Queries

Copyright Oracle Corporation, 2001. All rights reserved.

Data Block Properties for DML

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-20 Oracle iDS Forms: Build Internet Applications II
Data Block Properties
......................................................................................................................................................

Data Block Properties


Data Block Properties for Queries

Property Description
Query Data Source Type Specifies the query data source type for the data block
Query Data Source Name Specifies the name of the block query data source.
(Used when the query data source type is Table, Sub-
query, or Procedure.)
Query Data Source Columns Specifies the names and data types of columns associ-
ated with the query data source. (Used when the query
data source type is Table, Subquery, or Procedure.)
Query Data Source Arguments Specifies the names, data types, and values of the argu-
ments that are to be passed to the procedure for query-
ing data (Used only if the query data source type is
Procedure.)

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 (Used only if the DML data target type is Table.)
(Insert, Update, Delete, Lock) Specifies the name of the procedure to be used (Used
Procedure Name only if the DML data target type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names and data types of the
Procedure Result Set Columns result set columns associated with the
procedure (Used only if the DML data
target type is Procedure.)
(Insert, Update, Delete, Lock) Specifies the names, data types, and values
Procedure Arguments of the arguments that are to be passed to the
procedure (Used only if DML data target
type is Procedure.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-21
Lesson 6: Defining Data Sources
......................................................................................................................................................

Data Source Guidelines

Base a data block on a FROM clause query to:


Create a dynamic view
Perform validation and DML on the
server side

Copyright Oracle Corporation, 2001. All rights reserved.

Data Source Guidelines

Base a data block on a stored procedure to:


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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-22 Oracle iDS Forms: Build Internet Applications II
Data Source Guidelines
......................................................................................................................................................

Data Source Guidelines


Using a FROM Clause Query
You base a data block on a FROM clause query to:
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 last_name, salary FROM s_emp; otherwise open
the cursor as SELECT last_name, null FROM s_emp.
Base a block on multiple tables
Using a REF cursor and depending on some parameter to the procedure,
you could open the cursor either as SELECT * FROM open_orders
(current data) or as 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-23
Lesson 6: Defining Data Sources
......................................................................................................................................................

Data Source Guidelines

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-24 Oracle iDS Forms: Build Internet Applications 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?
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


Table Yes Yes
View Yes Yes
FROM Clause Yes No
Procedure Using a REF Cursor Yes No
Procedure Using a Table of Records Yes Yes
Transactional Trigger Yes Yes

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-25
Lesson 6: Defining Data Sources
......................................................................................................................................................

Summary

In this lesson, you should have learned to:


Base data blocks on new data sources:
FROM clause query (query only)
Stored procedure (query and DML)
Exploit features of stored procedures:
REF cursors
Limited to a single SELECT statement
Table of records
Can be a complex procedure

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Use the Data Block Wizard to specify:


Data source type
Procedures for queries, updates,
deletes, and locking

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-26 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
New Data Sources
Stored procedure (query and DML)
FROM clause query (query only)

Stored Procedures Return


REF cursorslimited to a single SELECT statement
Table of recordscan be a complex procedure

Using the Data Block Wizard


Specify data source type
Specify procedures for queries, updates, deletes, and locking

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-27
Lesson 6: Defining Data Sources
......................................................................................................................................................

Practice 6 Overview

This practice covers the following topics:


Creating a package containing a stored
procedure to return a REF cursor
Creating a data block based on a REF cursor
stored procedure

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
6-28 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 6
......................................................................................................................................................

Practice Overview: Lesson 6


This practice guides you through creating a data block based on stored
procedures.

Practice Contents
Create a package containing a stored procedure to return a REF Cursor
Create a data block based on a stored procedure

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 6-29
Lesson 6: Defining Data Sources
......................................................................................................................................................

Practice 6
1 Create a server-side package containing a procedure to return a REF
cursor.
a Create the Orders_pkg package specification; you can import the
code from the pr6_1.txt file.
b Create the Orders_pkg package body; you can import the code from
the pr6_2.txt file.
c Examine the Orders_pkg package body to identify required
parameter values.

2 Open the ORDERREFCURSOR.fmb file and save as ORDREFXX where


XX is your student course number. This form contains a control block,
called CHOOSE, and a group of option buttons, which allows the user to
specify a parameter value to be passed to the REF cursor.
a Create a data block called SELECTION and base it on the REF
cursor procedure that you have just created.
b Pass the name of the radio group as the value for the P_VIEW
argument: :choose.view_type.
c In the layout editor, customize the canvas layout to ensure that
SELECTION items are displayed to the left of the option buttons
group.
d Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
6-30 Oracle iDS Forms: Build Internet Applications II
................................

Working with Oracle8i


Objects in Form Builder
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to:
Recognize which object types are supported
Describe how object types are
represented within Form Builder
Create a block based on an object table
Create a block based on a relation table
with an object or an REF column
Populate a REF column with an LOV

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson reviews certain object features of Oracle8i and explains how
these objects are displayed in the Object Navigator.

Objectives
After completing this lesson, you should be able to do the following:
Recognize which Oracle8i object types are supported
Describe how Oracle8i objects are represented within Form Builder
Create a block based on an object table
Create a block based on a relational table with an object column or REF
column
Populate a REF column with an LOV

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-3
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Object Types

Attributes

Ship

ORDER
Check po_no Cancel
status custinfo
line_items
amount

Hold
Methods

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-4 Oracle iDS Forms: Build Internet Applications II
What Are Object Types?
......................................................................................................................................................

What Are Object Types?


An object type is a user-defined composite data type. It is in some ways
similar to a record type, and in some ways similar to a package.
An object type is similar to a record type in that it is composed of one or
more subparts that are of predefined data types. Record types call these
subparts fields, but object types call these subparts attributes. Just as the
fields of a record type can be of other record types, the attributes of an object
type can be of other object types. Such an object type is called nested.
Object types are like record types in another sense: both of them must be
declared as types before the actual object or record can be declared.
An object type is also similar to a package. After an object is declared, its
attributes are similar to package variables. Like packages, object types can
contain procedures and functions. In object types, these subprograms are
known as methods.
As with packages, object types can be declared in two parts: a specification
and a body. Like package variables, attributes declared in the object type
specification are public and those declared in the body are private, and as
with package subprograms, all methods are defined in the package body, but
only those whose specification appears in the object type specification are
public methods.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-5
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Review of Objects

Object tables
Object columns
Object views
INSTEAD-OF triggers

DECLARE

BEGIN

EXCEPTION

END;

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-6 Oracle iDS Forms: Build Internet Applications II
Review of Objects
......................................................................................................................................................

Review of Objects
With an object type, you can create object tables, object columns, object
views, and INSTEAD-OF triggers.

Object Tables
After you have declared an object type, you can create objects based on the
type. One way to do this is to create a table whose rows are objects of that
object type. Rows in an object table are assigned object IDs (OIDs) and can
be referenced using a REF type.

Object Column
Another construct that can be based on an object type is an object column in
a relational table. In the object table, the rows of a table are objects. In a
relational table with an object column, the column is an object. The table
usually has standard columns, as well as one or more object columns. Object
columns are not assigned OIDs, and thus cannot be referenced using object
REF values.

Object View
An object view transforms the way a table appears to a user, without
changing the actual structure of the table. Object views make relational
tables look like object tables. Objects accessed through object views are
assigned OIDs, and can be referenced using object REFs.

INSTEAD OF Triggers
INSTEAD OF triggers provide a transparent way of modifying views that
cannot be modified directly through SQL DML statements (INSERT,
UPDATE, and DELETE). These triggers are called INSTEAD-OF triggers
because, unlike with other types of triggers, the Oracle server fires the
trigger instead of executing the triggering statement. The trigger performs
update, insert, or delete operations directly on the underlying tables.

Technical Note
The Database Trigger Editor includes the INSTEAD-OF triggering event.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-7
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

References to Objects

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-8 Oracle iDS Forms: Build Internet Applications II
Object REFs
......................................................................................................................................................

Object REFs
When a row in an object table or object view is created, it is automatically
assigned a unique identifier called an object ID (OID). This OID value can
be stored in attributes of other objects, or columns of other tables. The stored
copy of the OID then becomes a pointer, or REF, to the original object.
(Object columns are not assigned OIDs and cannot be pointed to by a REF.)
In relational databases, primary key values are used to identify records
uniquely. In object-relational databases, OIDs provide an alternate method.
With relational tables, you can associate two records by storing the primary
key of one record in one of the columns (the foreign key column) of another.
In a similar way, you can associate two objects by storing the OID of one
object in an attribute of another, you can associate a row in a relational table
to an object by storing the OID of an object in a column of a relational table.
The attribute or column that holds the OID is of data type REF.
Remember, only the OID value for the object is stored in the table, not the
object itself.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-9
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Oracle8i in Oracle Forms

Supported Oracle8i features


Large Objects: BLOB, CLOB, NCLOB, BFILE
User-defined objects
Object table
Column object
REF column
Unsupported Oracle8i features
Collection types
Stored procedures that return object values

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-10 Oracle iDS Forms: Build Internet Applications II
Supported Oracle8i Features
......................................................................................................................................................

Supported Oracle8i Features


A number of features provided in the Oracle8i Server are available in Oracle
Forms Developer. This allows greater scalability and performance in your
application.
Oracle adds support for the following Oracle8i data types:
Large objects (LOBs): BLOB, CLOB, NCLOB, BFILE
User-defined Oracle8i objects
An object table, where the entire table is based on a single object type
(Oracle Forms Developer treats each column in an object table as an
individual data item.)
A column object in an object or relational table, where the column is
based on an object type definition
A REF column in an object or a relational table, where that columns
values are pointers to rows in a separate object table

Unsupported Oracle8i Features


Not all Oracle8i features are currently supported by Oracle Forms
Developer. The major unsupported features are:
Collection types, including nested tables and varying arrays
Stored procedures that return object values

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-11
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

How Oracle Forms Treats Objects

Object_A Object_A

Attr_A1 Attr_A1

Attr_A2

Object_B

Attr_B1 Attr_A2_B1

Attr_B2 Attr_A2_B2

Attr_A3 Attr_A3

Nested Objects Items in a Form

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-12 Oracle iDS Forms: Build Internet Applications II
How Oracle Forms Developer Treats Objects
......................................................................................................................................................

How Oracle Forms Developer Treats Objects


As you have learned, Oracle8i tables can contain objects. In its support for
the Oracle8i Server, Oracle Forms Developer allows you to access these
objects in an application.
A table itself can be based on an object (a table object), one or more of the
table columns can be based on an object (a column object), or one or more of
the tables columns can contain a reference to an object stored in another
table (REF column). Each of these objects can itself contain objects.
In these cases, the columns and attributes form a hierarchy among the
Oracle8i data types. However, Oracle Forms Developer has no hierarchy of
items. Each item lies directly below the block. Therefore, Oracle Forms
Developer must collapse the hierarchy before the columns and attributes are
mapped to items within a block. Both the hierarchy of the columns and
attributes and the flattened nature of the resulting items are represented in
Oracle Forms Developers displays and dialog boxes.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-13
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Object Display

Object Column

Object Table

Object REF

Object Type

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-14 Oracle iDS Forms: Build Internet Applications II
Object Type Displays
......................................................................................................................................................

Object Type Displays


The Object Navigator lists declared types under the Database Objects node,
along with tables, views, and other Oracle objects. The objects in the
screenshot are based on the following syntax:
-- type declaration
CREATE TYPE dept_type AS OBJECT
(id NUMBER,
name VARCHAR2(25),
region_id NUMBER(7) )
/

-- object table
CREATE TABLE oo_dept_table OF dept_type;

-- object column
CREATE TABLE rel_emp_table_ObjCol (
id NUMBER(7),
last_name VARCHAR2(25),
first_name VARCHAR2(25),
userid VARCHAR2(8),
start_date DATE, manager_id
NUMBER(7),
title VARCHAR2(25),
dept_id dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );

-- ref column
CREATE TABLE rel_emp_table_RefCol (
id NUMBER(7), last_name VARCHAR2(25),
first_name VARCHAR2(25), userid VARCHAR2(8),
start_date DATE, manager_id NUMBER(7), title
VARCHAR2(25), dept_id REF dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-15
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Creating Data Blocks Based


on Oracle8i Objects

Blocks based on object tables


Blocks based on object columns
Blocks with REF Lookups

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-16 Oracle iDS Forms: Build Internet Applications II
Creating Data Blocks Based on Oracle8i Objects
......................................................................................................................................................

Creating Data Blocks Based on Oracle8i Objects


Oracle Forms Developer enables you to create data blocks based on
Oracle8i objects. The Data Block Wizard has been enhanced to support
object tables. The fields of an object are displayed in a hierarchy underneath
the object column in the wizards Table page. Like objects in the Object
Navigator, you can expand or collapse the object columns in the display.
You can base a data block on:
An object table
A column object
A REF column

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-17
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Blocks Based on Object Tables

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-18 Oracle iDS Forms: Build Internet Applications II
Selecting Object Table Columns
......................................................................................................................................................

Selecting Object Table Columns


You can create a data block based on a user-defined object table. In the Data
Block Wizard, you select object tables the same way you select relational
tables. In the wizards Table page, when you select an object table as the
data source, it is expanded and each of its components is displayed in the
Available Columns window. An outline format with indenting is used to
show each component of the object.
You select the type attributes the same way you select relational table
columns. Oracle Forms Developer treats each component in an object table
as a separate column, and allows you to select these columns individually.
The syntax below creates an object table based on an object type:
CREATE TYPE dept_type AS OBJECT
(id NUMBER,
name VARCHAR2(25),
region_id NUMBER(7) )
/

CREATE TABLE oo_dept_table OF dept_type


/
In the diagram, the wizard shows all the columns of the object table
OO_DEPT_TABLE (ID, NAME, REGION_ID). Select any or all as data
block items.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-19
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Blocks Based on Object Columns

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-20 Oracle iDS Forms: Build Internet Applications II
Selecting Object Column Attributes
......................................................................................................................................................

Selecting Object Column Attributes


If you base a block on an object or relational table with an object column,
the attributes of the object column appear indented beneath the name of the
object column in the Data Block Wizard. Oracle Forms Developer treats
each attribute as a separate column. You can select any combination of
columns or object column attributes. Once selected, they all collapse to
the same level as an item within the new block.
Data items selected from an object are given the default name
ColumnObjectName_ItemName. Selecting the object column name itself
has the effect of selecting all of the attributes of the object column.
The syntax below creates a table with an object column:
CREATE TYPE dept_type AS OBJECT
(id NUMBER,
name VARCHAR2(25),
region_id NUMBER(7) )
/

CREATE TABLE rel_emp_table_ObjCol (


id NUMBER(7),
last_name VARCHAR2(25),
first_name VARCHAR2(25),
userid VARCHAR2(8),
start_date DATE,
manager_id NUMBER(7),
title VARCHAR2(25),
dept_id dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );
In the diagram, the wizard displays ID, NAME, and REGION_ID as
columns you can select as data block items.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-21
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Blocks with REF Lookups

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-22 Oracle iDS Forms: Build Internet Applications II
Blocks with REF Lookups
......................................................................................................................................................

Blocks with REF Lookups


If you base a block on an object or relational table with a REF column, the
attributes of the object being referenced appear below the REF column in
the Available Columns window.
Once selected, the attributes of the REF column are made into items, just
like standard columns. However, the items based on REF column attributes
are created with a QUERY ONLY property value of YES, and INSERT
ALLOWED and UPDATE ALLOWED properties of NO.
The syntax below creates a table with a REF data type:
CREATE TYPE dept_type AS OBJECT
(id NUMBER,
name VARCHAR2(25),
region_id NUMBER(7) )
/
CREATE TABLE rel_emp_table_RefCol (
id NUMBER(7),
last_name VARCHAR2(25),
first_name VARCHAR2(25),
userid VARCHAR2(8),
start_date DATE,
manager_id NUMBER(7),
title VARCHAR2(25),
dept_id REF dept_type,
salary NUMBER(11,2),
commission_pct NUMBER(4,2) );
As seen in the diagram, the REF column name (DEPT_ID) appears twice in
the column selection list. It appears once as a heading for the referenced
objects attributes and then again as a pointer. The column is selectable.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-23
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Using the REF Lookup Value

Select REF attribute columns: This causes the


columns to appear as data items at run-time.
Select the REF item itself:
This causes the item to be placed on a Null canvas.
The item does not appear at run time.
The item is available for coding purposes.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-24 Oracle iDS Forms: Build Internet Applications II
The REF Column Value
......................................................................................................................................................

The REF Column Value


The double listing of the REF column name affords you different choices.
As with a regular column object, you can select any or all of a REFs
attribute columns. Selecting the first instance of the REF name in the
diagram on the previous page selects all its parts.
When you select one or more of the REFs attribute columns, they appear as
normal data items in the data block at run time.
You can also select the REF itself, which is the second entry in the diagram
on the previous page. If the REF column itself is included in the block, it is
created as a nondisplay item and placed by default on the Null canvas.
Although the REF item does not appear on the canvas at run time, it is still
available for coding purposes.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-25
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

LOVs for REFs

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-26 Oracle iDS Forms: Build Internet Applications II
LOVs for REFs
......................................................................................................................................................

LOVs for REFs


Users may use an LOV to select appropriate referenced values. The Data
Block Wizard presents the LOV for REF window, which enables you to
define an LOV.

How to Create the LOV


1 Select the REF desired.
2 For the REF selected, the wizard lists all the associated tables. Select the
table of your choice.
The wizard builds the LOV from the values in this table.
Note: The same LOV gets attached to all the lookup items associated with a
particular REF.
REFs are defined on object types, not on specific tables. Therefore, a REF
can point to multiple tables.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-27
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Identify supported Oracle8i object types
Define data blocks based on object tables
Define data blocks based on tables
with object columns or REF columns
Populate REF columns with an LOV

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Oracle Forms Developer supports most, but not all, of the Oracle8i
object types.
In Forms Builder, object types are displayed like columns, where
indentation shows the nesting of objects.
Blocks can be based on object tables.
Blocks based on object or relational tables can include object columns or
REF columns.
REF columns can be populated with an LOV.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-29
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Practice 7 Overview

This practice covers the following topics:


Creating a block based on a relational
table with an object column
Creating a block based on a relational
table with a REF column
Populating a REF column with an LOV

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
7-30 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 7
......................................................................................................................................................

Practice Overview: Lesson 7


This practice guides you through creating data blocks based on Oracle8i
object tables.

Practice Contents
Create a block based on a relational table with an object column
Create a block based on a relational table with a REF column
Populate a REF column with an LOV

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 7-31
Lesson 7: Working with Oracle8i Objects in Form Builder
......................................................................................................................................................

Practice 7
1 Create a data block based on a relational table with an object column.
a Create a form called OBJ_COLXX where XX is your student course
number.
b Using the Data Block Wizard, create a block based on the
REL_EMP_TABLE_OBJCOL relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Expand the object column DEPT_ID and select the attributes ID and
NAME. Note the names that are given to the new items.
e In the Layout Wizard, select all available items for display. Change
the prompt for item DEPT_ID to Department ID and
DEPT_ID_NAME to Department Name. Use a form layout.
f Save, compile, and test your form.

If you have time


2 Create a block based on a relational table with an REF column, and
specify an LOV to populate the REF column.
a Create a form called REF_COLXX where XX is your student course
number.
b Create a block based on the REL_EMP_TABLE_REFCOL
relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Select the DEPT_ID attributes ID and NAME.
e Create an LOV for the REF item DEPT_ID. Select the check box,
and select OO_DEPT_TABLE as the source for the LOV.
f In the Layout Wizard, select all available items for display.
g In the Object Navigator, identify the canvas with which item
DEPT_ID is associated.
h In the Object Navigator, check that an LOV and associated record
group have been created.
i Save, compile, and test the form.

......................................................................................................................................................
7-32 Oracle iDS Forms: Build Internet Applications II
................................

Controlling Data Block


Relationships
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Objectives

After completing this lesson, you should be able to


do the following:
Define block coordination
Coordinate data blocks by using REF relations
Describe the characteristics and
principles of relation-handling code
Implement a coordination-type toggle
Force one commit per master record

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
You have seen how form modules consist of data blocks based on related
tables. This lesson shows how you can modify the relationship between two
data blocks to affect the way in which deletes are handled and to what extent
the data blocks are coordinated at query time. Also, it explains how to create
relationships based on object REFs.

Objectives
After completing this lesson, you should be able to do the following:
Define block coordination
Coordinate data blocks by using REF relations
Describe the characteristics and principles of relation-handling code
Implement a coordination-type toggle
Force one commit per master record

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-3
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Relations

Logical objects that handle the relationship


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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-4 Oracle iDS Forms: Build Internet Applications II
Creating a Relation
......................................................................................................................................................

Creating a Relation
What Is a Relation?
A relation is a Form Builder object that handles the relationship between
two associated blocks.
You can create a relation either:
Implicitly with a master-detail form module
Explicitly in the Object Navigator

Implicit Relations
When you create a master-detail form module, a relation is automatically
created. This relation is named in the format masterblock_detailblock, for
example, S_ORD_S_ITEM.

Explicit Relations
If a relation is not established when default blocks are created, you can
create your own, either by setting the properties in the master block New
Relation dialog box, or by calling the reentrant wizard for the detail data
block. Like implicitly created relations, PL/SQL program units and triggers
are created automatically when you explicitly create a relation.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-5
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Block Coordination

Coordination-causing event
Block-coordination phases:
Clear phase executed before change
of master record
Populate phase executed after
change of master record
Implementation of block coordination:
The Copy Value from Item property
Relation-handling triggers
Relation-handling procedures

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-6 Oracle iDS Forms: Build Internet Applications II
Block Coordination
......................................................................................................................................................

Block Coordination
To maintain a master-detail relationship, Forms coordinates the master and
detail blocks to ensure that only the detail records that belong to the current
master record are displayed.

Coordination-Causing Events
Any event that changes the master record is called a coordination-causing
event or a coordination operation. Forms automatically coordinates the
master and detail blocks again when you move to another master record.

Block Coordination Phases


Phase Description
Clear Forms clears all detail blocks before it navigates to the new master record.
Unsaved changes in detail blocks are 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.

Web Design Tip


You can reduce potential network traffic within Web-deployed forms by
specifying deferred coordination. By using relation-handling built-ins, you
can give users the run-time option of selecting either immediate or deferred
coordination.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-7
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Blocks with REF Relations

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-8 Oracle iDS Forms: Build Internet Applications II
Coordinate Blocks Using REFs
......................................................................................................................................................

Coordinate Blocks Using REFs


Many object-oriented languages implement master-detail relations by
storing in the detail data an internal identifier to the master data. This
internal identifier is known as a reference (REF). To support object-oriented
programming, the Data Block Wizard enables you to base the relation on a
REF rather than on a foreign key.
To create a master-detail relation based on a REF, the detail block must
contain the REF column. Create a master-detail form using REFs by doing
the following in the Data Block Wizard:
1 Create the master block and choose the columns you wish to include as
items in the block. Complete the Layout Wizard steps to finish creating
and laying out the master block.
2 Create the detail block. When you choose columns, you must choose the
REF column, because this value will be used to establish the
relationship. You should not choose the lookup columns, because doing
so causes the detail block to duplicate items that are already displayed in
the master block.
3 On the Master-Detail page of the wizard, click the Create Relationship
button. A dialog box appears listing all possible master blocks for the
relationship. Select the appropriate master block and click OK and then
Finish.
4 Complete the Layout Wizard steps to finish creating and laying out the
detail block.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-9
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Characteristics of
Relation-Handling Triggers

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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Relation-handling triggers fire only if you have defined a corresponding
relation.

......................................................................................................................................................
8-10 Oracle iDS Forms: Build Internet Applications II
Characteristics of Relation-Handling Triggers
......................................................................................................................................................

Characteristics of Relation-Handling Triggers


Forms automatically creates and maintains relation-handling triggers to
implement block coordination and restricted-delete foreign-key rules.
Trigger Description
On-Clear-Details Fires when a coordination-causing event occurs in a
master 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-
causing event is aborted.
On-Populate-Details Fires when a coordination-causing event occurs in a
master block, after Forms has navigated to the new master
record. However, this trigger fires only if an On-Clear-
Details trigger 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 rule. However, this is a
commit trigger, not a relation-handling trigger, and can also be used outside
the context of relations.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-11
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Principles of Relation-Handling Code

Three relation-handling procedures:


CLEAR_ALL_MASTER_DETAILS
QUERY_MASTER_DETAILS
CHECK_PACKAGE_FAILURE
Adding your own code to relation-handling triggers:
Forms adds comments around code.
You add your own code before or after
these comments.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-12 Oracle iDS Forms: Build Internet Applications II
Principles of Relation-Handling Code
......................................................................................................................................................

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-13
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Obtaining Relation-Handling Information

System variables for relation handling:


SYSTEM.MASTER_BLOCK
SYSTEM.COORDINATION_OPERATION
Built-ins for relation handling:
GET_FORM_PROPERTY
GET/SET_BLOCK_PROPERTY
GET/SET _RELATION_PROPERTY

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
8-14 Oracle iDS Forms: Build Internet Applications II
Obtaining Relation-Handling Information
......................................................................................................................................................

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
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 using the Set-Relation-Property built-
in.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-15
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Implementing a
Coordination-Type Toggle

Define a procedure that toggles between


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

Copyright Oracle Corporation, 2001. All rights reserved.

Implementing a
Coordination-Type Toggle

Call this procedure from:


When-Checkbox-Changed trigger
Menu item of type Check

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-16 Oracle iDS Forms: Build Internet Applications II
Implementing a Coordination-Type Toggle
......................................................................................................................................................

Implementing a Coordination-Type Toggle


You can use relation-handling built-ins to offer users the choice between
immediate and deferred coordination.
You can use this example procedure 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;
.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-17
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Forcing a Commit Per Master

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

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-18 Oracle iDS Forms: Build Internet Applications II
Forcing a Commit Per Master
......................................................................................................................................................

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-19
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Define Relation coordination properties
Manage data block coordination
Coordination-causing events change
the master record
Clear and populate

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Obtain relation-handling information


Identify characteristics of relation-handling
triggers
Identify characteristics of relation-handling
procedures
Coordinate data blocks with REF Elements

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-20 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Creating Relations
Implicitly, when you create a master-detail form module
Explicitly, by creating the relation after the blocks have been created

Block Coordination
Coordination-causing events cause a change of the master record.
The two block-coordination phases are the Clear and Populate phases.
Base coordination of blocks on REF values.

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.
You can use built-ins for relation handling to get relation names and to
get or set relation properties.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-21
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Practice 8 Overview

This practice covers the following topics:


Examining and changing relation properties
Implementing a coordination-type toggle for a
master-detail form
Synchronize coordination-type toggle at form
startup

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
8-22 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 8
......................................................................................................................................................

Practice Overview: Lesson 8


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

Practice Contents
Examining and changing relation properties
Using check boxes to implement a coordination-type toggle for a master-
detail form.
- The first check box should enable a user to toggle between
immediate coordination and deferred coordination.
- The second check box should enable a user to toggle between auto
query and no auto query in the detail block.
Synchronizing the coordination-type toggle at form startup.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-23
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

Practice 8
1 Open your ORDERS form and examine the properties of the relation
called S_ORD_S_ITEM.
a Note the deletion and coordination property values.
b Run the ORDERS form and test the way deletes are handled.
2 Implement a query coordination-type toggle.
a Add two check boxes to the control block with the following
properties:

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
Data Type CHAR CHAR
Initial Value Y Y
DataBase Item No No
Canvas TOOLBAR TOOLBAR

b Use the Layout Editor to position the check boxes appropriately in


the Toolbar canvas.
c Make sure that the first check box enables a user to toggle between
immediate coordination and deferred coordination. You can import
the code from the pr8_1.txt file.
d Make sure that the second check box enables a user to toggle
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 code from the
pr8_2.txt file.
e Save, compile, and test your form.

......................................................................................................................................................
8-24 Oracle iDS Forms: Build Internet Applications II
Practice 8
......................................................................................................................................................

If you have time


3 Synchronize the check boxes at form startup.
a Open your ORDERS form module
b Create a procedure called SYNCHRONIZE_CHECKBOX. This
procedure synchronizes the IMMEDIATE and AUTO_QUERY
check boxes with the current default value. You can import the code
from the pr8_3.txt file.
c Call this procedure from the When-New-Form-Instance trigger.
d Save, compile, and test your module.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 8-25
Lesson 8: Controlling Data Block Relationships
......................................................................................................................................................

......................................................................................................................................................
8-26 Oracle iDS Forms: Build Internet Applications II
................................

Building Multiple Form


Applications
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Objectives

After completing this lesson, you should be able to


do the following:
Describe the different ways of invoking
additional forms
Open, call, and close forms
Navigate between Web-deployed
form modules

Copyright Oracle Corporation, 2001. All rights reserved.

Objectives

After completing this lesson, you should be able to


do the following:
Control opened forms and called forms
Manage transaction processing for
opened forms and called forms
Choose the most appropriate method
for invoking forms
Pass form parameters

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
You have already seen that Oracle Forms Developer applications frequently consist of
more than one form. This lesson revisits the topic of multiple form applications and
takes a deeper look into the ways in which one form module can invoke another and
the effects this has on transaction processing.

Objectives
After completing this lesson, you should be able to do the following:
Describe the various ways of invoking additional form modules
Open, call, and close form modules
Navigate between Web-deployed form modules
Control open form modules and called form modules
Manage transaction processing for open and called form modules
Choose the most appropriate method for invoking form modules
Pass form parameters

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-3
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

OPEN_FORM to Invoke
Additional Forms

Modeless
Different transaction scopes

A B

OPEN_FORM(form_name,
OPEN_FORM(form_name, activate_mode,
activate_mode,
session_mode,
session_mode, data_mode,
data_mode, paramlist);
paramlist);

Copyright Oracle Corporation, 2001. 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: FORMS60_SESSION

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-4 Oracle iDS Forms: Build Internet Applications 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 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

Using Data Mode to Share PL/SQL Variable Data


You can use the data mode parameter to share PL/SQL variable data between forms.
Create a package that contains the PL/SQL variables to be shared, and place the
package in a library. Attach the library to all the forms that are to share the data. In the
OPEN_FORM command, set the data_mode parameter to
SHARE_LIBRARY_CODE. Any changes made by one form are visible to the other
forms. This method of sharing data between forms is preferable to global variables
because the PL/SQL variables benefit from PL/SQLs strong typing and because PL/
SQL variables are stored and accessed more efficiently than global variables.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-5
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Closing Forms

CLOSE_FORM:
form_name
form_id
Characteristics of CLOSE_FORM:
Restricted
Not valid in Enter-Query mode
CLOSE_FORM or EXIT_FORM
Cannot close a form that called
another form

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-6 Oracle iDS Forms: Build Internet Applications II
Closing Forms
......................................................................................................................................................

Closing Forms
Syntax
CLOSE_FORM(form_name);
CLOSE_FORM(form_id);

Parameter Description
form_name The module name of the form (not the .fmx filename)
form_id The internal form module ID of the form (of type Form Module)

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.

Web Design Tip


The Oracle Forms Developer application will continue if you attempt to exit your
Web-deployed form application by closing the browser window, while other browser
windows are still open. It will not terminate until the browser is also closed down. It is
recommended that users are always able to close their applications either with the
CLOSE_FORM or the EXIT_FORM commands. Applications that are not terminated
will continue until timed out by the Oracle Forms Server.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-7
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Navigating Between Forms

Built-ins for navigation between forms:


NEXT_FORM
PREVIOUS_FORM
GO_FORM

Copyright Oracle Corporation, 2001. All rights reserved.

Navigating Between Forms

Navigation and validation aspects:


Each open form has a current item.
There is no validation when navigating
between forms.
No triggers fire when navigating
between forms, except the When-Window-
Activated/Deactivated and
When-Form-Navigate triggers.
Click the noncurrent item in the other form.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-8 Oracle iDS Forms: Build Internet Applications 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 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 number
(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 num-
ber.
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.)

Navigation 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 you are navigating between open forms, no validation occurs in
the starting form. When you return to the starting form and attempt to
navigate within that form, normal validation is enforced.
When you are navigating between (current items of) open forms, no
triggers fire. The only exceptions are the When-Window-Activated,
When-Window-Deactivated, and When-Form-Navigate triggers. Even
the navigational triggers do not fire when you are navigating between
open forms.
The triggers that typically fire when you navigate from the current item
to the target item will fire when you click a noncurrent item of an open
form. When this happens, navigational triggers also fire and validation
occurs as required.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-9
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Opening Forms Within


the Same Session

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

Copyright Oracle Corporation, 2001. All rights reserved.

Opening Forms in Different Sessions

Connection
Runform Server

Session

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-10 Oracle iDS Forms: Build Internet Applications 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 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 noncurrent 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, noncurrent open forms are not
cleared.

Opening Forms in Different Sessions


The multiple-session feature of the Oracle server enables 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 Runtime invocations by
setting the FORMS60_SESSION environment variable to True.
Forms Runtime must be running with the Session option turned on when
you execute OPEN_FORM with the SESSION_MODE parameter set to
SESSION.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-11
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

CALL_FORM to Invoke
Additional Forms

Modal
Returns to calling form

A B

CALL_FORM(form_name,
CALL_FORM(form_name, display,
display,
switch_menu,
switch_menu, query_mode,
query_mode,
data_mode,
data_mode, paramlist);
paramlist);

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-12 Oracle iDS Forms: Build Internet Applications 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, you cannot work in the calling form. When the 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 call-
ing form should be hidden from view while the called form is running.)
switch_menu Either NO_REPLACE (the default) or DO_REPLACE (This defines
whether the current menu module should be replaced by the default
menu of the called form.)
query_mode Either NO_QUERY_ONLY (the default) or QUERY_ONLY (This
defines whether the called form should run in Query Only mode.)
data_mode Either NO_SHARE_LIBRARY_DATA (the default) or
SHARE_LIBRARY_DATA
paramlist Either the name (in quotes) or internal ID of a parameter list
(This argument is optional.)

Characteristics of CALL_FORM
Is valid in Enter Query mode
Causes Forms to issue a savepoint
Causes called form to be modal
Does not cause navigation or validation in the initial form
Can call a form in Query Only mode
Propagates query-only parameter through all subsequent called forms
Returns control to the calling form and resumes processing of the
PL/SQL code at the statement immediately following the calling
statement (This occurs when Forms exits the called form.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-13
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Save Not Allowed


in Post-Only Mode Form

A calling form has unapplied changes.


Save not allowed.

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-14 Oracle iDS Forms: Build Internet Applications 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.

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 is also in Post-Only mode. In Post-Only mode, you can submit DML
statements to the database, but you cannot commit the changes. You can only commit
the changes after you exit the form that is running 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. In other words, the changes are
written to the database, but a commit statement is not issued. 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 than 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);
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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-15
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Transaction Processing
for Called Forms

Examples of adjusting default


transaction processing:
Key-Commit on form

IF
IF <form
<form called>
called> THEN
THEN
POST;
POST;
ELSE
ELSE
COMMIT_FORM;
COMMIT_FORM;
END
END IF;
IF;

Copyright Oracle Corporation, 2001. All rights reserved.

Transaction Processing
for Called Forms

Key-Exit on form

IF <form called> THEN


EXIT_FORM(ASK_COMMIT, NO_ROLLBACK);
EXIT_FORM
ELSE
EXIT_FORM;
END IF;

Adjust labels of corresponding buttons and menu items

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-16 Oracle iDS Forms: Build Internet Applications 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 processing performs a post when the form is
called.
Redefine [Exit] so that processing 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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-17
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

NEW_FORM to Invoke
Additional Forms

Replaces calling form

A B

NEW_FORM(form_name,
NEW_FORM(form_name, rollback_mode,
rollback_mode,
query_mode,
query_mode, data_mode,
data_mode,
paramlist);
paramlist);

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-18 Oracle iDS Forms: Build Internet Applications 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 new form completely replaces the current 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.)

Web Design Tip


With small Web-deployed form modules, you can reduce the time to download your
applications from the server. You can easily link Form modules together by using the
OPEN_FORM and NEW_FORM built-ins. You can therefore provide users with all
the functionality that they require, when they need it.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-19
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Controlling Opened
and Called Forms

Form A Form C Form D


OPEN_FORM
S.P.
CALL_FORM
CALL_FORM

Form B
OPEN_FORM
S.P. Form F
CALL_FORM

Form E
Form A+B+E = Call form stack

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
9-20 Oracle iDS Forms: Build Internet Applications 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.

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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-21
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Different Ways of Invoking Forms

When to use OPEN_FORM


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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-22 Oracle iDS Forms: Build Internet Applications 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 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


The main advantage of this built-in is that it conserves memory because the invoked
form replaces the invoking form.

Web Design Tip


Additional forms may be opened within a Web-deployed form by using the built-in
WEB.SHOW_DOCUMENT. With this command you must specify a URL to call
another form. An additional Forms run-time session, however, will be generated.
In order to run many forms within one Web-deployed Forms run-time session, use
OPEN_FORM, CALL_FORM or NEW_FORM.
Calling forms will impose a burden on client and Web Server memory. If it is unlikely
that the user will return to the calling form, (such as a login form), use NEW_FORM.
If the user will continue to use the calling form, then OPEN_FORM will save the
startup delay and use of network resources that reloading the form would otherwise
incur.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-23
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Using Form Parameters

What is a form parameter?


How to create a form parameter

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-24 Oracle iDS Forms: Build Internet Applications II
Using Form Parameters
......................................................................................................................................................

Using Form Parameters


What Is a Form Parameter?
Form parameters provide a mechanism for supplying values that a form requires at
startup. These parameters are form variables that you define at design time.

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, you can specify values for form parameters.
Specify the parameters on the Runtime 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-25
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Using Form Parameters

Passing a form parameter at run time:

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

Referencing form parameters from


within a module:
:PARAMETER.parameter_name
PARAMETER.parameter_name

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-26 Oracle iDS Forms: Build Internet Applications II
Using Form Parameters
......................................................................................................................................................

Example
Pass a value for the CUS_ID form parameter to the ORDITEM form by way of the
Runtime command line. Note that MODULE and USERID are predefined command
line parameters.
ifrun60.exe module=orditem userid=scott/tiger cus_id=202

Referencing Form Parameters


You can reference form parameters in a way similar to how you would access 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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-27
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Parameter Lists

Parameter
list

CUS_ID TEXT_PARAMETER 204

ORDERS DATA_PARAMETER RG_ORD

OPEN_FORM( , )

CALL_FORM( , )

NEW_FORM( , )
The default parameter list is DEFAULT

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
The parameters whose values are being passed must be defined in the called form at
design time. That is, the called form must be expecting a value for each of the
parameters included in the parameter list it receives from the calling form.

......................................................................................................................................................
9-28 Oracle iDS Forms: Build Internet Applications 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.

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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-29
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Creating and Manipulating


Parameter Lists

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

Copyright Oracle Corporation, 2001. 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.

......................................................................................................................................................
9-30 Oracle iDS Forms: Build Internet Applications II
Creating and Manipulating Parameter Lists
......................................................................................................................................................

Creating and Manipulating Parameter Lists


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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-31
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Passing Data Between Forms

1. If a parameter list exists, destroy it.


2. Create a parameter list.
3. Add a text parameter to a list with the value
of an item.
4. Open a form with this parameter list.
Form A Form B
Run time OPEN_FORM(*) Design-time
parameters parameters
P1 P1
P2 P2
P3 P3

Copyright Oracle Corporation, 2001. All rights reserved.

Passing Data Between Forms

Characteristics of form parameters:


Can be used only as input parameters
Have data type CHAR, NUMBER, or DATE
CHAR parameter can be up to 64 K long
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

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Global variables are used more often than parameters for passing data between forms.

......................................................................................................................................................
9-32 Oracle iDS Forms: Build Internet Applications II
Passing Data Between Forms
......................................................................................................................................................

Passing Data Between Forms


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

Example
The When-Button-Pressed trigger on the CTL.OPEN_ORDITEM item:
DECLARE
v_pl_id PARAMLIST;
BEGIN
IF not ID_NULL(GET_PARAMETER_LIST(cus)) THEN
DESTROY_PARAMETER_LIST(cus);
END IF;
v_pl_id := CREATE_PARAMETER_LIST(cus);
ADD_PARAMETER(v_pl_id,cus_id,text_parameter,
TO_CHAR(:cus.id));
OPEN_FORM(orditem, activate, no_session,
no_share_library_data, cus);
END;

Note: You must define the CUS_ID parameter in the ORDITEM form at design time,
because each run-time parameter must have a corresponding design-time parameter in
the target form.

Form Parameters and Global Variables


Form parameters can be used only 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 data type of CHAR, NUMBER, or DATE.
- The length of a CHAR parameter can be up to 64 K.
- 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-33
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Open, call, and close forms:
OPEN_FORM, CALL_FORM, and
CLOSE_FORM
Multiple database sessions
Navigate between forms:
NEXT_FORM,
PREVIOUS_FORM, and GO_FORM
Identify restrictions on the call form stack

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Manage Transaction processing in:


Opened forms: Within same or
different sessions
Called forms: Post-Only mode; a
rollback to savepoint
Create form parameters and parameter lists
Methods for parameter passing
Referencing form parameters
Text parameters and Data parameters
Built-ins for parameter lists

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-34 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
The Three Built-ins for Invoking Forms
OPEN_FORM
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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-35
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Practice 9 Overview

This practice covers the following topics:


Implementing a multiple form application by
calling SALESREP from CUSTOMERS
Performing an automatic query on
the SALESREP form, based on the
Sales Rep ID value in the CUSTOMER form
Ensuring that posted changes in
SALESREP are not rolled back
Passing a parameter list from CUSTOMERS
to SALESREP

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
9-36 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 9
......................................................................................................................................................

Practice Overview: Lesson 9


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

Practice Contents
Implement a button on the CUSTOMER form to call the SALESREP form.
Perform an automatic query on the SALESREP form based on the
current sales rep ID in the CUSTOMER form.
Ensure that posted changes in the SALESREP form are not rolled back
on exit.
Pass a parameter list from the CUSTOMERS form to the SALESREP
form.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-37
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

Practice 9
1 Create a multiple-form application by linking the CUSTOMERS and the
SALESREP forms. The SALESREP form provides a look up facility for
:S_CUSTOMER.SALES_REP_ID. It replaces the SALES_REP_LOV
list of values. Values are selected by mouse double click.
a Open SALESREP form and save as SALESREPXX where XX is
your student course number.
b In your CUSTOMERS form, modify the code in the
SALES_LOV_BUTTON When-Button-Pressed trigger to call the
SALESREP form.
c Ensure that the user can see, but not navigate to, your CUSTOMERS
form, while the SALESREP form is open.
d Update :S_CUSTOMER.SALES_REP_ID with the value selected
by the user in the SALESREP form. The selected Sales Rep ID is
returned in a GLOBAL variable called salesrepid. This variable
contains either a valid value or the text NOT SELECTED.
e Save and compile your form. Deploy your form to the Web to test.

2 Modify your multiple-form application to enable the SALESREP form


to be called in post mode only.
a Hide the CUSTOMERS form when the SALESREP form is
displayed.
b In the SALESREP form, ensure that whenever the form has been
opened by CALL_FORM, that a [Commit Form] performs a POST.
c Ensure that updates in SALESREP are not cleared when the user
exits the form.
d Save and compile your form. Deploy your form to the Web to test.

3 The SALESREP form displays a list of all employees; modify your


application to ensure that only Sales Representatives are displayed when
the form is called from CUSTOMERS.
a Create a parameter called EVERYONE in the SALESREP form.
Specify a default value of Y.

......................................................................................................................................................
9-38 Oracle iDS Forms: Build Internet Applications II
Practice 9
......................................................................................................................................................

b Ensure that the SALESREP form will perform an unrestricted query


whenever the parameter value = Y. If the parameter value = S, a
restricted query should be performed, selecting only Sales
Representatives.
c In the CUSTOMERS form, pass the parameter value S to the
SALESREP form.
Create a parameter list called EMPS. Add the EVERYONE
parameter to the parameter list. The type of this parameter is
TEXT_PARAMETER, and it is initialized with the value S.
Pass the parameter list to the SALESREP form by using the
CALL_FORM built-in.
You can import the code from the pr9_1.txt file. Be sure to
change the name of the module in the CALL_FORM built-in.
d Save and compile your forms. Deploy your form to the Web to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 9-39
Lesson 9: Building Multiple Form Applications
......................................................................................................................................................

......................................................................................................................................................
9-40 Oracle iDS Forms: Build Internet Applications II
................................

Working with Record


Groups
Lesson 10: Working with Record Groups
......................................................................................................................................................

Objectives

After completing this lesson, you should be able to


do the following:
Describe the record group object
Use record groups
Define record groups at design time
Control record groups by using built-in functions
Define query record groups programmatically
Define nonquery record groups programmatically

Copyright Oracle Corporation, 2001. All rights reserved.

Objectives

After completing this lesson, you should be able to


do the following:
Manipulate record group rows
Define lists of values (LOVs) programmatically
Manipulate list items programmatically
Implement dynamic list items
Add values to combo boxes

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
Record groups are useful constructs for storing structured data, and they can
be manipulated at run time. This lesson covers how to create, modify, and
delete record groups at design time and programmatically at run time. It also
covers how you apply record groups in useful ways, such as for dynamic list
items.

Objectives
After completing this lesson, you should be able to do the following:
Describe the record group object
Use record groups
Define record groups at design time
Control record groups by using built-in functions
Define query record groups programmatically
Define nonquery record groups programmatically
Manipulate record group rows
Define lists of values (LOVs) programmatically
Manipulate list items programmatically
Implement dynamic list items
Add values to combo boxes

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-3
Lesson 10: Working with Record Groups
......................................................................................................................................................

Record Groups

Three record group types:

SOURCE Based on a Not Based on a


SELECT SELECT
TIME Statement Statement
Design Time QUERY STATIC

Run Time QUERY NON QUERY

Copyright Oracle Corporation, 2001. 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
IF Get_LOV_Property(lov_id,GROUP_NAME)
Get_LOV_Property(lov_id,GROUP_NAME) == GROUP1
GROUP1
THEN
THEN
Set_LOV_Property(lov_id,GROUP_NAME,GROUP2);
Set_LOV_Property(lov_id,GROUP_NAME,GROUP2);
END
END IF;
IF;
...
...

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-4 Oracle iDS Forms: Build Internet Applications II
Record Groups
......................................................................................................................................................

Record Groups
What Is a Record Group?
A record group is an internal Forms data structure that is similar to a
database table. It can have columns of type CHAR, NUMBER, or DATE,
and its data is stored in rows. Record groups exist in local Forms memory,
rather than in the database.

Three Record Group Types


Type Description
Query Record Group A record group with 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. You can create this type of record group at design
time and at run time.
Nonquery 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 SQL query statement. At
run time, you can call the SET_LOV_PROPERTY built-in function to
replace the default record group of an LOV with another one. Use the
GROUP_NAME property.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-5
Lesson 10: Working with Record Groups
......................................................................................................................................................

Uses for Record Groups

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-6 Oracle iDS Forms: Build Internet Applications II
Using Record Groups
......................................................................................................................................................

Using Record Groups


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

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

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 that 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 Builder and Graphics
Builder. 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 bidirectional; you can also transfer the values of a list
item to a record group. (This can be considered storing the list item.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-7
Lesson 10: Working with Record Groups
......................................................................................................................................................

Defining Record Groups


at Design Time

Copyright Oracle Corporation, 2001. All rights reserved.

Column Specification and Record Group


Property Sheet

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-8 Oracle iDS Forms: Build Internet Applications 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.
Forms displays the New Record Group dialog box.
2 Click the Based on the Query Below... option 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 generates 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-9
Lesson 10: Working with Record Groups
......................................................................................................................................................

Creating and Deleting Record Groups

CREATE_GROUP CREATE_GROUP_FROM_QUERY

Name Name, Query

Record ID Name
Record
group ID group ID

DELETE_GROUP

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-10 Oracle iDS Forms: Build Internet Applications II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................

Built-in Functions for Controlling Record Groups


You can create and modify query and nonquery record groups
programmatically at run time by using the following built-in functions.

Creating and Deleting Record Groups


Built-in Function Description
CREATE_GROUP Creates a nonquery 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-11
Lesson 10: Working with Record Groups
......................................................................................................................................................

Populating Query Record Groups

SELECT ID, name


FROM s_customer
ID Name
201 Unisports
202 SImms Athletics
POPULATE_GROUP
203 Delhi Sports
204 Womansport (_WITH_QUERY)

Copyright Oracle Corporation, 2001. All rights reserved.

Getting and Setting Record


Group Cell Values

ID Name

SET_GROUP_CHAR_CELL

GET_GROUP_NUMBER_CELL

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
POPULATE_GROUP built-in function returns 0 when population succeeds
and 1 if population does not succeed.

......................................................................................................................................................
10-12 Oracle iDS Forms: Build Internet Applications II
Built-in Functions for Controlling Record Groups
......................................................................................................................................................

Populating Record Groups


Built-in Function Description
POPULATE_GROUP Executes the query associated with the given
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 nonquery record group into a query record group
by using the POPULATE_GROUP_WITH_QUERY built-in function to
populate the nonquery 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.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-13
Lesson 10: Working with Record Groups
......................................................................................................................................................

Processing Record Group Rows

GET_GROUP_SELECTION_COUNT

Selection No Row No ID Name


1 201 Unisports
1 2 202 Simms Athletics
3 203 Delhi Sports
2 4 204 Womansport

GET_
GROUP_
ROW_
SET_GROUP_SELECTION COUNT
GET_GROUP_SELECTION

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-14 Oracle iDS Forms: Build Internet Applications 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
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
number 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.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-15
Lesson 10: Working with Record Groups
......................................................................................................................................................

Defining Query Record Groups


Programmatically

Find record group

Yes ID NULL? No

Create group from query

Populate group

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-16 Oracle iDS Forms: Build Internet Applications 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.
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 doesnt 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);

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-17
Lesson 10: Working with Record Groups
......................................................................................................................................................

Defining Nonquery Record Groups


Programmatically

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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-18 Oracle iDS Forms: Build Internet Applications II
Defining Nonquery Record Groups Programmatically
......................................................................................................................................................

Defining Nonquery Record Groups Programmatically


The PL/SQL code below illustrates how you can create and populate a
nonquery record group. Note that you cannot define nonquery record groups
at design time.
DECLARE
v_rg_id RECORDGROUP;
v_gc1_id GROUPCOLUMN;
v_gc2_id GROUPCOLUMN;
BEGIN
--Make sure that record group doesnt 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 nonquery record group into a query record group by
calling the POPULATE_GROUP_WITH_QUERY built-in function.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-19
Lesson 10: Working with Record Groups
......................................................................................................................................................

Manipulating Record Group Rows

Get number of group rows

Cell value=
For all given value
group Yes No
rows
Return row
number

Return NULL

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-20 Oracle iDS Forms: Build Internet Applications II
Manipulating Record Group Rows
......................................................................................................................................................

Manipulating Record Group Rows


The function below illustrates how you can loop through all rows of a record
group.
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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-21
Lesson 10: Working with Record Groups
......................................................................................................................................................

Manipulating Selected Record Group


Rows

Get number of group rows

Row number
For all even?
group Yes No
rows
Mark row
as selected

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-22 Oracle iDS Forms: Build Internet Applications 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.
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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-23
Lesson 10: Working with Record Groups
......................................................................................................................................................

Defining Global Record Groups

Record group visible to all forms in


an application
Scope parameter
FORM_SCOPE (default)
GLOBAL_SCOPE

...CREATE_GROUP(group_name,
...CREATE_GROUP(group_name, scope);
scope);
...CREATE_GROUP_FROM_QUERY(group_name,
...CREATE_GROUP_FROM_QUERY(group_name,
query,
query, scope);
scope);

Copyright Oracle Corporation, 2001. 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 nonquery record group. The record group retains its data, but a
subsequent POPULATE_GROUP is considered an error.

......................................................................................................................................................
10-24 Oracle iDS Forms: Build Internet Applications 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.

Scope Parameter
A scope parameter can be added to the CREATE_GROUP and
CREATE_GROUP_FROM_QUERY built-ins. The value for this scope can
be either:
FORM_SCOPE
GLOBAL_SCOPE
If you omit this parameter, the default is FORM_SCOPE.
Once created, a global record group persists for the remainder of the
application.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-25
Lesson 10: Working with Record Groups
......................................................................................................................................................

Manipulating List Items


Programmatically

ADD_LIST_ELEMENT
DELETE_LIST_ELEMENT
CLEAR_LIST
GET_LIST_ELEMENT_LABEL
GET_LIST_ELEMENT_VALUE
GET_LIST_ELEMENT_COUNT
POPULATE_LIST
RETRIEVE_LIST

Copyright Oracle Corporation, 2001. All rights reserved.

Using a Record Group


with a List Item
Labels Values

POPULATE_LIST RETRIEVE_LIST

CHAR Column 1 CHAR Column 2

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-26 Oracle iDS Forms: Build Internet Applications 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
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 contains only 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 speci-
fied 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 by 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-27
Lesson 10: Working with Record Groups
......................................................................................................................................................

Implementing Dynamic List Items

Find record group

Yes ID NULL? No

Create group from query

Populate group

Yes Success? No

Populate list

Display first list label

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-28 Oracle iDS Forms: Build Internet Applications 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.
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.

Technical Note
Because a base table list item must specify a value for either the Initial
property or the Mapping of Other Values property, the record group used to
dynamically populate a list item must also contain this value. Be sure the
record group query returns this value. For more information, see Note
1010798.6, available on MetaLink: http://www.metalink.oracle.com.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-29
Lesson 10: Working with Record Groups
......................................................................................................................................................

Adding Values to Combo Boxes

Get number of list elements

Element value=
For all Item value?
list Yes No
elements
Return

Add list element with item value

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-30 Oracle iDS Forms: Build Internet Applications 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
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;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-31
Lesson 10: Working with Record Groups
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Define design-time query and static
record groups
Define run time query and nonquery
record groups
Use Built-in functions for populating
record groups
Define Global record groups

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Use record groups for:


Constructing dynamic SELECT statements
Storing or passing data
Populating or storing list items
Manipulate list items programmatically
Built-in functions for list items

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-32 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
A record group is an internal Forms data structure that is similar to a
database table.

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


Created 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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-33
Lesson 10: Working with Record Groups
......................................................................................................................................................

Practice 10 Overview

This practice covers the following topics:


Basing a dynamically populated list item
on a design-time query record group
Basing a dynamically populated list item
on a run-time query record group

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
10-34 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 10
......................................................................................................................................................

Practice Overview: Lesson 10


This practice guides you through the creation of design-time and run-time
query record groups.

Practice Contents
Convert a text item into a list item that is populated dynamically at run
time by a design-time query record group.
Create a list item that is populated dynamically at run time by a run-time
query record group.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-35
Lesson 10: Working with Record Groups
......................................................................................................................................................

Practice 10
1 Create a dynamic list item populated from a design-time query record
group. The record group will hold region ID and the name of the
departments in the S_DEPT table.
a Open the Employees form. Save as EmpXX where XX is your student
course number. In the Object Navigator, create a record group named
DEPT_ID based on the query below:
SELECT name || in region ||
TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
UNION
SELECT none Name, 0 Id from dual
ORDER BY 1
b Convert the text item DEPT_ID into a list item, with a Poplist style.
Resize the list item in the Layout Editor.
c Create one element in the list item. Specify a label of Dummy and a
value of 0. Set the Mapping of Other Values property to 0.
d Create a procedure called POPULATE_DEPT_LIST. This procedure
will accept the list item name as an argument and populate the list
item dynamically at run time, using the design-time query record
group.
You can import the code from the pr10_1.txt file.
e Call the procedure each time a new record is created.
f Save and compile your form module to test.

If you have time


2 Replace the design-time query record group in the Employee form with
a run-time query-based record group.

......................................................................................................................................................
10-36 Oracle iDS Forms: Build Internet Applications II
Practice 10
......................................................................................................................................................

a Delete the DEPT_ID record group and remove the code from the
When-Create-Record trigger.
b Create a procedure called CREATE_DEPT_LIST which will
dynamically create a record group called QDEPT, if it does not
already exist. The procedure will also populate the record group by
using the query:
SELECT name ||TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
UNION
SELECT none Name, to_char(0) Id
FROM dual
ORDER BY 1
c The procedure will also populate the list item S_EMP.DEPT_ID.
d You can import the procedure code from pr10_2.txt file.
e Call the procedure from the When-Create-Record trigger.
f Save and compile your form module to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 10-37
Lesson 10: Working with Record Groups
......................................................................................................................................................

......................................................................................................................................................
10-38 Oracle iDS Forms: Build Internet Applications II
................................

Using Reusable
Components
Lesson 11: Using Reusable Components
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
List the reusable components
Include the calendar object in
an application

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson, you will learn about the reusable components that are
available with Oracle Forms Developer. You will learn how these
components can fit into any application.

Objectives
After completing this lesson, you should be able to do the following:
List the reusable components
Include the calendar object in an application

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-3
Lesson 11: Using Reusable Components
......................................................................................................................................................

Reusable Components

Picklist

Calendar

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-4 Oracle iDS Forms: Build Internet Applications II
Reusable Components
......................................................................................................................................................

Reusable Components
Oracle Forms Developer contains a complete set of demonstrations that
illustrate the power and productivity of the product. These demonstrations
contain many tips and techniques that you can copy and use in your own
applications.

Reusable Component Definition


A reusable component is a generic object (object group, block, PL/SQL
library, and so on) that you can reuse in all your applications. You can create
your own reusable components (code and object) by using the generic
programming characteristics.
Oracle Forms Developer also includes a number of reusable components
that enable you to easily and rapidly build applications that provide power
and performance while conforming to GUI standards. You can customize
these components.

Web Design Tip


JavaBeans and Enterprise JavaBeans are reusable components that you can
use with Web-deployed Oracle Forms Developer applications. These allow
you to create a customized look and feel for the user interface, and to add
additional functionality. The deployment of JavaBeans is covered in a later
lesson.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-5
Lesson 11: Using Reusable Components
......................................................................................................................................................

Reusable Components List

ActiveX controls
Java Beans
Sample Icons
Standard Menus
PL/SQL Drag & Drop Library
PL/SQL Utilities Library
PL/SQL Conversion Library
PL/SQL Window System Interface Library

Copyright Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
11-6 Oracle iDS Forms: Build Internet Applications II
Reusable Components List
......................................................................................................................................................

Reusable Components List


The reusable components include:

Reusable Component Description


ActiveX controls An ActiveX control is a stand-alone software component that
you can include in your applications. Five ActiveX controls
are shipped with Oracle Forms Developer: Image, Sound,
Spread Table, Tabsheet, and a Video object.
ActiveX controls cannot be used with Web-deployed forms.
JavaBeans A JavaBean is a stand-alone software component that you
can include in your Web-deployed applications. JavaBeans
allow you to customize the user interface, and to add new
functionality.
Sample icon files Sample icons can be found on the demo CD provided with
Oracle Forms Developer CD pack. ICO and GIF icon files
used in the demonstrations and sample menus are included.
Standard menus These demonstrations include menudef.mmb and a number
of standard menus that you may want to reuse and customize.
PL/SQL Drag and drop This PL/SQL library provides procedures to implement drag
library and drop in client server applications.
PL/SQL Utilities library This PL/SQL library contains a procedure to write out the
contents of a block.
PL/SQL Conversion library This PL/SQL library contains procedures to perform
complex conversions.
PL/SQL Window system This PL/SQL library contains many commonly used routines
interface library specific to the Windows environment. The utility consists of
a PL/SQL library and a Windows dynamic-link library
(DLL) and can be used with either Form Builder or Report
Builder.
The PL/SQL library uses the ORA_FFI package and can be
used as a model for creating your own DLL calls. The utility
FFI_GEN is also available to help you generate a PL/SQL
interface to DLLs.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-7
Lesson 11: Using Reusable Components
......................................................................................................................................................

Reusable Components List

Standard Object Library


Calendar class
Picklist class
Wizard class
Navigator class
Help class
Oracle Applications Object Library

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-8 Oracle iDS Forms: Build Internet Applications II
Reusable Components List
......................................................................................................................................................

Reusable Component Description


Standard object library The object library, stndrd20.olb, contains standard
classes and visual attribute groups to help you build your
applications to a standard look and feel. Some objects in the
library are set as SmartClasses so that they can be readily
applied to the objects created in your forms.
Calendar class This stndrd20.olb library component enables you
to add a calendar or date list of values to your application
Picklist class This stndrd20.olb library component enables you
to easily add a picklist or chooser-style interface to an appli-
cation, and to provide functionality that mimics the picklists
of wizards and other dialogs.
Wizard class This stndrd20.olb library component enables you
to easily add a wizard-style interface to an application, and to
provide functionality that mimics the wizards of the Oracle
Forms Developer builders and other Windows products.
Help class This stndrd20.olb library component enables you
to build an online Help facility with a Windows look and
feel. Help text is stored on the database.
Oracle applications object The object library, appsstds.olb, contains property
library classes and visual attribute groups that enable you to build
modules that have the same look and feel as Oracle
Applications. They have a Windows look and feel, but they
have also been designed for maximum portability.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-9
Lesson 11: Using Reusable Components
......................................................................................................................................................

The Calendar Class

Copyright Oracle Corporation, 2001. All rights reserved.

Creating a Calendar

To create a calendar:
1. Copy or make the Calendar Object
Group a subclass.
2. Attach the PL/SQL library
CALENDAR.PLL.
3. Create a Key-Listval trigger.
4. Call Date_LOV.Get_Date.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-10 Oracle iDS Forms: Build Internet Applications II
The Calendar Class
......................................................................................................................................................

The Calendar Class


This component enables you to easily add a calendar or date list of values to
an application. The Calendar window automatically displays the calendar
according to the NLS settings that are currently in effect, adjusting the start
of the week (for example, Sunday in the United States, Monday in Western
Europe) and the month and day names accordingly.

Creating a Calendar
To create a calendar, follow the steps below:
1 Open the stndrd20.olb object library. From the Components page,
copy or subclass the Calendar object group.
2 Attach the PL/SQL library calendar.pll, which contains the
Date_LOV package, to your module.
3 Create a Key-Listval trigger on the date item for which you would like to
use the Date List of Values window. Add code to display the calendar
using the Date_LOV package.
4 If you want the end user to be able to close the Date List of Values
window by clicking the WindowClose button in the title bar, create a
form-level When-Window-Closed trigger.
The calendar appears whenever the end user invokes a list of values for the
date item. A single calendar can be reused on many different date items.
Simply create a Key-Listval trigger for each item.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-11
Lesson 11: Using Reusable Components
......................................................................................................................................................

Calendar Object Group Content

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-12 Oracle iDS Forms: Build Internet Applications II
Calendar Object Group Content
......................................................................................................................................................

Calendar Object Group Content


The component contains many different Form Builder objects. You can
customize those objects for your specific application.

The Blocks
The calendar object contains two blocks:
Date_Control_Block: This block contains the buttons that control which
month and year is displayed.
Date_Button_Block: This block contains the buttons that represent each
day of the month.

The Canvas
The calendar class contains a content canvas named Date_Lov_Canvas. This
canvas contains all the items from both blocks.

The Window
The calendar class contains a window named Date_Lov_Window. This
window is used to display the Date_Lov_Canvas.

The Visual Attributes


The calendar class contains three visual attributes:
Date_Normal_VA: This visual attribute contains the attributes for a date
button that is displayed normally.
Date_Selected_VA: This visual attribute contains the attributes for a date
button that is displayed as selected.
Date_Weekend_VA: This visual attribute contains the attributes for a
date button that is displayed as a weekend day.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-13
Lesson 11: Using Reusable Components
......................................................................................................................................................

Built-in for Manipulating


the Calendar

Use Date_LOV.Get_Date to display the calendar


Syntax
date_lov.get_date( display_date,return_item,
window_x_pos,window_y_pos,
window_title,
ok_label,cancel_label,
highlight,
autoconfirm,autoskip );

Example
date_lov.get_date(sysdate,s_ord.date_ordered,240
date_lov.get_date(sysdate,s_ord.date_ordered,240
,60,Order
,60,Order Date,OK,Cancel,TRUE,FALSE,FALSE);
Date,OK,Cancel,TRUE,FALSE,FALSE);

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-14 Oracle iDS Forms: Build Internet Applications II
Built-in for Manipulating the Calendar
......................................................................................................................................................

Built-in for Manipulating the Calendar


To use the calendar class, you have to attach a PL/SQL library called
calendar.pll. This library contains a package called DATE_LOV. This
package contains routines that the developer uses to interact with the
component.

Date_LOV.Get_Date Procedure
This procedure displays the calendar with the month and year specified in
the Display_Date argument. The day of the month is displayed with bold
numbers. The date chosen by the end user is returned to the item specified
by the Return_Item argument.
. . .
PROCEDURE Date_LOV.Get_Date(
display_date DATE, return_item VARCHAR2,
v_x_pos NUMBER := 0, v_y_pos NUMBER := 0,
v_title VARCHAR2 := Date List of Values,
v_ok VARCHAR2 := OK,
v_cancel VARCHAR2 := Cancel, v_highlight BOOLEAN := TRUE,
v_autoconfirm BOOLEAN := TRUE, v_autoskip BOOLEAN := FALSE );. . .

Argument Description
display_date The date to display when the Date List of Values window first
appears
return_item The name of the block and item to which to return the chosen date
v_x_pos Specifies the X coordinate of the Date List of Values window
v_y_pos Specifies the Y coordinate of the Date List of Values window
v_title Title to display in the Date List of Values window
v_ok Label for the OK button
v_cancel Label for the Cancel button
v_highlight Specifies that weekend days appear in a different color
v_autoconfirm Specifies that the date immediately be returned when the end user
clicks a day
v_autoskip Specifies that the input focus moves to the next item in sequence

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-15
Lesson 11: Using Reusable Components
......................................................................................................................................................

Summary

In this lesson, you should have learned to:


Identify reusable components in Oracle Forms
Developer
Create a Calendar class:
Copy forms objects from calendar object
library
Copy PL/SQL code from calendar PL/SQL
library

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-16 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Reusable Components
The purpose of a reusable component
Reusable components list

The Calendar Class


Create a calendar
Calendar Object Group content
Built-in for manipulating the calendar

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-17
Lesson 11: Using Reusable Components
......................................................................................................................................................

Practice 11 Overview

This practice covers the following topics:


Creating a picklist class to display and
select the products available
Attaching a calendar class to ORDERS
date items:
date_ordered
date_shipped

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
11-18 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 11
......................................................................................................................................................

Practice Overview: Lesson 11


This practice guides you through the development of form functionality
based on reusable components.

Practice Contents
Create a picklist to display and select the products available.
Add a calendar on the S_ORD.DATE_ORDERED and
S_ORD.DATE_SHIPPED items.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-19
Lesson 11: Using Reusable Components
......................................................................................................................................................

Practice 11
1 Create a picklist by using the picklist class. This picklist enables the end
user to select order items from a product list, and to place selections in a
second list.
a Create a new form module, called PICKXX where XX is your student
course number. Open the Form_Builder_II.olb object
library. This library contains form objects and code for the picklist.
Copy the PICKLIST_BASIC object group to your form module.
Copy the PICKLIST object group into your new form module.
b Ensure the CONTROL block is the last defined data block in the
Object Navigator.
c Attach the picklist.pll library. This contains the functions
and procedures required for creating the picklist.
d Define a When-New-Form-Instance trigger which will create and
populate the picklist. You can import the code from the
pr11_1.txt file.
Create the picklist with the picklist.Create_Picklist procedure.
Call function pick_list.Populate_Picklist_With_Query to populate
the List_in object. You must define a query that returns the ID, name
and suggested prices from the S_PRODUCT table.
Call pick_list.Set_Picklist_Selection procedure to select the first
element in the list.
Display both lists by using the pick_list.Display_Picklist procedure.
Exclude from the query any products already in the current S_ITEM
block. You should use the global variable :GLOBAL.where_cls.
e Save and compile your form. Deploy your form to the Web.
f In your ORDERS form, modify the When-Button-Pressed trigger for
the CONTROL.PRODUCT_LOV_BUTTON so that it calls your
new form module.
g Save and compile your form. Deploy your form to the Web to test.

If you have time


2 In the ORDERS form, add a calendar on the S_ORD.DATE_ORDERED
item and S_ORD.DATE_SHIPPED item.
a From the calendar page of the Form_Builder_II.olb object
library, copy the calendar object group.

......................................................................................................................................................
11-20 Oracle iDS Forms: Build Internet Applications II
Practice 11
......................................................................................................................................................

b Attach the PL/SQL library calendar.pll, which contains the


Date_LOV package, to your module.
c Create a Key-Listval trigger on the date ordered item. Add code to
display the calendar using the Date_LOV package. You can import
the code from the pr11_2.txt file.
d Create a Key-Listval trigger on the date shipped item. Add code to
display the calendar using the Date_LOV package.You can import
the code from the pr11_3.txt file.
e Save and compile your form module. Deploy your form to the Web
to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-21
Lesson 11: Using Reusable Components
......................................................................................................................................................

......................................................................................................................................................
11-22 Oracle iDS Forms: Build Internet Applications II
................................

Using Java with


Web-Deployed Forms
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Customize the user interface
Incorporate JavaBeans in Web-deployed forms
by:
Inserting Pluggable Java Components
Creating Bean Areas
Use Oracle8i Java with Web-deployed forms
Use the Java Importer Tool

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson you will learn how to enhance Web-deployed forms by using
JavaBeans to customize the user interface. You will also learn about
Oracle8i features that may be used within Web-deployed Oracle forms.

Objectives
After completing this lesson, you should be able to do the following:
Customize the user interface
Incorporate JavaBeans in Web-deployed forms by
- Inserting Pluggable Java Components
- Creating Bean Areas
Exploit Oracle8i features with Web-deployed forms
Invoke the Java Importer Tool

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-3
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Java and Oracle Forms Developer

Java class files Platform independent


programs

Java Runtime A Java Virtual Machine


Environment executes class files in Web
browser

Forms Applet Downloads class files to


create and maintain the
Forms user interface

JavaBeans reusable programs for Forms!


Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-4 Oracle iDS Forms: Build Internet Applications II
Java and Oracle Forms Developer
......................................................................................................................................................

Java and Oracle Forms Developer


Oracle Forms Developer applications are deployed on the Web by
downloading Java class files to the client browser. The class files create the
user interface for the Forms Server application modules and maintain
communications between Server and client browser.

Java Runtime Environment


At run time Java class files are executed by the Java Virtual Machine (JVM).
This is either included with a Web browser or with an AppletViewer. The
Java Runtime Environment (JRE) is the combination of the JVM and
supporting files.
Oracle JInitiator provides an alternative to the standard browser JRE; it
enhances the Web deployment of Oracle Forms Developer applications. It is
supplied as a Netscape plug-in or as an ActiveX component for MicroSoft
Internet Explorer.

Forms Applet
The Forms Applet is a Java code component embedded in the base HTML
file. It is responsible for downloading and executing the Java class files that
create the Oracle Forms Developer user interface.

JavaBeans
JavaBeans are portable, reusable and platform independent Java programs.
You can change the appearance and behavior of the Forms user interface by
including JavaBeans in your Oracle Form Builder applications.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-5
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Java in Web-Deployed Forms

Oracle Look
and Feel

Bean
Areas

Pluggable Java
Components

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-6 Oracle iDS Forms: Build Internet Applications II
Java in Web-Deployed Forms
......................................................................................................................................................

Java in Web-Deployed Forms


You can customize the user interface for your Oracle Forms Developer
applications by using the following Java features.

Oracle Look and Feel


As an alternative interface to the traditional gray Windows look, Oracle
Forms Developer provides a Look and Feel parameter for the Forms Applet.
This allows you to change the appearance and color of the user interface for
an entire application.

JavaBeans
You can add JavaBeans to extend existing Oracle Form Developer
components using Pluggable Java Components. With Bean Areas you can
insert JavaBeans that provide new application functionality, and may also be
used to execute code on the user interface.

Pluggable Java Components


You can replace the original appearance or functionality of existing Form
items with a Pluggable Java Component (PJC). You can introduce variety
with your applications by displaying, for example, rounded buttons, traffic
light option buttons, and smoking checkbox.

Bean Areas
You can insert new functionality, such as slider controls or progress bars, by
defining a Bean Area Item in your form module. With supplied triggers and
PL/SQL built-ins, you can communicate between the Form Server and the
client JavaBean.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-7
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Oracle Look and Feel

Oracle Look and Feel


Pluggable Java Components
Bean Areas

Copyright Oracle Corporation, 2001. All rights reserved.

Oracle Look and Feel

Oracle Look and Feel is defined in the Forms Applet


base HTML file
<HTML><BODY>
<EMBED type="application/x-jinit-applet"
java_CODE="oracle.forms.engine.Main"
java_CODEBASE="/web_frms/"
java_ARCHIVE="f60all.jar"
WIDTH=750 HEIGHT=400
serverPort="5555"
serverArgs="module=emp userid=scott/tiger@mydatabase"
serverApp="/web_html/summit"
pluginspage="http://machine/jinit_download.htm"
splashScreen="/web_img/summitlo.gif"
lookAndfeel="Oracle"
colorScheme="teal">
</EMBED>
</BODY></HTML>

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-8 Oracle iDS Forms: Build Internet Applications II
The Forms Applet
......................................................................................................................................................

The Forms Applet


When the base HTML file is downloaded, the embedded Forms Applet is
executed by the Java Virtual Machine (JVM) on the Forms Client. The JVM
may either be in a browser or in an AppletViewer.
You can test your Web forms without deploying them to the middle tier by
using Form Builders Web Previewer. This uses the AppletViewer as a JVM.

Oracle Look and Feel


IView is a Java class file which manages the display of Web-deployed
forms. Oracle Look and Feel exploits IView to provide you with an
alternative user interface to the MS Windows look. You can implement your
choice by specifying the Forms Applet lookAndFeel parameter in the base
HTML file:

Parameter Parameter Value


lookAndFeel Determines the applications look and feel. Values:
Oracle or Generic (Windows 95 look-and-feel).
Default value is Generic.
colorScheme Determines the applications color scheme. Values:
Teal, Titanium, Red, Khaki, Blue, Olive, or Purple.
Ignored when lookAndFeel is set to Generic.

Technical Note
To enable the Web Previewer, you must have installed the Forms Server
Runtime Engine in your test environment.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-9
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Defining Fonts
for Web-Deployed Forms

Use Java supported fonts:


Java Font Windows Font XWindows Font Mac Font
Monospaced Courier New Adobe-courier Courier
Dialog MS San Serif b&h-lucida Geneva
DialogInput MS San Serif b&h-lucidatypewriter Geneva
Helvetica Arial Adobe-Helvetica Helvetica
Symbol Wingdings itc-zapfdingbats Symbol
Times Roman Times New Roman Adobe-times Times Roman

Define your default Java font in:


Oracle_Home
/form60/java/oracle/forms/registry/reg
istry.dat

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-10 Oracle iDS Forms: Build Internet Applications II
Defining Fonts for Web-Deployed Forms
......................................................................................................................................................

Defining Fonts for Web-Deployed Forms


When you select a font for building your Web-deployed forms applications,
you should ensure that it will map to supported Java fonts. The Java
environment for Oracle Forms Developer supports the following fonts:

Java Font MS Windows Font Windows Font X Macintosh Font


Monospaced Courier New Adobe-courier Courier
Dialog Ms Sans Serif b&h-lucida Geneva
DialogInput Ms Sans Serif b&h-lucidatype- Geneva
writer
Helvetica Arial Adobe-Helvetica Helvetica
Symbol WingDings itc-zapfdingbats Symbol
TimesRoman Times New Roman Adobe-times Times Roman

At run time, Oracle Form Developer fonts are converted to their Java
equivalent using a reference to an alias file, Registry.dat. If your
selected Oracle Form Builder font does not map to a supported Java font, it
will be replaced with the default Java font. You can specify the default Java
font by editing the Java registry file. The Registry.dat file is located
in:
ORACLE_HOME/forms60/java/oracle/forms/registry/

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-11
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Pluggable Java Components

Oracle Look and Feel


Pluggable Java Components
Bean Areas

Copyright Oracle Corporation, 2001. All rights reserved.

Pluggable Java Components

Pluggable Java Components ( PJCs ) are JavaBeans


that enable you to customize the appearance and
functionality of existing Form Builder control items.

Pluggable Java Components are supported with the


following Form Items:

Check box List Item Push Button


Text Item Radio Button

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-12 Oracle iDS Forms: Build Internet Applications II
Pluggable Java Components
......................................................................................................................................................

Pluggable Java Components


When you deploy Oracle Forms Developer modules on the Web, native user
interface controls, such as push buttons or radio buttons, are replaced by a
Java user interface component. The Java components are defined as defaults
within Form Builder. They are based on Java class files supplied with Oracle
Forms Developer; you do not need to specify them.
As an alternative to the standard Java user interface component, you can
specify a Pluggable Java Component, which will enable you to customize
the appearance and functionality of the original control. The PJC is a
JavaBean that must support the properties and events specific to the type
of user interface component, for which it is being used.

Specifying Use of a PJC in an Oracle Forms Developer Module


You may specify a PJC for any form module user interface control which
has an Implementation Class property. Supported control types are:
Check Box
List Item
Push Button
Radio Button
Text item

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-13
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Pluggable Java Components


Examples

Text Items:

Checkboxes:

Y N

Smoking ?

Radio Buttons
Cash
Credit Card
Cheque

Copyright Oracle Corporation, 2001. All rights reserved.

Using Pluggable Java Components

Select a valid Form Item

Specify the name and path of your PJC


in the Implementation Class property:

Name: PasswordFieldPJC.class
Path :
FORMS60_JAVADIR oracle\forms\demos

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-14 Oracle iDS Forms: Build Internet Applications II
Pluggable Java Components
......................................................................................................................................................

Pluggable Java Components


Oracle provides Java class files for building components in Web-deployed
forms. The default value is the name of the standard PJC supplied with
Oracle Forms Developer. To use your own PJC, you must supply the fully
qualified name of the PJC Java class file:

Implementation Class property Description


Default value Oracle supplied PJC; value not displayed in
property palette
Fully qualified name of PJC Custom PJC specified by application
developer.
Example oracle.forms.demos.SecureText

Example: Specifying the Securetext PJC


This PJC will display salary data as asterisk characters. When the user clicks
on the field, the PJC will reveal the salary values:
Open the Property Palette for :EMP.SAL and select the Implementation
Class property.
Specify the full name of the PJC: oracle.forms.pjc.demo.SecureText
Form Builder will search for the file SecureText.class in the
demos directory, in the path FORMS60_JAVADIR/oracle/forms/
Compile the form module.

Location of PJC Class Files


You should specify the FORMS60_JAVADIR environment variable to
enable Oracle Forms Developer to locate your JavaBeans. The default path
is: ORACLE_HOME/forms60/java. It is recommended that you place
your custom JavaBean class files within a subdirectory in this path.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-15
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Bean Areas

Pluggable Java Components


Oracle Look and Feel
Bean Areas

Copyright Oracle Corporation, 2001. All rights reserved.

What is a Bean Area?

A Bean Area is a Forms item that enables you to


incorporate JavaBeans in your Web-deployed forms.
With Bean Areas you can:
Add new control
items and new Hello Forms!
functionality Someone hit the OK
button.
Execute Client- heres the
side Java code Date Changed event
and
Communicate a parameter list with
between Forms the selected date
Server and Client
with PL/SQL

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-16 Oracle iDS Forms: Build Internet Applications II
What Is a Bean Area?
......................................................................................................................................................

What Is a Bean Area?


Bean Areas are Forms objects that allow you to host JavaBeans in your
Web-deployed forms application. The behavior of these JavaBeans is
determined by you, and you can therefore use Bean Areas to provide new
functionality for your form module. Unlike Pluggable Java Components,
there is no assumed behavior. A PJC, such as a button, knows about being
pressed; the Bean Area functionality is derived totally from within the
JavaBean.

With PL/SQL built-ins and triggers, you can also communicate with the
JavaBean at run time.

Uses and Benefits of Bean Areas


Add new control items and new functionality
Execute Client side Java code
Communicate between the Form Server and Client

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-17
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Hosting a JavaBean

1. Define a Bean Area

2. Specify the JavaBean

3. JavaBean is visible in
Layout Editor

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-18 Oracle iDS Forms: Build Internet Applications II
Hosting a JavaBean
......................................................................................................................................................

Hosting a JavaBean
You can host a JavaBean in your Oracle Forms Developer application by
creating a Bean area control item.

Creating a Bean Area


You can create a Bean Area in three ways:
Use the Bean Area Item tool in the Layout Editor
Use the Create icon in the Object Navigator
Convert an existing item

Associating a JavaBean with Your Bean Area


In order to associate your JavaBean with the Bean Area, you will need to
name the JavaBean class file in the Bean Area Implementation class
property. This property entry is mandatory.
Oracle Forms Developer will locate your JavaBean class files by searching
the Java directory, specified in the FORMS60_JAVADIR environment
variable.
Java is a case sensitive language, and you must ensure that the class file
name is precisely specified. You must also supply a fully qualified name.
For example, the location of MyEg.class file is:
FORMS60_JAVADIR/oracle/forms/demos/MyEg.class
You should therefore specify an entry in the Implementation class property:
oracle.forms.demos.MyEg
After you have specified the Implementation class property, the JavaBean
will be visible in the Bean Area (in the Layout Editor).

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-19
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

How a JavaBean Communicates

A JavaBean communicates with a Web-deployed


form by issuing an event.

When-Custom-Item-Event trigger

System variables:
:SYSTEM.CUSTOM_ITEM_EVENT
:SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-20 Oracle iDS Forms: Build Internet Applications II
How a JavaBean Communicates
......................................................................................................................................................

How a JavaBean Communicates


Communicating with Forms from a JavaBean
A JavaBean will initiate communication with a form by firing a
CustomEvent. The JavaBean CustomEvent sends an event name, and the
name of a parameter list containing associated data, to the form module. You
can obtain this information from the system variables:

System Variable Description


:SYSTEM.CUSTOM_ITEM_EVENT Name of Custom event dispatched by Java
Bean; this is case sensitive.
:SYSTEM. Name of Parameter list containing
CUSTOM_ITEM_EVENT_PARAMETERS associated event data

How Forms Receives JavaBean CustomEvents


Whenever the JavaBean communicates with your form, the
When-Custom-Item-Event trigger will fire. This trigger should be attached
to the Bean Area hosting the JavaBean. By examining the form module
system variables from this trigger, you can identify which JavaBean
CustomEvent has occurred, and take appropriate action.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-21
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Communicating with the JavaBean

SET_CUSTOM_PROPERTY built-in
Example:
Declare
EventName varchar2(20) := :system.custom_item_event;
EventValues ParamList;
EventvalueType number;
TempString varchar2(4000);
Begin
If EventName = ALARMFIRED then
EventValues := get_parameter_list(:system.custom_event_parameters);
get_parameter_attr(EventValues, ALARMTIME, EventvalueType,
TempString);

If Summit_Show_Alert(Alarm Call:||TempString) =
alert_button1 then
set_custom_property(jAlarmClock, 1, wakeuptime, 1000);
end if;
end if;
End;

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-22 Oracle iDS Forms: Build Internet Applications II
Communicating with the JavaBean
......................................................................................................................................................

Communicating with the JavaBean


The JavaBean will accept parameters from PL/SQL that enable you to
change its run-time behavior. For example, you can alter the speed of a
progress bar or the time for a clock. You can communicate with your
JavaBean by calling the built-in SET_CUSTOM_PROPERTY:
SET_CUSTOM_PROPERTY(bean_area, row, property, value);

Example
SET_CUSTOM_PROPERTY(alarm_clock,1, wakeuptime, 1000);
In the following example the When-Custom-Item-Event trigger examines
the system variables to identify the contents of a parameter list sent by the
JavaBean. The JavaBean has sent date and time information to the form,
which is then displayed to the user using an alert.
Declare
EventName varchar2(20) := :system.custom_item_event;
EventValues ParamList;
Eventvalue Typenumber;
TempString varchar2(4000);
Begin
If EventName = ALARMFIRED' then
EventValues := get_parameter_list(
:system.custom_event_parameters);
get_parameter_attr(EventValues, 'ALARMTIME',
EventvalueType, TempString);
If Summit_Show_Alert(Alarm Call: '||TempString) =
alert_button1 then
set_custom_property(AlarmClock',
1,wakeuptime', 1000);
end if;
end if;
End;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-23
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Exploiting Oracle 8i Features

Oracle 8i Java features that can be exploited in


Oracle Forms Developer:
Java stored procedures
Enterprise JavaBeans
Business Components for Java

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-24 Oracle iDS Forms: Build Internet Applications II
Exploiting Oracle8i Features
......................................................................................................................................................

Exploiting Oracle8i Features


With Oracle8i you can create Java Stored procedures, develop Enterprise
JavaBeans (EJB), and build Business Components for Java (BC4J). These
features are available to Oracle Forms Developer applications, and they
allow you to develop features such as e-mail, and automated messaging.

Java Stored Procedures


Java stored procedures are Java classes which, like PL/SQL stored
procedures, are held on the Oracle8i database. In Oracle Forms Developer
applications, you are able to call Java stored procedure by writing a PL/SQL
wrapper.

Enterprise JavaBeans
Unlike JavaBeans, Enterprise JavaBeans (EJB) do not perform user
interface functions. EJB encapsulate and distribute Java backend logic
across many servers in order to manage data, transaction security, and
resources.

Business Components for Java


Business Components for Java (BC4J) is an application framework for
generating reusable business logic. You can encapsulate business rules in
Java component libraries, and reuse them by generating SQL-based views.
For example, with Oracle8i object views and XML (Extended Markup
Language), you can build message based e-commerce applications that
implement your business rules.

Developing Server Side Java


You can develop Java stored procedures, EJB, and BC4J by using Oracle
JDeveloper. You will require knowledge in Java programming.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-25
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

How to Create JavaBeans

JavaBeans in Oracle Forms Developer are:


Predefined Java class files

Reusable Java class files

Managed with a PL/SQL interface


(triggers and built-ins)

No Java programming is required

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-26 Oracle iDS Forms: Build Internet Applications II
How to Create JavaBeans
......................................................................................................................................................

How to Create JavaBeans


With Web-deployed form applications, you can reuse existing JavaBeans
supplied by Oracle or by a third-party developer. Java programming skills
are not required for implementing JavaBeans. In Oracle Forms Developer,
triggers and built-ins allow you to directly manipulate Java class files with
PL/SQL.

Creating Your Own JavaBeans


In order to create your own JavaBeans, you should use a Java development
tool such as Oracle JDeveloper or the Sun Java Developers Kit (JDK). You
can find examples of writing JavaBeans in Forms online Help and in
JDeveloper online Help. The JDK can be downloaded from
http://www.javasoft.com/.

Implementing a Development Environment for Testing JavaBeans


You should ensure that your JavaBean class files are placed in the
Oracle_Home/forms60/java directory or subdirectory. At run time
certain environment variables are used by Forms Server in order to obtain
Java classes. You should include:
The java bin directory within the PATH environment variable setting for
your User:
Oracle_Home/jdk/bin
The java directory within the CLASSPATH environment variable setting
for your User:
Oracle_Home/forms60/java

Technical Note
You should only deploy light-weight JavaBeans with your Web-deployed
forms applications; the light-weight JavaBean user interface (UI)
components are rendered completely and can be used independently of any
operating system. In contrast, heavy-weight JavaBeans rely on UI objects
provided by the client operating system. Oracle Forms Developer uses light-
weight JavaBeans to provide a common look and feel across different
operating systems.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-27
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

The Java Importer

The Java Importer enables you to:


Access components written in Java and
invoke them from Forms applications
Build middle-tier integration layers between
applications and technologies
XML, EJB, BC4J
Data sources other than Oracle
Nonstandard devices

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-28 Oracle iDS Forms: Build Internet Applications II
The Java Importer
......................................................................................................................................................

The Java Importer


While PL/SQL provides a powerful and productive development
environment, it is sometimes necessary to integrate Forms applications with
other external application services and providers. Usually, these external
applications are not written in PL/SQL so some form of integration
capability is required. Traditionally, the interfaces and libraries exposed by
external applications have been based on the C programming language, and
the ORA_FFI built-in package has proved more than sufficient.
With the increasing momentum of the Java movement within the
Information Technology industry, many applications are now providing
integration points in Java. Similarly, the number of standard Java libraries
for enterprise applications is continually growing.
Oracle Forms 6i Release 2 introduced a new feature, the Java Importer, to
facilitate the invocation of business logic written in Java from a Forms
application. With the Java Importer, you can automatically generate PL/SQL
packages and procedures that allow you to create and use Java objects
directly in your Forms applications.

Components of the Java Importer


The Java Importer enables a Forms application to call out to Java to make
use of code contained within compiled Java classes. The components of the
Java Importer make it possible to create PL/SQL packages for specified Java
classes within a Forms application, and to instantiate, use, and destroy the
Java object instances when the Forms application is run. These components
are:
Java Importer Tool, which allows you to select and specify which Java
classes you want to access in your application.
Java Importer Generator, which creates PL/SQL packages that provide
access to the specified Java class.
ORA_JAVA package, which provides a set of functions to assist you in
working with the selected Java packages.
Oracle Forms Services Java Native Interface (JNI) Bridge, which
handles low level interaction with the Java classes at runtime.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-29
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Invoking the Java Importer

Copyright Oracle Corporation, 2001. All rights reserved.

Using the Java Importer

4 5

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-30 Oracle iDS Forms: Build Internet Applications II
The Java Importer Tool
......................................................................................................................................................

The Java Importer Tool


You can invoke the Java Importer Tool from the Program Menu in Form
Builder. The dialog box that displays enables you to select or specify the
Java classes you wish to make use of in your Forms application. Once you
select the required Java classes, the Java Importer Tool calls the PL/SQL
Generator to create a PL/SQL package for each class selected. You can
invoke the tool multiple times during a development session as new Java
class access requirements are discovered; it is not necessary to identify all
the classes needed at one time.
The Java Importer Tools consists of the following sections:
1 Class Browser: The class browser lists all of the Java classes found on
the CLASSPATH, displaying the classes in a hierarchical tree format.
When a class is selected, the fully qualified name of the class is added to
the Import Classes List field.
2 Import Classes List: This field displays a list of fully qualified classes
that will be made accessible to the Forms application when you press the
Import button. In addition to populating this list by selecting the class in
the Class Browser, you can directly enter the fully qualified class names
of the Java classes you wish to access.
3 Message Display: Output from the PL/SQL Generator is directed to the
Message display. Progress of the PL/SQL generation phase is displayed
and upon completion, so are the names of the packages generated for
each Java class selected.
4 Import Button: The Import button starts the PL/SQL generation process
for each Java class specified in the Import Classes list.
5 Options Button: The Options button displays a dialog box that you use to
set the PL/SQL generation options. These options are described in the
documentation that accompanies the Java Importer.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-31
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Define Oracle LookandFeel and Java fonts
Incorporate Java in Web-deployed forms by:
Inserting Pluggable Java Components
Creating Bean Areas
Use Oracle 8i features by exploiting Java
stored procedures, EJB and BC4J
Use the Java Importer to build PL/SQL interfaces
to Java classes

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-32 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Customize the User Interface
Specifying Oracle look and feel
Specifying default Java fonts

Create JavaBean Areas


Inserting Pluggable Java Components
Creating Bean Areas
Communicating with JavaBeans

Exploit Oracle8i Features with Web-Deployed Forms


Java stored procedures
Enterprise JavaBeans
Business Components for Java

Use the Java Importer Tool


Utilize Java code contained in standard, compiled Java class libraries
from your Forms applications
Automate the generation of PL/SQL procedures and functions to
interface with a specified Java class

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-33
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Practice 12 Overview

This practice covers the following topics:


Providing an alternative UI for text items by
including PJC for
Changing the mouse cursor style
Displaying secure data as asterisks
Add a Bean Area to allow users to specify
hyperlinks of their choice

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
12-34 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 12
......................................................................................................................................................

Practice Overview: Lesson 12


This practice guides you through defining Pluggable Java Components, and
hosting Java Beans with a Bean Area.

Practice Contents
Provide an alternative UI for text items by including PJC
- Change the mouse cursor style
- Display secure data as asterisks.
Add a Java Bean to allow users to specify hyperlinks of their choice.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-35
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................

Practice 12
1 Provide an alternative user interface for your Web-deployed forms by
including Pluggable Java Components (PJCs).
a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb,
where XX is your student course code.
b Change the :EMP.SAL item so that values are displayed as asterisks
at run time. Use the PJC PasswordFieldPJC.class.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
c Change the :EMP.ENAME item so that the mouse cursor changes to
hand style whenever the cursor is moved over the item. Use the
PJC ModCursor.class.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
d Use the built-in SET_CUSTOM_PROPERTY in an appropriate
trigger, to specify the cursor style:
SET_CUSTOM_PROPERTY(Emp.Ename,1,
DOCURSOR,HAND);
e Save and compile your form. Deploy your form to the Web to test.

2 Create a JavaBean area in the Layout Editor to enable users to specify


hyperlinks of their choice.
a Create a new data block called LINK in your JAVAEMP form.
b Create a Bean Area called HYPERLINK1 in the new data block
and specify the class file HyperLinkWrapper.class.
c Create an appropriate trigger to identify the user-supplied URL from
the JavaBean, and to download his or her Web page. You can import
the code from the pr12_1.txt file.
d Create two text items, one called URL to accept a URL and one
called LABEL to accept a URL label. These will enable the user to
select a different URL. Set the maximum length for the URL text
item to 255.
e Create a push button with an appropriate trigger that will accept
values from the URL and LABEL text items, and pass them to the
JavaBean. You can import the code from the pr12_2.txt file.
f Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
12-36 Oracle iDS Forms: Build Internet Applications II
................................

Using Server Features


in Form Builder
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Use Oracle server functionalities in forms
Deal with server-side PL/SQL
Recognize which PL/SQL8 features are supported
in forms
Handle Oracle server errors
Perform DDL commands by using the
FORMS_DDL built in subprograms

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson covers the use of Oracle database server features in Form
Builder applications. You will learn about storing and calling PL/SQL code,
handling Oracle database server errors, and issuing DDL commands from
within forms.

Objectives
After completing this lesson, you should be able to do the following:
Use Oracle database server functionalities in forms
Deal with server-side PL/SQL
Recognize which PL/SQL8 features are supported in forms
Handle Oracle database server errors
Perform DDL commands by using the FORMS _DDL built-in
subprograms

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-3
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Using Oracle Database Server


Functionality in Forms

Useful Oracle server features:


Declarative constraints
Stored program units
Database triggers
DDL

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-4 Oracle iDS Forms: Build Internet Applications II
Using Oracle Database Server Functionality in Forms
......................................................................................................................................................

Using Oracle Database Server Functionality in Forms


The Oracle8i database offers several powerful features to implement
functionality in the Oracle database server. You can call that functionality in
your forms to handle possible errors.

Oracle Database Server Features Useful for Forms


The following useful features are available to application developers:
Declarative integrity constraints
Stored program units: procedures, functions, and packages
Built-in database packages
Database triggers
Database roles
DDL
SQL Optimizer; shared SQL
Locking
Sequences
Some of these features are discussed in more depth later in this lesson.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-5
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Dealing with PL/SQL Code

Where to store PL/SQL code:


On the Oracle server
In the attached PL/SQL libraries
In the form itself
Where to call PL/SQL code:
From database triggers
From forms triggers
Application partitioning

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-6 Oracle iDS Forms: Build Internet Applications II
Dealing with PL/SQL Code
......................................................................................................................................................

Dealing with PL/SQL Code


You can store and call your code in two places: the Oracle database server
and the Oracle Form Builder application.

Where to Store PL/SQL Code


To maintain your code, you should not store the code in more locations than
necessary. The places to store PL/SQL code, in order of preference, are as
follows:
1 The Oracle Database Server
2 Attached PL/SQL libraries
3 The form itself
Note: PL/SQL code cannot be stored in the Oracle database server if it
contains bind variables or calls to Forms built-ins.

Where to Call PL/SQL Code


PL/SQL code is eventually called from triggers. Also, for easier
maintenance, the places to call PL/SQL code, in order of preference, are as
follows:
1 Database triggers
2 Forms triggers
Note: Database triggers fire only at commit time. If you want to give
immediate feedback to the user, you must use forms triggers.

Application Partitioning
For enhanced performance, you may want to call or store PL/SQL code on
either the Oracle database server or the Oracle Form Builder application.
In Form Builder you can drag and drop PL/SQL program units between the
Oracle database server and the application. This is called application
partitioning. With Web-deployed forms it is also possible to place code on
the client by using JavaBeans. In this way, you can optimally divide
application code over the available resources.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-7
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

PL/SQL8 Support in Oracle Forms

Client-side program units cannot support


Oracle8i object-related functionality.
Stored program units can use PL/SQL8
features.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-8 Oracle iDS Forms: Build Internet Applications II
PL/SQL8 Support
......................................................................................................................................................

PL/SQL8 Support
Oracle Forms Developer uses PL/SQL8 in the Oracle database server and
the Oracle Form Builder application. However, Form Builder module
program units currently cannot support Oracle8i object-related functionality.
The Stored Program Unit editor has been extended in Oracle Forms
Developer to allow editing of the type body (methods) and type
specification (attributes) of Oracle8i user-defined data types.

Object Iron Packages


Object Iron is a set of database packages that helps you to access tables
containing instances of Oracle8i object types. The packages generate a
table-specific package, which you use to access data from the specified
table. After generation, the table-specific package appears under the Stored
Program Units node. It contains code that allows you to select, insert,
update, delete, and lock records in the specified table.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-9
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

PL/SQL8 Scalar Types

NCHAR and NVARCHAR2


SIGNTYPE
FLOAT
NATURALN
POSITIVEN
PLS_INTEGER

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-10 Oracle iDS Forms: Build Internet Applications II
PL/SQL8 Scalar Data Types
......................................................................................................................................................

PL/SQL8 Scalar Data Types


NCHAR stores fixed-length (blank-padded if necessary) NLS character
data. How the data is represented internally depends on the national
character set, which might use a fixed-width encoding such as
US7ASCII or a variable-width encoding such as JA16SJIS.
NVARCHAR2 stores variable-length NLS character data. How the data
is represented internally depends on the national character set, which
might use a fixed-width encoding such as WE8EBCDIC37C or a
variable-width encoding such as JA16DBCS.
SIGNTYPE lets you restrict an integer variable to the values -1, 0, and 1,
which is useful in programming tri-state logic.
FLOAT is a subtype of NUMBER. However, you cannot specify a scale
for FLOAT variables. You can specify only a binary precision.
NATURALN is like subtype NATURAL but prevents the assignment of
NULL.
POSITIVEN is like subtype POSITIVE but prevents the assignment of
NULL.
PLS_INTEGER stores signed integers. Its magnitude range is
-2147483647 ... 2147483647. PLS_INTEGER values require less
storage than NUMBER values. Also, PLS_INTEGER operations use
machine arithmetic, so they are faster than NUMBER and
BINARY_INTEGER operations, which use library arithmetic.
Besides the database character set, which is used for identifiers and source
code, PL/SQL8 now supports a second character set called the national
character set, which is used for NLS data. The PL/SQL data types NCHAR
and NVARCHAR2 allow you to store character strings formed from the
national character set.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-11
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Unsupported Client-Side
PL/SQL8 Features

Untrusted external procedures


Object types
Collection types
LOB types
Methods
Objects as stored procedure parameters

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-12 Oracle iDS Forms: Build Internet Applications II
Unsupported Oracle Forms Developer PL/SQL8 Features
......................................................................................................................................................

Unsupported Oracle Forms Developer PL/SQL8 Features


The following features are supported in database server PL/SQL8 but are
not currently supported in Form Builder module PL/SQL8:
Object types
Collection types
LOB types
Methods
Objects as stored procedure parameters
Because these features are supported in database server PL/SQL8, you can
use them by writing stored (server-side) subprograms, and calling the
subprograms from Oracle Forms Developer. However, the last restriction
requires that you decompose any object data types before returning them to
the client side.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-13
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Causes of Oracle Server Errors

Form Oracle Server

Base table block Declarative


constraint
Implicit DML

Database
Trigger/PU
trigger
Explicit DML
Stored
Stored PU call program unit

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-14 Oracle iDS Forms: Build Internet Applications II
Handling Errors Raised by the Oracle Database Server
......................................................................................................................................................

Handling Errors Raised by the Oracle Database Server


Oracle server errors can have different causes; for example, a declarative
constraint or a stored program unit. You should know how to handle errors
that may occur in different situations.

Causes of Oracle Server Errors


Cause Error Message
Declarative constraint Causes predefined error message
Database trigger Error message specified in RAISE_APPLICATION_ERROR
Stored program unit Error message specified in RAISE_APPLICATION_ERROR

Types of DML Statements


Declarative-constraint violations and firing of database triggers are in turn
caused by DML statements. For error-handling purposes, you must
distinguish between the following two types of DML statements:
Type Description
Implicit DML DML statements that are associated with base table blocks.
Implicit DML is also called base table DML. By default,
Forms constructs and issues these DML statements.
Explicit DML DML statements that a developer explicitly codes in triggers
or program units.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-15
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Trapping Server Errors

Form Oracle Server


Constraint
Base table block
Predefined
On-Error: message
DBMS_ERROR_CODE
DBMS_ERROR_TEXT
DB trigger
RAISE_
APPLICATION_
Explicit DML/PU call
ERROR
When Others: Stored PU
RAISE_
SQLCODE
APPLICATION_
SQLERRM ERROR

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-16 Oracle iDS Forms: Build Internet Applications II
Handling Errors Raised by the Oracle Database Server
......................................................................................................................................................

How to Trap Different Types of Oracle Database Server Errors


Type Error Handling
Implicit DML Use the Forms built-ins DBMS_ERROR_CODE and
DBMS_ERROR_TEXT in an On-Error trigger.
Explicit DML Use the PL/SQL functions SQLCODE and SQLERRM in a
WHEN OTHERS exception handler of the trigger or program
unit that issued the DML statements.
Stored program unit Use the PL/SQL functions SQLCODE and SQLERRM in a
WHEN OTHERS exception handler of the trigger or program
unit that called the stored program unit.

Note: Declarative-constraint violations and database triggers may be caused


by both implicit DML and explicit DML. Stored program units are always
called explicitly from a trigger or program unit.

Technical Note
The values of DBMS_ERROR_CODE and DBMS_ERROR_TEXT are the
same as what a user would see after selecting [Display Error]; the values are
not automatically reset following successful execution.
Appendix F Handling Server-Side Errors covers server-side error
handling in more detail.

FRM-Error Messages Caused by Implicit DML Errors


If an implicit DML statement causes an Oracle server error, Forms displays
one of these FRM-error messages:
FRM-40508: ORACLE error: unable to INSERT record.
FRM-40509: ORACLE error: unable to UPDATE record.
FRM-40510: ORACLE error: unable to DELETE record.
You can use ERROR_CODE to trap these errors in an On-Error trigger and
then use DBMS_ERROR_CODE and DBMS_ERROR_TEXT to determine
the ORA-error code and message.

FRM-Error Messages with Web-Deployed Forms


A generic FRM-999999 is the most common error displayed with Web
forms. You can obtain meaningful information from the JInitiator Control
Panel, or from the DOS window if you run the form from a Java
Appletviewer. For further information see Oracle 9iAS Forms Services:
Deploy Internet Applications.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-17
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Performing DDL with FORMS_DDL

Syntax: FORMS_DDL (statement);


Parameter (<=32K):PL/SQL block, DML
or DDL statement
Characteristics:
Unrestricted; valid in Enter Query mode
Statement must not contain bind-
variable references

Copyright Oracle Corporation, 2001. All rights reserved.

Performing DDL with FORMS_DDL

Characteristics:
Statement cannot return results directly
Use FORM_SUCCESS to check
success of statement
Hints:
Create SQL Query record group
instead of FORMS_DDL
Call stored program unit instead of
FORMS_DDL

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-18 Oracle iDS Forms: Build Internet Applications II
Performing DDL with FORMS_DDL
......................................................................................................................................................

Performing DDL with FORMS_DDL


Forms is intended primarily to perform DML operations. However, in some
cases you may find it useful to issue DDL statements from a form. You can
do this using the FORMS_DDL built-in function.

Syntax
FORMS_DDL(statement);

Description
FORMS_DDL issues dynamic SQL statements at run time, including
server-side PL/SQL and DDL.

Parameter
The specified statement can be any string expression up to 32K
representing a:
PL/SQL block
DML statement
DDL statement
Do not end the PL/SQL block with a slash or the DML or DDL statement
with a semicolon.

Characteristics
FORMS_DDL is an unrestricted procedure that is also valid in Enter Query
mode.
The specified statement must not contain bind-variable references.
However, you can concatenate the values of bind variables into the
specified string.
The statement executed using FORMS_DDL cannot return results to
Forms directly.
Use the FORM_SUCCESS built-in to check whether the statement
issued using FORMS_DDL executed correctly.
Note: Consider using a query record group with a SELECT statement or
calling a stored program unit, instead of executing FORMS_DDL.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-19
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Performing DDL with FORMS_DDL

Example: Create temporary table


FORMS_DDL (CREATE table temp (n_col number));
IF not FORM_SUCCESS THEN
MESSAGE (Table creation failed.);
RAISE form_trigger_failure;
END IF;

Example: Execute procedure with given name


FORMS_DDL
FORMS_DDL (BEGIN
(BEGIN ||
|| p_proc_name
p_proc_name ||;
||; END;
END; );
);
IF
IF not
not FORM_SUCCESS
FORM_SUCCESS THEN
THEN
handle_server_error(DBMS_ERROR_CODE,
handle_server_error(DBMS_ERROR_CODE,
DBMS_ERROR_TEXT);
DBMS_ERROR_TEXT);
END
END IF;
IF;

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-20 Oracle iDS Forms: Build Internet Applications II
Using FORMS_DDL
......................................................................................................................................................

Using FORMS_DDL
The following examples show how you can use the FORMS_DDL built-in
function.

Example
Create a temporary table at the start of a post.
Pre-commit trigger at form level:
BEGIN
FORMS_DDL(CREATE table temp(n_col number));
IF not FORM_SUCCESS THEN
MESSAGE (Table creation failed.);
RAISE form_trigger_failure;
END IF;
END;

Example
Execute a procedure with a given name. This is useful if you want to determine
dynamically which procedure should be executed in a certain situation.
PROCEDURE exec_proc (p_proc_name IN VARCHAR2)
IS
BEGIN
FORMS_DDL(BEGIN || p_proc_name ||; END;);
IF not FORMS_SUCCESS THEN
handle_server_error(DBMS_ERROR_CODE,DBMS_ERROR_TEXT);
END IF;
END;
Note: If the FORMS_DDL built-in fails, Forms sets the DBMS_ERROR_CODE
and DBMS_ERROR_TEXT built-ins. Therefore, you can handle Oracle server
errors using the HANDLE_SERVER_ERROR procedure discussed earlier.
Always test the SYSTEM.FORM_STATUS before calling the FORMS_DDL
built-in.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-21
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Identify Oracle server features useful
for Form Builder
Identify PL/SQL8 supported features
Write PL/SQL code to trap errors raised
by the Oracle server
Implicit DML
Explicit DML or stored program units
Perform DDL with FORMS_DDL

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-22 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Oracle Database Server Features Useful for Form Builder
Declarative integrity constraints
Stored program units
Database triggers
DDL

Dealing with PL/SQL Code


Store PL/SQL code in
- Oracle server
- Library
- Form
Call PL/SQL code from
- Database trigger
- Form trigger
Application partitioning

Handling Errors Raised by the Oracle Database Server


Causes: Declarative constraints, database triggers, stored program units
Trap implicit-DML errors by using DBMS_ERROR_CODE and
DBMS_ERROR_TEXT in an On-Error trigger
Trap explicit DML errors and stored program unit errors by using
SQLCODE and SQLERRM in a WHEN OTHERS exception handler

Performing DDL with FORMS_DDL


Parameter is a string (less than or equal to 32 K) representing a PL/SQL
block or DML or DDL statement.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-23
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Practice 13 Overview

This practice covers the following topics:


Handling errors caused by stored program units
Handling errors caused by declarative
constraint violation

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
13-24 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 13
......................................................................................................................................................

Practice Overview: Lesson 13


This practice guides you through handling Oracle server errors.

Practice Contents
Handle errors caused by stored program units.
Handle errors caused by declarative-constraint violations.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-25
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................

Practice 13
1 Create a stored procedure, and process error messages that it may
generate in the CUSTSERVER form.
a Open the CUSTSERVER form and save as CUSTSERVXX where
XX is your student course number. Copy the code in the
SELECT_CODE program unit and create a stored procedure called
SELECT_CUSTOMER. This procedure takes a user supplied value
from :CONTROL.NAME to check whether a customer name already
exists. Existing names will generate an error.
b Modify the When-Button-Pressed trigger for the CONTROL block
CHECK_CUSTOMER button, to trap any errors generated from the
stored procedure SELECT_CUSTOMER. If a customer already
exists, display a warning message to the user.
c Save and compile your form module; test.

2 Whenever the user attempts to save a new customer record with an


existing primary key, display an appropriate warning message.
a Run your CUSTSERVER form. Attempt to insert a record with an
existing primary key. Note the generated error message.
b Define an appropriate trigger to trap the generated error message,
and display the database constraint violation message and error code.
Ensure that any other generated messages will continue to be
displayed.
c Display all messages in an ALERT called errors.
d Save and compile your form module; test your form.

......................................................................................................................................................
13-26 Oracle iDS Forms: Build Internet Applications II
................................

Applying Timers
Lesson 14: Applying Timers
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Describe timers
Create a timer
Modify a timer
Delete a timer
Handle timer expiration

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson covers time-initiated processing; that is, processing that occurs
after a certain amount of time has elapsed. The mechanism you use to do this
is called a timer and it is created, modified, and deleted at run time.

Objectives
After completing this lesson, you should be able to do the following:
Describe timers
Create a timer
Modify a timer
Delete a timer
Handle timer expiration

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-3
Lesson 14: Applying Timers
......................................................................................................................................................

Timers

What is a timer?
Built-ins for timers:
FIND_TIMER
CREATE_TIMER
SET_TIMER
DELETE_TIMER
GET_APPLICATION_PROPERTY
(TIMER_NAME)

Copyright Oracle Corporation, 2001. All rights reserved.

Timers

When-Timer-Expired trigger
Using timers:
Poll database
Periodically query, commit, or rollback
Show About information at startup

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Timers are not suitable means of shutting down an application. It is the job
of the operating system to recognize idle processes and shut them down.

......................................................................................................................................................
14-4 Oracle iDS Forms: Build Internet Applications II
Timers
......................................................................................................................................................

Timers
Forms typically processes events that are user initiated. You can use timers
when you want Forms to initiate actions after a specific time period time.

What Is a Timer?
A timer is a programmatic construct similar to an internal alarm clock.
You can create, modify, or delete timers with built-ins. When you create or
modify a timer, you can specify the time period for the timer. Using a
trigger, you can specify actions to be performed at the end of that period.

Built-in Functions for Timers


Built-in Description
FIND_TIMER Returns the internal timer ID (of data type
TIMER) of a timer with the given name
CREATE_TIMER Creates a timer with a given name, a defined time
interval, and whether the timer should repeat on
expiration.
SET_TIMER Changes the settings for the given timer (You can
modify the time interval and the repeat behavior.)
DELETE_TIMER Deletes the given timer
GET_APPLICATION_PROPERTY The TIMER_NAME property returns the name of
the most recently expired timer.

When-Timer-Expired Trigger
This trigger fires when the specified time interval of the timer has elapsed.

Uses of Timers
Polling the database to check if a certain event has occurred
Performing an automatic query at regular intervals
Showing About this... information at form startup
Performing automatic commits or rollbacks after a specified idle time

Web Design Tip


You should restrict the frequency of timers in Web-deployed forms in order
to reduce a potential increase in network traffic. Replacing timers with
JavaBeans, which provide similar functionality, will benefit users as code
would be executed on the Web client without invoking network traffic.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-5
Lesson 14: Applying Timers
......................................................................................................................................................

Handling Timer Expiration


Timer A Timer B Start
created created
A
Timer A
expired When-Timer-Expired (A)
Query
issued
(R) Timer B
expired B

Timer A B,A
expired
Query
complete
(R) When-Timer-Expired (B)

When-Timer-Expired (A)

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-6 Oracle iDS Forms: Build Internet Applications II
Handling Timer Expiration
......................................................................................................................................................

Handling Timer Expiration


When a timer expires, the When-Timer-Expired trigger fires and executes
the desired actions. If you define more than one timer, you need to know
which timer expired and how expired timers are handled.

Timer Queue
When a timer expires, it is put in a queue of expired timers. Forms services
this timer queue on a first-in-first-out basis, but only while it is waiting for
user actions. After an expired timer is handled, it is removed from the queue.
Note: A repeating timer will not begin the next iteration while it is still in
the timer queue.

When-Timer-Expired Trigger
When using the When-Timer-Expired trigger remember that it:
Fires once for each timer that expires, but only after Form Builder has
completed any current processing of triggers and built-in functions
Fires after the specified time interval, rather than exactly on the moment
of expiration
Must be defined at the form level
Should include the GET_APPLICATION_PROPERTY built-in function
for you to find out which timer has expired

Example
Handle the expiration of two timers named HOUR_ALARM and
ABOUT_STARTUP.
DECLARE
v_timer_name VARCHAR2(30);
BEGIN
v_timer_name := GET_APPLICATION_PROPERTY(timer_name);
IF v_timer_name = HOUR_ALARM THEN
MESSAGE(One hour has passed again.);
ELSIF v_timer_name = ABOUT_STARTUP THEN
DELETE_TIMER(ABOUT_STARTUP);
END IF;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-7
Lesson 14: Applying Timers
......................................................................................................................................................

Creating a Timer

Syntax:
CREATE_TIMER
CREATE_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)

Example:
v_timer_id
v_timer_id := CREATE_TIMER ((hour_alarm,
:= CREATE_TIMER hour_alarm, cst_hour);
cst_hour);

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-8 Oracle iDS Forms: Build Internet Applications II
Creating a Timer
......................................................................................................................................................

Creating a Timer
You can create a timer by using the CREATE_TIMER built-in function,
which returns type TIMER.

Syntax

CREATE_TIMER(timer_name, milliseconds, iterate)

Parameter Description
timer_name The timer name
milliseconds The duration of the timer in milliseconds (Value must be
between 1 and 2147483648, approximately 25 days.)
iterate Specifies whether the timer should repeat upon expiration
(Valid values are REPEATthe defaultand NO_REPEAT.)

Example
At form startup, create a timer named HOUR_ALARM that expires every
hour.
DECLARE
cst_hour constant NUMBER(7) := 3600000;
--3600000 is one hour in milliseconds
v_timer_id TIMER;
BEGIN
v_timer_id := CREATE_TIMER(hour_alarm, cst_hour);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-9
Lesson 14: Applying Timers
......................................................................................................................................................

Modifying a Timer

Syntax:
SET_TIMER
SET_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)
SET_TIMER
SET_TIMER (timer_id, iterate))
(timer_id, milliseconds, iterate
milliseconds,

Example:

SET_TIMER ((hour_alarm,
SET_TIMER hour_alarm, no_change, no_repeat);
no_change, no_repeat );

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-10 Oracle iDS Forms: Build Internet Applications II
Modifying a Timer
......................................................................................................................................................

Modifying a Timer
You can modify a timer by using the SET_TIMER built-in procedure.

Syntax

SET_TIMER(timer_name, milliseconds, iterate)


SET_TIMER(timer_id, milliseconds, iterate)

Parameter Description
timer_name The timer name
timer_id The internal timer ID
millisec- The duration of the timer in milliseconds (Value must be between 1 and
onds 2147483648approximately 25 daysor must be NO_CHANGE.)
iterate Specifies whether the timer should repeat upon expiration (Valid
values are REPEAT (default), NO_REPEAT, and NO_CHANGE.)

Example
Set the repeat behavior of a timer named HOUR_ALARM without changing
the time interval. The trigger name depends on the situation.
BEGIN
SET_TIMER(hour_alarm, no_change, no_repeat);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-11
Lesson 14: Applying Timers
......................................................................................................................................................

Deleting a Timer

Syntax:
DELETE_TIMER
DELETE_TIMER (timer_name)
(timer_name)
DELETE_TIMER
DELETE_TIMER (timer_id)
(timer_id)

Example:
...
...
IF
IF NOT
NOT ID_NULL (FIND_TIMER ((hour_alarm
ID_NULL (FIND_TIMER hour_alarm))
)) THEN
THEN
DELETE_TIMER (hour_alarm);
DELETE_TIMER (hour_alarm);
END
END IF;
IF;
...
...

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-12 Oracle iDS Forms: Build Internet Applications II
Deleting a Timer
......................................................................................................................................................

Deleting a Timer
You can delete a timer by using the DELETE_TIMER built-in procedure.

Syntax

DELETE_TIMER(timer_name)
DELETE_TIMER(timer_id)

Parameter Description
timer_name The timer name
timer_id The internal timer ID

Note: Forms generates an error if you attempt to delete a nonexistent timer.

Example
Delete a timer named HOUR_ALARM after first checking that it exists. The
trigger name depends on the situation.
BEGIN
IF NOT ID_NULL(FIND_TIMER(hour_alarm)) THEN
DELETE_TIMER(hour_alarm);
END IF;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-13
Lesson 14: Applying Timers
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Create and modify a timer with built-in
functions
FIND_TIMER
CREATE_TIMER
SET_TIMER
DELETE_TIMER
GET_APPLICATION_PROPERTY
(TIMER_NAME)

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Handle timer expiration:


Timer queue
When-Timer-Expired trigger

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-14 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
A timer is a programmatic construct much like an internal alarm clock.

Built-ins for Timers


FIND_TIMER
CREATE_TIMER
SET_TIMER
DELETE_TIMER
GET_APPLICATION_PROPERTY(TIMER_NAME)

Uses of Timers
Polling the database to check if a certain event has occurred
Performing an automatic query at regular intervals
Showing About this... information at form startup
Performing an automatic commit or rollback after a specific amount of
idle time

Handling Timer Expiration


When a timer expires, it is put in a first-in-first-out timer queue.
The When-Timer-Expired trigger fires once for each timer that expires,
but only after Forms has completed any current processing.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-15
Lesson 14: Applying Timers
......................................................................................................................................................

Practice 14 Overview

This practice covers the following topic:


Periodically checking to see if there are
locked records and asking the user to
commit or rollback

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
14-16 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 14
......................................................................................................................................................

Practice Overview: Lesson 14


This practice guides you through the implementation of time-initiated
processing. You will use the appropriate timer built-ins and triggers to create
a timer and handle timer expiration.

Practice Contents
If table rows are locked, display an alert that asks the user to commit or roll
back changes after a set period of time.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-17
Lesson 14: Applying Timers
......................................................................................................................................................

Practice 14
1 Automatically ask the users if they want to commit after a set period of
time.
a Open your CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING. This will indicate at all times
whether rows of the S_CUSTOMER table are locked. The default
value is NULL. Append your new code to existing code.
c Create the On-Lock trigger to implement the default lock processing,
update the global variable, and create the timer. You can import the
code from the pr14_1.txt file.
d Display an alert if locks are still pending after a certain period of
time elapses. This alert should ask the user to commit or roll back the
changes. The alert, ASK_SAVE, already exists in your form. Define
an appropriate trigger. You can import the code from the
pr14_2.txt file.
e Create a Post-Database-Commit trigger to restore the NULL value to
the global variable. You can import the code from the pr14_3.txt
file.
f Create the On-Rollback trigger to implement the default rollback
processing and restore the NULL value to the global variable. You
can import the code from the pr14_4.txt file.
g Save and compile your form to test.

......................................................................................................................................................
14-18 Oracle iDS Forms: Build Internet Applications II
................................

Including Charts
and Reports
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Objectives

After completing this lesson, you should


be able to do the following:
Include charts in an application
Include reports in an application
Integrate other documents with
Web-deployed forms

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson, you will learn how to include charts and reports in your
application. You will also learn how to invoke additional document types
with Web-deployed forms.

Objectives
After completing this lesson, you should be able to do the following:
Include charts in an application
Include reports in an application
Integrate other documents with Web-deployed forms

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-3
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Including Charts by Using


the Chart Wizard

To invoke the Chart Wizard:


Use the
Chart tool
to drag a
chart area
onto
the canvas.

Select Tools>Chart Wizard

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-4 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................

Including Charts by Using the Chart Wizard


You are able to create charts and reports within Form Builder without
launching separate chart or reports engines.
The Chart Wizard leads you step-by-step through the process of creating a
chart from within a form or a report.
Once the chart is created, you can modify or enhance the chart by using
Graphics Builder.

Invoking the Chart Wizard


To invoke the Chart Wizard:
From the Layout Editor, use the Chart tool to drag a chart area onto the
canvas.
The New Chart Wizard dialog box appears. Click on the OK button to
accept the default option, Use the Chart Wizard.

Incorporating a Chart
The steps to create a chart are:
1 Specify a chart type and subtype.
2 Specify the data block that contains the data you want to assign to chart
columns.
3 Specify the data to appear on the Category (X) axis of the chart.
4 Specify the data to appear on the Value (Y) axis of the chart.
Follow the prompts on each page of the wizard to specify the settings for the
chart you want to create.

Re-entering the Chart Wizard


A powerful quality of the Chart Wizard is its ability to operate in reentrant
mode. This means you can use the Chart Wizard to modify an existing chart
created with the wizard.
To invoke the Chart Wizard in reentrant mode, select the chart object in the
Object Navigator, and then select Tools>Chart Wizard from the menu.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-5
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Including Charts by Using


the Chart Wizard

Chart
type

Copyright Oracle Corporation, 2001. All rights reserved.

Including Charts by Using


the Chart Wizard

Arrow indicates that


data from the block
is represented in the
chart.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-6 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................

Chart Type
Select the style of chart that you require. The picture on the left of the wizard
displays the relevant chart style.
The chart subtype options are context-sensitive; the number and style of
options change depending on the chart type that you choose. Select the chart
subtype that you require, and then click Next to continue to the next wizard
page.

Chart Type Description


Column Data is plotted as columns.
Bar Data is plotted as horizontal bars.
Pie Data is plotted as individual slices showing the relationship of parts to
the whole.
Line Data is plotted as points along a line.
Mixed Data is charted using multiple chart types, such as bar and line.

Data Source
The next step in the Chart Wizard is to select the block that contains the data
you want to represent in the chart. The data block you select determines the
data that is available for assignment to the Category and Value axes of your
chart.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-7
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Including Charts by Using


the Chart Wizard

Arrow points to the


Category axis.

Copyright Oracle Corporation, 2001. All rights reserved.

Including Charts by Using


the Chart Wizard

Arrow points to
the Value axis.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-8 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................

Category Axis
To use the Chart Wizard to map data to your charts Category (X) axis:
1 In the Available Fields list, select the field that you want to map to the
Category (X) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Category
Axis list.

Chart Type Description


Column, Line, Mixed chart Categories appear along the x-axis.
Bar chart Categories appear down the y-axis.
Pie chart Each category represents one segment of the pie.

Value Axis
To use the Chart Wizard to map data to your charts Value (Y) axis:
1 In the Available Fields list, select the field that you want to map to the
Value (Y) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Value
Axis list.

Chart Type Description


Column, Line, Mixed chart Values are represented by the height of the column against
the y-axis.
Bar chart Values are represented by the length of the column against
the x-axis.
Pie chart Values are represented by the size of each segment.

You must transfer at least one field from the Available Fields list to the
Category Value list before navigating to the next page.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-9
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Chart Item Properties

Filename
Execution Mode
Communication Mode
Data Source Data Block
Query Name
Data Source X Axis
Data Source Y Axis
Update on Query
Update on Commit

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-10 Oracle iDS Forms: Build Internet Applications II
Chart Item Properties
......................................................................................................................................................

Chart Item Properties


The chart item properties are the following:

Property Description
Filename Specifies the name of the file where the chart is stored
Execution Mode Specifies the execution version of Graphics Builder to use:
BATCH or RUNTIME
Communication Mode Specifies the communication mode to be used when calling
Graphics Builder: SYNCHRONOUS or ASYNCHRONOUS
Data Source Data Block Specifies the block that contains the data to represent in the chart
Query Name Specifies the name of the query used to display the chart
Data Source X Axis Specifies the item name used to map data to the chart Category
(X) axis
Data Source Y Axis Specifies the item name used to map data to the chart Value (Y)
axis
Update on Query Specifies that the chart is refreshed each time you perform a
query
Update on Commit Specifies that the chart is refreshed each time you perform a
commit

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-11
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Reporting Within Form Builder

Create report objects in Object Navigator


Run a report against a local or remote server
Base a report on a data block

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Passing data is applicable only if running against a local server.

......................................................................................................................................................
15-12 Oracle iDS Forms: Build Internet Applications II
Reporting Within Form Builder
......................................................................................................................................................

Reporting Within Form Builder


Oracle Forms Developer provides the ability to run a report against a local
or a remote server with considerable ease. A report object is available that
allows you to specify all the commands necessary for running a report.

Using the Report Wizard


Using the Report Wizard within Form Builder, you can:
Create a new report module based on one data block in your form
Create a new report module
Use an existing report module
Note: You can modify or enhance the report module by using Oracle
Reports Developer.

Creating a Report Object Based on a Data Block


The ability to base a report on a data block represents an efficient way of
passing data from a form module to a report. Select the Report node in the
Object Navigator.
1 Create a new report object by clicking the Create icon.
Form Builder displays the New Report dialog box.
2 Specify a filename and a block name.
3 Click OK.
Form Builder runs Report Builder and displays the Report Wizard.
4 Choose the report style that most closely resembles the report you want
to create.
5 Select the fields you would like to display in your report.
6 Select the fields you would like to total by choosing from a list of
possible calculations. (This step is optional.)
7 Enter labels and widths for your fields and totals. (This step is optional.)
8 Select a template for your report and then click the Finish button.
The Live Previewer is displayed.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-13
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Report Object Properties

Oracle Forms Developer


integration properties

Filename
Filename
Execution
Execution Mode
Mode
Communication
Communication Mode
Mode
Data
Data Source
Source Data
Data Block
Block
Query
Query Name
Name

Copyright Oracle Corporation, 2001. All rights reserved.

Report Object Properties

Report Destination Type


Report Destination Name
Report Destination Format
Report Server
Other Report Parameters

Reports properties

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-14 Oracle iDS Forms: Build Internet Applications II
Report Object Properties
......................................................................................................................................................

Report Object Properties


Oracle Forms Developer Integration Properties

Property Name Description


Filename Specifies the name of the report module to be executed by
Report Builder
Execution Mode Specifies the execution mode to be used when running Report
Builder (Valid numeric constants for this property are BATCH
and RUNTIME.)
Communication Mode SYNCHRONOUS specifies that control returns to Form
Builder only after Report Builder has been exited. The end user
cannot work in the form while Report Builder is running.
ASYNCHRONOUS specifies that control returns to the calling
application immediately, even if Report Builder has not
completed its display.
Data Source Data Block Block name used by Report Builder as data source
Query Name Query name used by Report Builder to retrieve the data (When
the report is based on data from a Form Builder block, the
query name property value is the block name.)

Reports Properties

Property Name Description


Report Destination Type Specifies the type of device that will receive the report
output
Report Destination Name Specifies the name of the file, printer, or Oracle Office
username (or distribution list) to which the report output will
be sent
Report Destination Format Specifies the format of your report (values are PDF, HTML,
HTMLCSS, XML) or the printer driver to be used when
DESTYPE is File.)
Report Server Name of the remote server on which the report is run
Other Report Parameters Declares additional parameters

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-15
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Working with Reports

Built-ins for interacting with reports:


RUN_REPORT_OBJECT
FIND_REPORT_OBJECT
GET_REPORT_OBJECT_PROPERTY
SET_REPORT_OBJECT_PROPERTY
CANCEL_REPORT_OBJECT
COPY_REPORT_OUTPUT
REPORT_OBJECT_STATUS
RUN_PRODUCT

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-16 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................

Working with Reports


When running a form you can control reports in the Report Server
dynamically by including the following built-ins in your trigger code:

Built-in Description
RUN_REPORT_OBJECT Runs a specified report on a specified server
FIND_REPORT_OBJECT Returns the internal ID of a report object
GET_REPORT_OBJECT_PROPERTY Dynamically gets report object properties at
run time
SET_REPORT_OBJECT_PROPERTY Dynamically sets report object properties at
run time
CANCEL_REPORT_OBJECT Cancels a report in the server queue
COPY_REPORT_OUTPUT Copies the report output back to the client
REPORT_OBJECT_STATUS Returns the current status of a report (The status
codes can be FINISHED, RUNNING,
CANCELED, OPENING_REPORT,
ENQUEUED, INVALID_JOB,
TERMINATED_WITH_ERROR, or
CRASHED.)
RUN_PRODUCT Invokes one of the supported Oracle tools
products and specifies the name of the module or
modules to be run

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-17
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Running a Report Against


a Local Server

DECLARE
v_rep VARCHAR2(100);
repid REPORT_OBJECT;
BEGIN
repid := FIND_REPORT_OBJECT(deptrpt);
v_rep := RUN_REPORT_OBJECT(repid);
end;

Copyright Oracle Corporation, 2001. All rights reserved.

Running a Report Against


a Remote Server

. . .
repid := FIND_REPORT_OBJECT(barcode);
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
IF rep_status = FINISHED THEN
COPY_REPORT_OBJECT_OUTPUT(v_rep,c:\local.pdf);
HOST(netscape c:\local.pdf);
END IF;
. . .

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-18 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................

Running a Report Against a Local Server


This example allows the user to run a report against a local server.
DECLARE
v_rep VARCHAR2(100);
repid REPORT_OBJECT;
rep_status VARCHAR2(20);
BEGIN
repid := FIND_REPORT_OBJECT(deptrpt);
v_rep := RUN_REPORT_OBJECT(repid);
end;

Running a Report Against a Remote Server


You can run a report on a remote server by naming the server in the Report
Object property, Report Server. RUN_REPORT_OBJECT returns a string
that uniquely identifies the report.
In this Client Server example, this string can be used to get the report status
and to copy the output.
....
v_rep := RUN_REPORT_OBJECT(repid);
IF REPORT_OBJECT_STATUS(v_rep) = FINISHED THEN
COPY_REPORT_OBJECT_OUTPUT(v_rep,c:\local.pdf);
HOST(netscape c:\local.pdf);
ELSE
MESSAGE(Error when running report.);
END IF;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-19
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Running a Report from


a Web-Deployed Form

Built-in for downloading reports:


WEB.SHOW_DOCUMENT
WEB.SHOW_DOCUMENT(url,
WEB.SHOW_DOCUMENT(url, target);
target);

Example
my_url
my_url :=
:= http://www.summit.com/repts/emps.pdf;
http://www.summit.com/repts/emps.pdf;
WEB.SHOW_DOCUMENT(my_url,
WEB.SHOW_DOCUMENT(my_url, _SELF);
_SELF);

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-20 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................

Running a Report from a Web-Deployed Form


When you call RUN_REPORT_OBJECT from a Web-deployed form, the
report is created on the Web server. You can specify a directory location for
report output, and a Web-deployable report format, with the following
Report Object properties:

Property Value
Report Destination Format File
Report Destination Name pathname / report filename
Report Destination Format HTML
HTMLCSS
PDF
XML

Viewing Report Output from a Web-Deployed Form


You can view report output with the built-in WEB.SHOW_DOCUMENT.
This is supplied with the Oracle Forms Developer WEB built-in package,
and you can only use it with Web-deployed forms. The built-in has two
parameters:
URL of the document to be downloaded. The document may, for
example, be a report, an image, a form that you wish to run on the Web,
or for another Web-site.
Target window or frame for displaying the report:
_BLANK specifies that the document can be downloaded in a new
HTML window.
_SELF specifies that the document is downloaded to the base HTML
page window or frame.
_TOP specifies that the document is downloaded to the base HTML
page, replacing any frames.
_PARENT specifies that the document is downloaded to the parent
window of the base HTML page.
In this example, WEB.SHOW_DOCUMENT is used to download the emps
report which has been formatted in pdf:
WEB.SHOW_DOCUMENT(http://www.summit.com/repts/emps.pdf,
_blank);

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-21
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Invoke the Chart Wizard
Exploit Report features in Form Builder
Create report objects
Run against local or remote server
Base reports on data blocks
Manage report objects with forms built-ins
GET_REPORT_OBJECT_PROPERTY
SET_REPORT_OBJECT_PROPERTY

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

Communicate with Report server


RUN_REPORT_OBJECT
FIND_REPORT_OBJECT
CANCEL_REPORT_OBJECT
REPORT_OBJECT _STATUS
COPY_REPORT_OUTPUT
Communicate with a Web server
WEB.SHOW_DOCUMENT

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-22 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
In this lesson, you should have learned how to include charts and reports in
your application. You should have learned how to invoke the Chart Wizard.

Reporting Features in Form Builder


Create report objects
Base reports on data blocks
Run against local or remote server
Run reports from Web-deployed forms

Interacting with Reports


RUN_REPORT_OBJECT
FIND_REPORT_OBJECT
CANCEL_REPORT_OBJECT
REPORT_OBJECT_STATUS
COPY_REPORT_OUTPUT
GET_REPORT_OBJECT_PROPERTY
SET_REPORT_OBJECT_PROPERTY
WEB.SHOW_DOCUMENT

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-23
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Practice 15 Overview

This practice covers the following topics:


Creating a chart to display the total orders
for each customer
Creating a report based on the
S_CUSTOMER block

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
15-24 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 15
......................................................................................................................................................

Practice Overview: Lesson 15


This practice guides you in creating and displaying charts and reports within
your forms application.

Practice Contents
Create a chart to display the total orders for each customer.
Create a report based on the S_CUSTOMER block.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-25
Lesson 15: Including Charts and Reports
......................................................................................................................................................

Practice 15
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the ORDCHART form module. Save as ORDCHARTXX
where XX is your student course number. This form module contains
a S_ORD block. Only one item from this block is visible: TITLE.
This item displays a title for your chart.
b In the Layout Editor, use the Chart tool to drag a chart area onto the
canvas. Select Use the Chart Wizard from the New Chart Object
dialog box. Do not specify a title for the chart.
c Select Column as chart type, Plain as chart subtype.
d Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
e Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
f Click the Finish button.
g Save and compile your form module. Deploy your form to the Web
to test. To display the chart, click in the Title item on the Chart tab.

2 Create a report object based on the S_CUSTOMER block. This report


displays a customer list using a tabular layout. Display only the ID,
NAME, COUNTRY, and REGION_ID fields.
a Open the CUSTREPT form. Save as CUSTREPXX where XX is your
student course number. Create a new report object.
This will invoke Report Builder. Within the Report Wizard:
Choose the report style Tabular.
Select the ID, NAME, COUNTRY, and REGION_ID fields.
Do not select fields to total.
Change labels and widths for your fields.
Select a template for your report.
b Save your report and exit Report Builder.
c Set the Execution Mode report object property to runtime and the
Report Destination Type report object property to screen. Rename
the report object to my_report.
d Create a button named CUST_REP_BUTTON in the control block.
Display this button on the CANVAS2 canvas.

......................................................................................................................................................
15-26 Oracle iDS Forms: Build Internet Applications II
Practice 15
......................................................................................................................................................

e Create a When-Button-Pressed trigger on the


CUST_REP_BUTTON button to run the report.
f Change the Query All Record property value to Yes for the
S_CUSTOMER block.
g Save and compile your form module. Deploy your form to the Web
to test. Query a customer record before calling the report.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-27
Lesson 15: Including Charts and Reports
......................................................................................................................................................

......................................................................................................................................................
15-28 Oracle iDS Forms: Build Internet Applications II
................................

Practice Solutions
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 1 Solutions
1 Create a new menu module.
a Using the following screenshot as a guideline, create a new menu
module called M_SUMMITXX where XX is your student course
number.

- Select the Menus node in the Object Navigator and click the
Create tool.
- Invoke the Menu Editor.
- This automatically creates the main menu.
- Change the name of the menu to MAIN_MENU.
- Rename the menu item New Item to File. Click New Item twice
to obtain the text cursor. Erase the old name. Enter the name
File.
- Create new menu items under File. Click File. Click the Create
Down tool. Change the name.

......................................................................................................................................................
A-2 Oracle iDS Forms: Build Internet Applications II
Practice 1 Solutions
......................................................................................................................................................

- Set the properties as follows:


- File Menu

Visible in
Menu Visible Horiz.
Item Command Menu Item in Menu Icon
Label Type Type Code Menu Toolbar Filename
Save Plain PL/SQL DO_KEY(CO Yes Yes Save
MMIT_FORM
);
Clear Plain PL/SQL DO_KEY( Yes Yes Abort
CLEAR_FORM
);
Null1 Separator Null Yes Yes
Exit Plain PL/SQL DO_KEY( Yes Yes Exit
EXIT_FORM
);
Null2 Separator Null No Yes

- Note the exact names of the Main Menu, and each of its menu
items. These will be needed in a later exercise.
- Create a new menu item to the right of File and rename it Edit.
- Click the File menu item.
- Click the Create Right tool.
- Name the new menu item Edit.
- Create new menu items under Edit. Click Edit. Click the Create
Down tool. Change the name.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-3
Appendix A: Practice Solutions
......................................................................................................................................................

- For each of the items, set the properties as follows:


Edit Menu

Visible in
Menu Magic Command Visible Horiz. Menu Icon
Label Item Type Item Type in Menu Toolbar Filename
Cut Magic Cut Null Yes Yes Cut
Copy Magic Copy Null Yes Yes Copy
Paste Magic Paste Null Yes Yes Paste
Null3 Separator Null No Yes

- Create a new menu item to the right of Edit and rename it Sort
By. Click Edit. Click the Create Right tool. Rename the new
menu item Sort By.
- Create three new menu items under Sort By. Click Sort By. Click
the Create Down tool. Change the name. Set additional
properties as follows:
Sort By Menu

Menu Menu Item


Item Radio Command
Menu Label Type Group Type Menu Item Code
Order Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
id ) ;
Customer Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
customer_id ) ;
Sales Rep Id Radio Order_By PL/SQL SET_BLOCK_PROPERTY(
s_ord, order_by,
sales_rep_id ) ;

......................................................................................................................................................
A-4 Oracle iDS Forms: Build Internet Applications II
Practice 1 Solutions
......................................................................................................................................................

- Create a new menu to the right of Sort By and rename it Query.


See the previous solution.
- Create two new menu items under Query. See the previous
solution. Set the properties as follows:
Query Menu

Visible in
Menu Command Horiz. Menu Icon
Label Item Type Type Menu Item Code Toolbar Filename
Enter Plain PL/SQL DO_KEY( Yes query
Query ENTER_QUERY);
eXe- Plain PL/SQL DO_KEY(EXECUT Yes execute
cute E_QUERY);
Query

b Save as M_SUMMIT and compile the menu module.


c Attach the menu module to the ORDERS form.
- Open the ORDERS form and set the Menu Module property to
M_SUMMIT for the form module.
d Save and compile the form module as ORDGXX where XX is your
student course number.
e Run and test your ORDERS form.
2 Add pop-up menus to the CUSTOMERS form.
a Open the CUSTOMERS form module. Save as CUSTGXX where
XX is your student course number.
b Copy the EDIT_MENU menu from your M_SUMMIT menu
module to your CUSTOMERS form. Attach this pop-up menu to the
Comments item.
- Select EDIT_MENU from the M_SUMMIT menu module.
- Click the right mouse button and select Copy.
- Select the Pop-up Menus node from the CUSTOMERS form
module.
- Click the right mouse button and select Paste.
- Select this pop-up menu in the Popup Menu property for the
Comments item.
c Save and compile the form module. Deploy your form to the Web to
test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-5
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 2 Solutions
1 Define a check menu item.
a Open your M_SUMMIT menu module and add a new menu item to
the Sort By menu; name it Display_Help.
- See previous solution.
- Set the properties as follows:

Menu Label Menu Item Type Command Type


Display Help Check PL/SQL

If Display_Help is selected, enable the ORDERS form toolbar HELP


b
button and set the toolbar canvas background color to grey.
If Display_Help is not selected, disable the ORDERS form toolbar
HELP button and set the toolbar canvas background color to red.
You can import the code from the pr2_1.txt file.
- Import the pr2_1.txt file.
If get_menu_item_property(
sort_by_menu.display_help,
checked) = TRUE then
set_canvas_property(toolbar,
visual_attribute,Toolnormal);
set_item_property(control.showhelp,
enabled, property_true);
Else
set_canvas_property(toolbar,
visual_attribute,Toolred);
set_item_property(control.showhelp,
enabled, property_false);
End If;
c Save and compile the menu module.
d Deploy your ORDERS form on the Web to test your menu.
2 Synchronize the menu module with the form.
a Write startup code for your M_SUMMIT menu module that
synchronizes the Display_Help menu item with the toolbar HELP
button. You can import the code from the pr2_2.txt file.

......................................................................................................................................................
A-6 Oracle iDS Forms: Build Internet Applications II
Practice 2 Solutions
......................................................................................................................................................

- Use the Startup Code menu module property to invoke the


PL/SQL Editor.
If Get_Item_Property(Control.Showhelp,
Enabled) = TRUE Then
Set_Menu_Item_Property(
Sort_By_Menu.Display_Help,
Checked, Property_True );
Else
Set_Menu_Item_Property(
Sort_By_Menu.Display_Help,
Checked, Property_False );
End If;

bSave and compile your menu module.


c Deploy your ORDERS form on the Web to test your menu.
3 Attach your M_SUMMIT menu to your CUSTOMERS form. The menu
item Sort_By is not relevant, and should not be visible to the user.
a Attach the menu module to your CUSTOMERS form.
- Open the CUSTOMERS form and set the Menu Module
property to M_SUMMIT for the form module.
b Modify the startup code of the M_SUMMIT menu module to hide
the SORT_BY menu when the CUSTOMERS form is opened. You
can import the code from the pr2_3.txt file to replace the
existing code. You may need to change the code to conform to the
exact names you gave to the Main Menu and its menu items. Also,
be sure the When-Button-Pressed trigger on the Orders button refers
to your Orders form.
- Import pr2_3.txt file to add the following code.
If :System.current_form = CUSTOMERSthen
set_menu_item_property(
main_menu.sort_by,
visible,
property_false);
End if;
c Save and compile the menu module.
d Deploy your CUSTOMERS form to the Web and test your
application. Execute a Query and click the Orders button to move to
the ORDERS form. Note that the Sort_By menu item is hidden
when the CUSTOMERS form is current, and is visible when the
ORDERS form is current.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-7
Appendix A: Practice Solutions
......................................................................................................................................................

4 With both the ORDERS and CUSTOMERS form modules, restore the default
menu, (DEFAULT&SMARTBAR).

......................................................................................................................................................
A-8 Oracle iDS Forms: Build Internet Applications II
Practice 3 Solutions
......................................................................................................................................................

Practice 3 Solutions
1 Maintain consistent functionality in your form module by using key
triggers. Define a key trigger in your ORDERS form to give users
consistent functionality whenever they exit the form, either using the
menu or when the CONTROL.EXIT_BUTTON button is pressed.
a Redefine [Exit Form] in your ORDERS form so that an alert
message is displayed to users before allowing them to exit the form.
b Amend the entry in Keyboard Help to Exit Orders for the key
trigger.
c Save and compile your form. Deploy your form to the Web to test.
- Create a form-level KEY-EXIT trigger. Copy the code from the
CONTROL.EXIT_BUTTON When-button-pressed trigger.
Set_Alert_Property(Exit_Alert,
ALERT_MESSAGE_TEXT,
Do you really want to leave the form?);
If show_alert(EXIT_ALERT) = alert_button1
then
exit_form;
End if;
- Change the keyboard help text in the KEY-EXIT trigger
property palette to Exit Orders, and set keyboard help display
to YES.
d Customize the Alert Text message in your key trigger and ensure that
it is displayed whenever the user exits the form using the
EXIT_BUTTON on the Control block.
- Replace the code in the EXIT_BUTTON When-Button -Pressed
trigger with: do_key(Exit_Form);
e Save and compile your form module. Deploy to the Web and test
your form.
If you have time
2 Disable [Enter query] in your CUSTOMERS form by creating an
appropriate key trigger. Replace [Enter Query] functionality with a call
to the customized query form CUSTQUERY. This form allows the user
to select a CUSTOMER ID, a CUSTOMER NAME, or a SALES REP
ID. The user selections are returned to your CUSTOMER form using
global variables.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-9
Appendix A: Practice Solutions
......................................................................................................................................................

a Add the following code to your key trigger:


call_form(custquery,no_hide);
execute_query;
- Create a form-level KEY-ENTQRY trigger. Add the code:
call_form(custquery,no_hide);
execute_query;
You may import the code from pr3_1.txt file.
b The CUSTQUERY form will return three values, held in global
variables. The contents should be passed to your CUSTOMERS
form to allow the user to execute a restricted query. Use the
following global variables:
:global.custid;
:global.custname;
:global.repid;
- Pass the values to the S_CUSTOMER block items in a
PRE_QUERY trigger:
:s_customer.id := :global.custid;
:s_customer.name := :global.custname;
:s_customer.sales_rep_id := :global.repid;
c Define the global variables in your CUSTOMERS form to ensure
that the user can perform unrestricted queries.
- Define the global variables in the When-New-Form-Instance
trigger:
default_value(,global.custid);
default_value(,global.custname);
default_value(,global.repid);
d Save and compile your CUSTOMER form. Deploy your form to the
Web to test.

......................................................................................................................................................
A-10 Oracle iDS Forms: Build Internet Applications II
Practice 4 Solutions
......................................................................................................................................................

Practice 4 Solutions
In this practice, you provide additional functionality in your forms by
defining mouse event triggers.
1 In your CUSTOMERS form, define a mouse event trigger on
S_CUSTOMER.COMMENTS that invokes the items editor when the
user double-clicks the item.
- When-Mouse-Doubleclick on s_customer.comments
Edit_TextItem;
2 In your ORDERS form change the mouse cursor symbol to busy while
the HELP canvas is displayed.
a Ensure that the default symbol is restored whenever the user hides
the HELP canvas.
- When-Button-Pressed on :control.showhelp
Set_Application_Property(cursor_style,help);
- When-Button-Pressed on :control.hidehelp
Set_Application_Property(cursor_style,normal);

b The user can close the HELP canvas without pressing the
HIDEHELP button, by navigating to an item in another block. How
can you ensure that the mouse cursor is always restored?
- Define a Post-Block trigger for the Control Data block.
Copy the code to restore the mouse cursor from your
:Control.hidehelp button When-Button-Pressed trigger.
c Save and compile your form modules. Deploy your forms to the Web
to test.You can call the ORDERS form from your CUSTOMERS
form.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-11
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 5 Solutions
1 Manipulate a multiple-window form.
aIn your ORDERS form module, ensure that the form is exited when a
user closes the orders window using the window system menu box.
An alert should be displayed to users asking them to confirm that
they wish to leave the application.
- Define a When-Window-Closed trigger at Form Level.
- Call the do_key built-in to execute [Exit_Form].
b If a user closes the Inventory window through the system menu box,
ensure that the form remains open with the cursor positioned in the
Orders window.
- In the When-Window-Closed trigger, use :system.event_window
to identify the current window:
If :system.event_window = WIN_ORDER then
do_key(exit_form);
else
go_block(s_ord);
end if;
c Whenever the user navigates between the order and inventory
windows, place the cursor in the first navigable item within the
current window.
- Define a When-Window-Activated trigger at form level. Use
:system.event_window to identify the current window, and use
the GO_BLOCK built in to enforce navigation within the
appropriate window.
d Save and compile your form. Deploy your form to the Web to test.
2 In your CUSTOMERS form module, define triggers to manage tab page
navigation.
a Using an appropriate trigger, disable the COMMENTS tab page
whenever the COMMENTS item contains no text.
b The trigger should fire whenever the user navigates to another
record.

......................................................................................................................................................
A-12 Oracle iDS Forms: Build Internet Applications II
Practice 5 Solutions
......................................................................................................................................................

- Modify the WHEN-NEW-RECORD-INSTANCE trigger. If the


item COMMENTS contains no data, use the built-in
SET_TAB_PAGE_PROPERTY to disable the COMMENTS
page. You may import the code from the pr5_1.txt file.
Declare
tb_pg_id TAB_PAGE;
Begin
tb_pg_id := FIND_TAB_PAGE(COMMENTS);
If :s_customer.comments is null then
set_tab_page_property(comments, enabled, property_false);
else
set_tab_page_property(comments, enabled, property_true);
end if;
:GLOBAL.custid := s_customer.id;
End;
c Whenever the user moves from one tab page to another, ensure that
the mouse cursor is placed in the first navigable field within the
page.
- Define a WHEN-TAB-PAGE-CHANGED trigger. Identify the
current tab page with the :system.tab_new_page system
variable. Use the GO_ITEM built-in to place the cursor in the
first navigable field.
Begin
if :SYSTEM.tab_new_page = ADDRESS
then GO_ITEM(s_customer.name);
else if :SYSTEM.tab_new_page = BILLING
then GO_ITEM(s_customer.credit_rating);
else GO_ITEM(s_customer.comments);
end if;
end if;
End;
d Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-13
Appendix A: Practice Solutions
......................................................................................................................................................

If you have time


3 How can you ensure that the user is returned to the first navigable item
within a tab page after navigating from the last navigable item?
- You can use the NEXT and PREVIOUS navigation item
properties.
4 How can you enforce item navigation dynamically within a tab page?
- Use GO_ITEM in a KEY-NEXT-ITEM or KEY-PREV-ITEM
trigger.

......................................................................................................................................................
A-14 Oracle iDS Forms: Build Internet Applications II
Practice 6 Solutions
......................................................................................................................................................

Practice 6 Solutions
1 Create a server-side package containing a procedure to return a REF
cursor.
a Create the Orders_pkg package specification; you can import the
code from the pr6_1.txt file.
b Create the Orders_pkg package body; you can import the code from
the pr6_2.txt file.
- Use the Stored Procedure editor in Forms and import the code
from the files.
c Examine the Orders_pkg package body to identify required
parameter values.
- A value of P,C or S is passed to the REF cursor to determine
which query is required. The REF cursor can query on either
products, customers, or sales reps.
2 Open the ORDERREFCURSOR.fmb file and save as ORDREFXX where
XX is your student course number. This form contains a control block,
called CHOOSE, and a group of option buttons which allows the user to
specify a parameter value to be passed to the REF cursor.
a Create a data block called SELECTION and base it on the REF
cursor procedure that you have just created.
- Use the Data Block Wizard and select Stored Procedures for
data block type.
- Specify full procedure name:
orders_pkg.query_proc
- Press the Refresh button. Available columns will be displayed.
- Select all as Database Items.
b Pass the name of the radio group as the value for the P_VIEW
argument: :choose.view_type.
- For the P_VIEW argument, set the value to
:choose.view_type
- Select Finish to end the wizard.
c In the layout editor, customize the canvas layout to ensure that
SELECTION items are displayed to the left of the option buttons
group.
d Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-15
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 7 Solutions
1 Create a data block based on a relational table with an object column.
aCreate a form called OBJ_COLXX where XX is your student course
number.
b Using the Data Block Wizard, create a block based on the
REL_EMP_TABLE_OBJCOL relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Expand the object column DEPT_ID and select the attributes ID and
NAME. Note the names that are given to the new items.
e In the Layout Wizard, select all available items for display. Change
the prompt for item DEPT_ID to Department ID and
DEPT_ID_NAME to Department Name. Use a form layout.
f Save, compile, and test your form.
If you have time
2 Create a block based on a relational table with an REF column, and
specify an LOV to populate the REF column.
a Create a form called REF_COLXX where XX is your student course
number.
b Create a block based on the REL_EMP_TABLE_REFCOL
relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Select the DEPT_ID attributes ID and NAME.
- Note that there are two items called DEPT_ID. The first is
expandable and has the term LOOKUP in parentheses after
the name. The second represents the REF column value itself.
The REF item is included automatically when the LOV is
created.)
e Create an LOV for the REF item DEPT_ID. Select the check box,
and select OO_DEPT_TABLE as the source for the LOV.
f In the Layout Wizard, select all available items for display.
- The REF item DEPT_ID is included in the list of items in the
Object Navigator but is not included in the list of available items
in the Layout Wizard.
g In the Object Navigator, identify the canvas with which item
DEPT_ID is associated.

......................................................................................................................................................
A-16 Oracle iDS Forms: Build Internet Applications II
Practice 7 Solutions
......................................................................................................................................................

- REF item values are normally not displayed, so by default the


REF item is assigned to the Null canvas.)
h In the Object Navigator, check that an LOV and associated record
group have been created.
i Save, compile, and test the form.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-17
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 8 Solutions
1 Open your ORDERS form and examine the properties of the relation
called S_ORD_S_ITEM.
a Note the deletion and coordination property values.
b Run the ORDERS form and test the way deletes are handled.
2 Implement a query coordination-type toggle.
a Add two check boxes to the control block with the following
properties:

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
Data Type CHAR CHAR
Initial Value Y Y
DataBase Item No No
Canvas TOOLBAR TOOLBAR

b Use the Layout Editor to position the check boxes appropriately in


the Toolbar canvas.
c Make sure that the first check box enables a user to toggle between
immediate coordination and deferred coordination. You can import
the code from the pr8_1.txt file.
- When-Checkbox-Changed on CONTROL.IMMEDIATE

......................................................................................................................................................
A-18 Oracle iDS Forms: Build Internet Applications II
Practice 8 Solutions
......................................................................................................................................................

If GET_RELATION_PROPERTY( s_ord_s_item,
DEFERRED_COORDINATION )
= FALSE Then
SET_RELATION_PROPERTY(s_ord_s_item,
DEFERRED_COORDINATION,
PROPERTY_TRUE);
SET_ITEM_PROPERTY(control.auto_query,
ENABLED,
PROPERTY_TRUE );
Else
SET_RELATION_PROPERTY(s_ord_s_item,
DEFERRED_COORDINATION,
PROPERTY_FALSE);
SET_ITEM_PROPERTY(control.auto_query,
ENABLED,
PROPERTY_FALSE );
End If;

d Make sure that the second check box enables a user to toggle
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 code from the
pr8_2.txt file.
- When-Checkbox-Changed on CONTROL.AUTO_QUERY
If GET_RELATION_PROPERTY(s_ord_s_item,
AUTOQUERY ) = FALSE Then
SET_RELATION_PROPERTY(s_ord_s_item,
AUTOQUERY, PROPERTY_TRUE );
Else
SET_RELATION_PROPERTY(s_ord_s_item,
AUTOQUERY, PROPERTY_FALSE);
End If;
e Save, compile, and test your form.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-19
Appendix A: Practice Solutions
......................................................................................................................................................

If you have time


3 Synchronize the check boxes at form startup.
a Open your ORDERS form module
b Create a procedure called SYNCHRONIZE_CHECKBOX. This
procedure synchronizes the IMMEDIATE and AUTO_QUERY
check boxes with the current default value. You can import the code
from the pr8_3.txt file.
- Procedure synchronize_checkbox IS
Begin
IF GET_RELATION_PROPERTY(s_ord_s_item',
DEFERRED_COORDINATION) = 'FALSE' Then
:control.immediate := Y;
SET_ITEM_PROPERTY(control.auto_query,
ENABLED, PROPERTY_FALSE);
Else
:control.immediate := N;
SET_ITEM_PROPERTY(control.auto_query,
ENABLED, PROPERTY_TRUE );
End If;
If GET_RELATION_PROPERTY(s_ord_s_item,
AUTOQUERY) = TRUE Then
:control.auto_query := Y;
Else
:control.auto_query := N;
End If;
End;
c Call this procedure from the When-New-Form-Instance trigger.
d Save, compile, and run the module.

......................................................................................................................................................
A-20 Oracle iDS Forms: Build Internet Applications II
Practice 9 Solutions
......................................................................................................................................................

Practice 9 Solutions
1 Create a multiple-form application by linking the CUSTOMERS and the
SALESREP forms. The SALESREP form provides a look up facility for
:S_CUSTOMER.SALES_REP_ID. It replaces the SALES_REP_LOV
list of values. Values are selected by mouse double click.
a Open SALESREP form and save as SALESREPXX where XX is
your student course number.
b In your CUSTOMERS form, modify the code in the
SALES_LOV_BUTTON When-Button-Pressed trigger to call the
SALESREP form.
c Ensure that the user can see, but not navigate to, your CUSTOMERS
form, while the SALESREP form is open.
d Update :S_CUSTOMER.SALES_REP_ID with the value selected
by the user in the SALESREP form. The selected Sales Rep ID is
returned in a GLOBAL variable called salesrepid. This variable
contains either a valid value or the text NOT SELECTED.
- Ensure that you call your SALESREP form which is identified
by the XX suffix.
CALL_FORM(SALESREP,no_hide);
If :global.salesrepid <> NOT SELECTED then
:S_CUSTOMER.SALES_REP_ID :=
:global.salesrepid
End if;
e Save and compile your form. Deploy your form to the Web to test.

2 Modify your multiple-form application to enable the SALESREP form


to be called in post mode only.
a Hide the CUSTOMERS form when the SALESREP form is
displayed.
- Change your When-Button-Pressed trigger code for the
SALES_LOV_BUTTON in the CUSTOMERS form:
CALL_FORM(SALESREP,hide);
If :global.salesrepid <> NOT 4SELECTED then
:S_CUSTOMER.SALES_REP_ID :=
:global.salesrepid
End if;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-21
Appendix A: Practice Solutions
......................................................................................................................................................

b In the SALESREP form, ensure that whenever the form has been
opened by CALL_FORM, that a [Commit Form] performs a POST.
- In a KEY-COMMIT trigger, define the following code:
If get_application_property(calling_form)
is not null then
post;
else
commit_form;
end if;
c Ensure that updates in SALESREP are not cleared when the user
exits the form.
- SALESREP form KEY-EXIT trigger
If get_application_property(calling_form)
is not null then
exit_form(do_commit,no_rollback);
else
exit_form;
end if;
d Save and compile your form. Deploy your form to the Web to test.

3 The SALESREP form displays a list of all employees; modify your


application to ensure that only Sales Representatives are displayed when
the form is called from CUSTOMERS.
a Create a parameter called EVERYONE in the SALESREP form.
Specify a default value of Y.
- Create a PARAMETER object, called EVERYONE in the
Object Navigator. Define as character type CHAR, with a
default value of Y.
b Ensure that the SALESREP form will perform an unrestricted query
whenever the parameter value = Y. If the parameter value = S, a
restricted query should be performed, selecting only Sales
Representatives.
- Create a PRE-QUERY trigger :
If :parameter.everyone = S then

......................................................................................................................................................
A-22 Oracle iDS Forms: Build Internet Applications II
Practice 9 Solutions
......................................................................................................................................................

:s_emp.title := Sales Representative;


end if;
c In the CUSTOMERS form, pass the parameter value S to the
SALESREP form.
Create a parameter list called EMPS. Add the EVERYONE
parameter to the parameter list. The type of this parameter is
TEXT_PARAMETER, and it is initialized with the value S.
Pass the parameter list to the SALESREP form by using the
CALL_FORM built-in.
You can import the code from the pr9_1.txt file. Be sure to change
the name of the module in the CALL_FORM built-in.
- Insert the following code for the SALES_LOV_BUTTON
When-Button-Pressed trigger:
Declare
vpid PARAMLIST;
Begin
If not Id_Null(
Get_Parameter_List( EMPS ) ) Then
Destroy_Parameter_List(EMPS);
End If;
vpid := Create_Parameter_List(EMPS);
Add_Parameter( vpid, everyone,
TEXT_PARAMETER,S);
Call_Form(SALESREP, Hide, No_Replace,
No_Query_Only,
No_Share_Library_Data, EMPS );
If :global.salesrepid = NOT SELECTED then
message(New Sales Rep not selected);
Else
:s_customer.sales_rep_id :=
:global.salesrepid;
End if;
End;
d Save and compile your forms. Deploy your form to the Web to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-23
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 10 Solutions
1 Create a dynamic list item populated from a design-time query record
group. The record group will hold region ID and the name of the
departments in the S_DEPT table.
a Open the Employees form. Save as EmpXX where XX is your student
course number. In the Object Navigator, create a record group named
DEPT_ID based on the query below:
SELECT name || in region ||
TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
UNION
SELECT none Name, 0 Id from dual
ORDER BY 1
b Convert the text item DEPT_ID into a list item, with a Poplist style.
Resize the list item in the Layout Editor.
c Create one element in the list item. Specify a label of Dummy and a
value of 0. Set the Mapping of Other Values property to 0.
d Create a procedure called POPULATE_DEPT_LIST. This procedure
will accept the list item name as an argument and populate the list
item dynamically at run time, using the design-time query record
group.
You can import the code from the pr10_1.txt file.
- Procedure Populate_Dept_List
p_list_item in varchar2) is
cst_rg_nom constant varchar2( 30 ) :=
Get_Item_Property(p_list_item,
Item_Name );
Begin
If Populate_Group( cst_rg_nom ) = 0 then
Populate_List( p_list_item, cst_rg_nom );
End If;
Copy(Get_List_Element_Value( p_list_item,1),
p_list_item);
End;

......................................................................................................................................................
A-24 Oracle iDS Forms: Build Internet Applications II
Practice 10 Solutions
......................................................................................................................................................

e Call the procedure each time a new record is created.


- When-Create-Record Trigger on the EMP Block:
Clear_List(S_Emp.Dept_Id);
POPULATE_DEPT_LIST(S_Emp.Dept_Id);
f Compile and save your form module. Test.

If you have time


2 Replace the design-time query record group in the Employee form with
a run-time query based record group.
a Delete the DEPT_ID record group and remove the code from the
When-Create-Record trigger.
b Create a procedure called CREATE_DEPT_LIST which will
dynamically create a record group called QDEPT, if it does not
already exist. The procedure will also populate the record group by
using the query:
SELECT name ||TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
UNION
SELECT none Name, TO_CHAR(0) Id
FROM dual
ORDER BY 1
c The procedure will also populate the list item S_EMP.DEPT_ID.
d You can import the procedure code from pr10_2.txt file.
- Procedure Create_Dept_List is
v_rg_id recordgroup;
v_error number;
rg_count number;
Begin
v_rg_id := find_group(qdept);
if id_null(v_rg_id) then
v_rg_id :=
create_group_from_query(qdept,

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-25
Appendix A: Practice Solutions
......................................................................................................................................................

Select name||to_char(region_id),
to_char(id)
from s_dept
UNION
Select none Name, to_char(0) Id
from dual
order by 1');
end if;
v_error := populate_group(v_rg_id);
populate_list('s_emp.dept_id',v_rg_id);
Copy(Get_List_Element_Value('s_emp.dept_id',
1), 's_emp.dept_id');
End;
e Call the procedure from the When-Create-Record trigger.
- When-Create-Record Trigger on the S_EMP Block:
Create_Dept_List;
f Compile and save your form module. Test.

......................................................................................................................................................
A-26 Oracle iDS Forms: Build Internet Applications II
Practice 11 Solutions
......................................................................................................................................................

Practice 11 Solutions
1 Create a picklist by using the picklist class. This picklist enables the end
user to select order items from a product list, and to place selections in a
second list.
a Create a new form module, called PICKXX where XX is your student
course number. Open the Form_Builder_II.olb object
library. This library contains form objects and code for the picklist.
Copy the PICKLIST_BASIC object group to your form module.
Copy the PICKLIST object group into your new form module.
b Ensure the CONTROL block is the last defined data block in the
Object Navigator.
c Attach the picklist.pll library. This contains the functions
and procedures required for creating the picklist.
d Define a When-New-Form-Instance trigger which will create and
populate the picklist. You can import the code from the
pr11_1.txt file.
- Declare
dummy number;
Begin
Default_Value(Y,Global.where_cls);
pick_list.create_picklist;
if :GLOBAL.where_cls = Y then
dummy := pick_list.populate_picklist_with_query(
pick_list.list_in, select name, id from
s_product order by 1);
else
dummy := pick_list.populate_picklist_with_query(
pick_list.list_in, select name, id from
s_product where || :GLOBAL.where_cls || order
by 1);
end if;
pick_list.set_picklist_selection(
pick_list.list_in,1,null);
pick_list.display_picklist(pick_list.list_in);
pick_list.display_picklist(pick_list.list_out);
End;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-27
Appendix A: Practice Solutions
......................................................................................................................................................

Create the picklist with the picklist.Create_Picklist procedure.


Call function pick_list.Populate_Picklist_With_Query to populate
the List_in object. You must define a query that returns the ID, name
and suggested prices from the S_PRODUCT table.
Call pick_list.Set_Picklist_Selection procedure to select the first
element in the list.
Display both lists by using the pick_list.Display_Picklist procedure.
Exclude from the query any products already in the current S_ITEM
block. You should use the global variable :GLOBAL.where_cls.
e Save and compile your form. Deploy your form to the Web.
f In your ORDERS form, modify the When-Button-Pressed trigger for
the CONTROL.PRODUCT_LOV_BUTTON so that it calls your
new form module.
- Call_Form(pickXX, No_Hide );
g Save and compile your form. Deploy your form to the Web to test.

If you have time


2 In the ORDERS form, add a calendar on the S_ORD.DATE_ORDERED
item and S_ORD.DATE_SHIPPED item.
a From the calendar page of the Form_Builder_II.olb object
library, copy the calendar object group.
b Attach the PL/SQL library calendar.pll, which contains the
Date_LOV package, to your module.
c Create a Key-Listval trigger on the date ordered item. Add code to
display the calendar using the Date_LOV package. You can import
the code from the pr11_2.txt file.
- date_lov.get_date( sysdate, -- initial date
s_ord.date_ordered, -- return block.item
240, -- window x position
60, -- window y position
Order Date, -- window title
OK, -- ok button label
Cancel, -- cancel button label
TRUE, -- highlight weekend days
FALSE, -- autoconfirm selection
FALSE); -- autoskip after selection

......................................................................................................................................................
A-28 Oracle iDS Forms: Build Internet Applications II
Practice 11 Solutions
......................................................................................................................................................

d Create a Key-Listval trigger on the date shipped item. Add code to


display the calendar using the Date_LOV package.You can import
the code from the pr11_3.txt file.
- date_lov.get_date( sysdate + 7, -- initial date
s_ord.date_shipped, -- return block.item
240, -- window x position
60, -- window y position
Shipped Date, -- window title
OK, -- ok button label
Cancel, -- cancel button label
TRUE, -- highlight weekend days
FALSE, -- autoconfirm selection
FALSE); -- autoskip after selection
e Save and compile your form module. Deploy your form to the Web
to test.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-29
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 12 Solutions
1 Provide an alternative user interface for your Web-deployed forms by
including Pluggable Java Components (PJCs).
a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb,
where XX is your student course code.
b Change the :EMP.SAL item so that values are displayed as asterisks
at run time. Use the PJC PasswordFieldPJC.class.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
- In the :EMP.SAL Property Palette, set the implementation class
to oracle.forms.demos.PasswordFieldPJC.
c Change the :EMP.ENAME item so that the mouse cursor changes to
hand style whenever the cursor is moved over the item. Use the
PJC ModCursor.class.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
- In the :EMP.ENAME property palette, set the implementation
class to oracle.forms.demos.ModCursor.

d Use the built-in SET_CUSTOM_PROPERTY in an appropriate


trigger, to specify the cursor style:
SET_CUSTOM_PROPERTY(Emp.Ename,1,
DOCURSOR,HAND);
- In the When-New-Form-Instance trigger, include:
SET_CUSTOM_PROPERTY(EMP.ENAME,1,
DOCURSOR,HAND);
e Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
A-30 Oracle iDS Forms: Build Internet Applications II
Practice 12 Solutions
......................................................................................................................................................

2 Create a JavaBean area in the Layout Editor to enable users to specify


hyperlinks of their choice.
a Create a new data block called LINK in your JAVAEMP form.
b Create a Bean Area called HYPERLINK1 in the new data block
and specify the class file HyperLinkWrapper.class.
- Create a new data block called LINK, and define a Bean Area
in the Layout editor. In the Bean Area property palette, set the
Implementation class to
oracle.forms.demos.HyperLinkWrapper.

c Create an appropriate trigger to identify the user-supplied URL from


the JavaBean, and to download his or her Web page. You can import
the code from the pr12_1.txt file.
- Attach the When-Custom-Item-Event trigger to the Bean Area
and include the following code:
Declare
eventName varchar2(20) :=
:system.custom_item_event;
eventValues ParamList;
eventValueType number;
url varchar2(255);
Begin
eventValues := get_parameter_list(
:system.custom_item_event_parameters);
if(eventName = LINKEVENT) then
get_parameter_attr(eventValues,
LINKEVENTDATA,
eventValueType,url);
web.show_document(url,_blank);
end if;
End;

d Create two text items, one called URL to accept a URL and one
called LABEL to accept a URL label. These will enable the user to
select a different URL. Set the maximum length for the URL text
item to 255.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-31
Appendix A: Practice Solutions
......................................................................................................................................................

- Create two text items, URL and LABEL, in the Data Block
LINK.

e Create a push button with an appropriate trigger that will accept


values from the URL and LABEL text items, and pass them to the
JavaBean. You can import the code from the pr12_2.txt file.
Create a push button and add the following code to the
When-Button-Pressed trigger:
If(:URL is not null) and
(:LABEL is not null) then
set_custom_property(HYPERLINK1,1,
LINKLABEL, :label);
set_custom_property(HYPERLINK1,1,
LINKURL, :URL);
set_custom_property(HYPERLINK1,1,
ACTIVECOLOR,
#8BFC5E);
set_custom_property(HYPERLINK1,1,
VISITEDCOLOR,
#DF37E1);
set_custom_property(HYPERLINK1,1,
NORMALCOLOR,
#F3F4AA);
else
set_custom_property(HYPERLINK1,1,
LINKLABEL,
Oracle Technet!);
set_custom_property(HYPERLINK1,1,
LINKURL,
http://technet.oracle.com);
end if;

f Save and compile your form. Deploy your form to the Web to test.

......................................................................................................................................................
A-32 Oracle iDS Forms: Build Internet Applications II
Practice 13 Solutions
......................................................................................................................................................

Practice 13 Solutions
1 Create a stored procedure, and process error messages that may be
generated in the CUSTSERVER form.
a Open the CUSTSERVER form and save as CUSTSERVXX where
XX is your student course number. Copy the code in the
SELECT_CODE program unit and create a stored procedure called
SELECT_CUSTOMER. This procedure takes a user supplied value
from :CONTROL.NAME to check whether a customer name already
exists. Existing names will generate an error.
b Modify the When-Button-Pressed trigger for the CONTROL block
CHECK_CUSTOMER button, to trap any errors generated from the
stored procedure SELECT_CUSTOMER. If a customer already
exists, display a warning message to the user.
- Add the following code:
exception
when others then
message(sqlcode|| ||sqlerrm);
raise form_trigger_failure;
c Save and compile your form module; test.

2 Whenever the user attempts to save a new customer record with an


existing primary key, display an appropriate warning message.
a Run your CUSTSERVER form. Attempt to insert a record with an
existing primary key. Note the generated error message.
- Form - 40508 error code is generated
b Define an appropriate trigger to trap the generated error message,
and display the database constraint violation message and error code.
Ensure that any other generated messages will continue to be
displayed.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-33
Appendix A: Practice Solutions
......................................................................................................................................................

c Display all messages in an ALERT called errors.


- Define a form level ON-ERROR trigger and include the
following code:
Declare
nums number;
errmess varchar2(200);
v_constraint_name varchar2(255);
begin
if error_code = 40508 then
errmess := Constraint violation
||dbms_error_text||
(||dbms_error_code||);
else
errmess := error_type ||
to_char( -error_code ) ||
: || error_text;
end if;
set_alert_property(errors,
alert_message_text,
errmess);
nums := show_alert(errors);
End;
d Save and compile your form module; test your form.

......................................................................................................................................................
A-34 Oracle iDS Forms: Build Internet Applications II
Practice 14 Solutions
......................................................................................................................................................

Practice 14 Solutions
1 Automatically ask the users if they want to commit after a set period of
time.
a Open your CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING. This will indicate at all times
whether rows of the S_CUSTOMER table are locked.
The default value is NULL. Append your new code to existing code.
- When-New-Form-Instance Trigger at Form Level
...
Default_Value( NULL, GLOBAL.locks_pending);

c Create the On-Lock trigger to implement the default lock processing,


update the global variable, and create the timer. You can import the
code from the pr14_1.txt file.
- On-Lock Trigger at Form Level
Declare
timer_id TIMER;
Begin
LOCK_RECORD;
If FORM_SUCCESS then
If :GLOBAL.locks_pending IS NULL then
:GLOBAL.locks_pending := TRUE;
timer_id := CREATE_TIMER( locks,
5000 );
End If;
Else
Raise Form_Trigger_Failure;
End If;
End;
d Display an alert if locks are still pending after a certain period of
time elapses. This alert should ask the user to commit or roll back the
changes. The alert, ASK_SAVE, already exists in your form. Define
an appropriate trigger. You can import the code from the
pr14_2.txt file.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-35
Appendix A: Practice Solutions
......................................................................................................................................................

- When-Timer-Expired Trigger at Form Level


If GET_APPLICATION_PROPERTY( TIMER_NAME ) =
LOCKS then
If :GLOBAL.locks_pending is not NULL then
If SHOW_ALERT( ask_save ) =
ALERT_BUTTON1 then
COMMIT_FORM;
Else
CLEAR_FORM( no_validate );
End If;
If :SYSTEM.FORM_STATUS <> CHANGED then
DELETE_TIMER(locks);
End If;
End If;
End If;

e Create a Post-Database-Commit trigger to restore the NULL value to


the global variable. You can import the code from the pr14_3.txt
file.
- Post-Database-Commit Trigger at Form Level
:GLOBAL.locks_pending := NULL;
f Create the On-Rollback trigger to implement the default rollback
processing and restore the NULL value to the global variable. You
can import the code from the pr14_4.txt file.
- On-Rollback Trigger at Form Level
Issue_Rollback(
Get_Application_Property( savepoint_name ) );
If Form_Success then
:Global.locks_pending := NULL;
End If;
g Save and compile your form to test.

......................................................................................................................................................
A-36 Oracle iDS Forms: Build Internet Applications II
Practice 15 Solutions
......................................................................................................................................................

Practice 15 Solutions
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the ORDCHART form module. Save as ORDCHARTXX
where XX is your student course number. This form module contains
a S_ORD block. Only one item from this block is visible: TITLE.
This item displays a title for your chart.
b In the Layout Editor, use the Chart tool to drag a chart area onto the
canvas. Select Use the Chart Wizard from the New Chart Object
dialog box. Do not specify a title for the chart.
c Select Column as chart type, Plain as chart subtype.
d Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
e Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
f Click the Finish button.
g Save and compile your form module. Deploy your form to the Web
to test. To display the chart, click in the Title item on the Chart tab.

2 Create a report object based on the S_CUSTOMER block. This report


displays a customer list using a tabular layout. Display only the ID,
NAME, COUNTRY, and REGION_ID fields.
a Open the CUSTREPT form. Save as CUSTREPXX where XX is your
student course number.Create a new report object.
- Select the Reports node in the Object Navigator.
- Click the Create icon.
- Specify a filename of myreport and a block name.
Click OK.
b This will invoke Report Builder. Within the Report Wizard:
Choose the report style Tabular.
Select the ID, NAME, COUNTRY, and REGION_ID fields.
Do not select fields to total.
Change labels and widths for your fields.
Select a template for your report.
c Save your report and exit Report Builder.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-37
Appendix A: Practice Solutions
......................................................................................................................................................

d Set the Execution Mode report object property to runtime and the
Report Destination Type report object property to screen. Rename
the report object to my_report.
- Display the Property Palette for the report object.
- Select Execution Mode and change the value to RUNTIME.
- Select Report Destination Type and change the value to
SCREEN.
e Create a button named CUST_REP_BUTTON in the control block.
Display this button on the CANVAS2 canvas.
f Create a When-Button-Pressed trigger on the
CUST_REP_BUTTON button to run the report.
- DECLARE
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
BEGIN
repid := FIND_REPORT_OBJECT(my_report);
v_rep := RUN_REPORT_OBJECT(repid);
END;
g Change the Query All Record property value to Yes for the
S_CUSTOMER block.
h Save and compile your form module. Deploy your form to the Web
to test. Query a customer record before calling the report.

......................................................................................................................................................
A-38 Oracle iDS Forms: Build Internet Applications II
................................

Table Descriptions
and Data
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

Summit Sporting Goods Database Diagram

ORD_ID
ID
S_ITEM S_ORD

PRODUCT_ID CUSTOMER_ID
SALES_REP_ID

S_INVENTORY
*
PRODUCT_ID
ID

ID ID
S_CUSTOMER
S_PRODUCT SALES_REP_ID

IMAGE_ID

ID ID ID

S_IMAGE S_EMP
DEPT_ID

ID

S_DEPT

*Unique occurrences are identified by PRODUCT_ID and


WAREHOUSE_ID.

......................................................................................................................................................
B-2 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Description
.....................................................................................................................................................

S_CUSTOMER Description
Column Name Null? Datatype
-------------- --------- ------------- -----------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)
PHONE VARCHAR2(25)
ADDRESS VARCHAR2(400)
CITY VARCHAR2(30)
STATE VARCHAR2(20)
COUNTRY VARCHAR2(30)
ZIP_CODE VARCHAR2(75)
CREDIT_RATING VARCHAR2(9)
SALES_REP_ID NUMBER(7)
REGION_ID NUMBER(7)
COMMENTS VARCHAR2(255)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-3
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_CUSTOMER Data

SQL> SELECT * FROM s_customer;

Id Name Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
201 Unisports 55-2066101 72 Via Bahia
Sao Paolo Brazil
Excellent 12 2
Customer usually orders large amounts and has a high order
total. This is okay as long as the credit rating remains
excellent.

202 Oj Athletics 6741 Takashi Blvd. 81-20101


Osaka Japan
Poor 14 4
Customer should always pay by cash until his credit rating
improves.

203 Delhi Sports 91-10351 11368 Chanakya


New Delhi India
Good 14 4
Customer specializes in baseball equipment and is the largest
retailer in India.

......................................................................................................................................................
B-4 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Data
.....................................................................................................................................................

Id Name Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
204 Womansport 1-206-104-0103 281 King Street
Seattle Washington USA
98101 EXCELLENT 11 1

205 Kams Sporting Goods 852-3692888 15 Henessey Road


Hong Kong EXCELLENT 15 4

206 Sportique 172 Rue de Rivoli 33-2257201


Cannes France
EXCELLENT 15 5
Customer specializes in soccer. Likes to order accessories in
bright colors.

207 Sweet Rock Sports 234-603620 6 Saint Antoine


Lagos Nigeria

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-5
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

Id Name Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
208 Muench Sports 49-527454 435 Gruenestrasse
Stuttgart Germany
GOOD 15 5
Customer usually pays small orders by cash and large orders on
credit.

209 Beisbol Si! 809-352689 789 Playa Del Mar


San Pedro de Macons Dominican Republic
EXCELLENT 11 1

210 Futbol Sonora 52-404562 3 Via Saguaro


Nogales
EXCELLENT 12 2
Customer is difficult to reach by phone. Try mail.

211 Kuhns Sports 42-111292 7 Modrany


Prague Czechoslovakia
EXCELLENT 15 5

......................................................................................................................................................
B-6 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Data
.....................................................................................................................................................

Id Name Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
212 Hamada Sport 20-1209211 57A Corniche
Alexandria Egypt
EXCELLENT 13 3
Customer orders sea and water equipment.

213 Big Johns Sports 1-415-555-6281 4783 18th Street


Emporium
San Francisco CA USA
94117 EXCELLENT 11 1
Customer has a dependable credit record.

214 Ojibway Retail 1-716-555-7171 415 Main Street


Buffalo NY USA
14202 POOR 11 1

215 Sporta Russia 7-3892456 6000 Yekatamina


St. Petersburg Russia
POOR 15 5
This customer is very friendly, but has difficulty paying bills.
Insist upon cash.

Note: This display has been formatted.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-7
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_DEPT Description and Data


Column Name Null? Datatype
---------------------- ------------- --------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(25)
REGION_ID NUMBER(7)

SQL> SELECT * FROM s_dept;

ID NAME REGION_ID
------ ---------------- -----------------
10 Finance 1
31 Sales 1
32 Sales 2
33 Sales 3
34 Sales 4
35 Sales 5
41 Operations 1
42 Operations 2
43 Operations 3
44 Operations 4
45 Operations 5
50 Administration 1

12 rows selected.

......................................................................................................................................................
B-8 Oracle iDS Forms: Build Internet Applications II
S_EMP Description
.....................................................................................................................................................

S_EMP Description
Column Name Null? Datatype
------------------------ -------------- --------------
ID NOT NULL NUMBER(7)
LAST_NAME NOT NULL VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
COMMENT VARCHAR2(255)
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID NUMBER(7)
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-9
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_EMP Data

SQL> SELECT * FROM s_emp;

ID LAST_NAME FIRST_NAME USERID START_DAT


---- ----------------- ---------------- -------- ---------
COMMENTS
--------------------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- ---------------------------- ------- ------
COMMISSION_PCT
---------------
1 Velasquez Carmen cvelasqu 03-MAR-90
President 50 2500
2 Ngao LaDoris lngao 08-MAR-90
1 VP, Operations 41 1450

3 Nagayama Midori mnagayam 17-JUN-91


1 VP, Sales 31 1400

4 Quick-To-See Mark mquickto 07-APR-90


1 VP, Finance 10 1450

5 Ropeburn Audry aropebur 04-MAR-90


1 VP, Administration 50 1550

6 Urguhart Molly murguhar 18-JAN-91


2 Warehouse Manager 41 1200

7 Menchu Roberta rmenchu 14-MAY-90


2 Warehouse Manager 42 1250
8 Biri Ben bbiri 07-APR-90
2 Warehouse Manager 43 1100

9 Catchpole Antoinette acatchpo 09-FEB-92


2 Warehouse Manager 44 1300

......................................................................................................................................................
B-10 Oracle iDS Forms: Build Internet Applications II
S_EMP Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID START_DAT


---- ----------------- ---------------- -------- ---------
COMMENTS
--------------------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- ---------------------------- ------- ------
COMMISSION_PCT
---------------
10 Havel Marta mhavel 27-FEB-91
2 Warehouse Manager 45 1307

11 Magee Colin cmagee 14-MAY-90


3 Sales Representative 31 1400
10

12 Giljum Henry hgiljum 18-JAN-92


3 Sales Representative 32 1490
12.5

13 Sedeghi Yasmin ysedeghi 18-FEB-91


3 Sales Representative 33 1515
10

14 Nguyen Mai mnguyen 22-JAN-92


3 Sales Representative 34 1525
15

15 Dumas Andre adumas 09-OCT-91


3 Sales Representative 35 1450
17.5

16 Maduro Elena emaduro 07-FEB-92


6 Stock Clerk 41 1400

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-11
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID START_DAT


---- ----------------- ---------------- -------- ---------
COMMENTS
--------------------------------------------------------------
MANAGER_ID TITLE DEPT_ID SALARY
---------- ---------------------------- ------- ------
COMMISSION_PCT
---------------
17 Smith George gsmith 08-MAR-90
6 Stock Clerk 41 940

18 Nozaki Akira anozaki 09-FEB-91


7 Stock Clerk 42 1200

19 Patel Vikram vpatel 06-AUG-91


7 Stock Clerk 42 795

20 Newman Chad cnewman 21-JUL-91


8 Stock Clerk 43 750

21 Markarian Alexander amarkari 26-MAY-91


8 Stock Clerk 43 850

22 Chang Eddie echang 30-NOV-90


9 Stock Clerk 44 800

23 Patel Radha rpatel 17-OCT-90


9 Stock Clerk 34 795

24 Dancs Bela bdancs 17-MAR-91


10 Stock Clerk 45 860

25 Schwartz Sylvie sschwart 09-MAY-91


10 Stock Clerk 45 1100

Note: This display has been formatted.

......................................................................................................................................................
B-12 Oracle iDS Forms: Build Internet Applications II
S_ITEM Description
.....................................................................................................................................................

S_ITEM Description
Column Name Null? Datatype
------------------------- -------------- ----------
ORD_ID NOT NULL NUMBER(7)
ITEM_ID NOT NULL NUMBER(7)
PRODUCT_ID NOT NULL NUMBER(7)
PRICE NUMBER(11,2)
QUANTITY NUMBER(9)
QUANTITY_SHIPPED NUMBER(9)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-13
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_ITEM Data

SQL> SELECT * FROM s_item;

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED


------ -------- ----------- ------ -------- -----------------
100 1 10011 135 500 500
100 2 10013 380 400 400
100 3 10021 14 500 500
100 5 30326 582 600 600
100 7 41010 8 250 250
100 6 30433 20 450 450
100 4 10023 36 400 400
101 1 30421 16 15 15
101 3 41010 8 20 20
101 5 50169 4.29 40 40
101 6 50417 80 27 27
101 7 50530 45 50 50
101 4 41100 45 35 35
101 2 40422 50 30 30
102 1 20108 28 100 100
102 2 202011 23 45 45
103 1 30433 20 15 15
103 2 32779 7 11 11
104 1 20510 9 7 7
104 4 30421 16 35 35
104 2 20512 8 12 12
104 3 30321 1669 19 19
105 1 50273 22.8 16 16
105 3 50532 47 28 28
105 2 50419 80 13 13

......................................................................................................................................................
B-14 Oracle iDS Forms: Build Internet Applications II
S_ITEM Data
.....................................................................................................................................................

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED


------- ------- ----------- ------ -------- -----------------
106 1 20108 28 46 46
106 4 50273 22.89 75 75
106 5 50418 75 98 98
106 6 50419 80 27 27
106 2 20201 123 21 21
106 3 50169 4.29 125 125
107 1 20106 11 50 50
107 3 20201 115 130 130
107 5 30421 16 55 55
107 4 30321 1669 75 75
107 2 20108 28 22 22
108 1 20510 9 9 9
108 6 41080 35 50 50
108 7 41100 45 42 42
108 5 32861 60 57 57
108 2 20512 8 18 18
108 4 32779 7 60 60
108 3 30321 1669 85 85
109 1 10011 140 150 150
109 5 30426 18.25 500 500
109 7 50418 75 43 43
109 6 32861 60 50 50
109 4 30326 582 1500 1500
109 2 10012 175 600 600
109 3 10022 21.95 300 300
110 1 50273 22.89 17 17
110 2 50536 50 23 23
111 1 40421 65 27 27
111 2 41080 35 29 29
97 1 20106 9 1000 1000
97 2 303211 500 50 50
98 1 404218 5 7 7
99 1 20510 9 18 18
99 2 20512 8 25 25
99 3 50417 80 53 53
99 4 50530 45 69 69

Note: This display has been formatted.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-15
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_ORD Description and Data


Column Name Null? Datatype
------------------------ ------ ---------------------
ID NOT NULL NUMBER(7)
CUSTOMER_ID NOT NULL NUMBER(7)
DATE_ORDERED DATE
DATE_SHIPPED DATE
SALES_REP_ID NUMBER(7)
TOTAL NUMBER(11,2)
PAYMENT_TYPE VARCHAR2(6)
ORDER_FILLED VARCHAR2(1)

SQL> SELECT * FROM s_ord;

ID CUSTOMER_ID DATE_ORDE DATE_SHIPSALES_REP_IDTOTAL PAYMEN ORDER_F


--- ----------- --------- ---------------------------------- ------
100 204 31-AUG92 10-SEP-9211 601100 CREDIT Y
101 205 31-AUG-92 15-SEP-9214 8056.6 CREDIT Y
102 206 01-SEP-92 08-SEP-9215 8335 CREDIT Y
103 208 02-SEP-92 22-SEP-9215 377 CASH Y
104 208 03-SEP-92 23-SEP-9215 32430 CREDIT Y
105 209 04-SEP-92 18-SEP-9211 2722.24 CREDIT Y
106 210 07-SEP-92 15-SEP-9212 15634 CREDIT Y
107 211 07-SEP-92 21-SEP-9215 142171 CREDIT Y
108 212 07-SEP-92 10-SEP-9213 149570 CREDIT Y
109 213 08-SEP-92 28-SEP-9211 1020935 CREDIT Y
110 214 09-SEP-92 21-SEP-9211 1539.13 CASH Y
111 204 09-SEP-92 21-SEP-9211 2770 CASH Y
97 201 28-AUG-92 17-SEP-9212 84000 CREDIT Y
98 202 31-AUG-92 10-SEP-9214 595 CASH Y
99 203 31-AUG-92 18-SEP-9214 7707 CREDIT Y
112 210 31-AUG-92 10-SEP-9212 550 CREDIT Y

16 rows selected.

......................................................................................................................................................
B-16 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Description
.....................................................................................................................................................

S_PRODUCT Description
Column Name Null? Datatype
---------------------------------- -----------------
ID NOT NULL NUMBER(7)
NAMENOT NULL VARCHAR2(50)
SHORT_DESC VARCHAR2(255)
LONGTEXT_ID NUMBER(7)
IMAGE_ID NUMBER(7)
SUGGESTED_WHLSL_PRICE NUMBER(11,2)
WHLSL_UNITS VARCHAR2(25)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-17
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_PRODUCT Data

SQL> SELECT * FROM s_product;

ID NAME SHORT_DESC LONGTEXT_ID


---- -------------------------- -----------
IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS
-------- --------------------------------
10011 Boot Beginners ski boot 518
1001 150

10012 Ace Ski BootIntermediate ski boot519


1002 200

10013 Pro Ski BootAdvanced ski boot 520


1003 410

10021 Bunny Ski PoleBeginners ski pole528


1011 16.25

10022 Ace Ski PoleIntermediate ski pole529


1012 21.95

10023 Pro Ski PoleAdvanced ski pole 530


1013 40.95

20106 Junior Soccer BallJunior soccer ball613


11

20108 World Cup Soccer BallWorld cup soccer ball615


28

20201 World Cup NetWorld cup net 708


123

......................................................................................................................................................
B-18 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Data
.....................................................................................................................................................

ID NAME SHORT_DESC LONGTEXT_ID


---- ---------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
20510 Black Hawk Knee pads, pair 1017
Knee Pads 9

20512Black Hawk Elbow pads, pair 1019


Elbow Pads 8

30321 Grand Prix Bicycle Road bicycle828


1291 1669

30326 Himalaya BicycleMountain bicycle833


1296 582

30421 Grand Prix Road bicycle tires927


Bicycle Tires16

30426 Himalaya TiresMountain bicycle tires933


18.25

30433New Air PumpTire pump 940


20

32779 Slaker Water Water bottle 1286


Bottle 7

32861 Safe-T HelmetBicycle helmet 1368


1829 60

40421 Alexeyer ProStraight bar 928


Lifting Bar
1381 65

40422 Pro Curling BarCurling bar 929


1382 50

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-19
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID NAME SHORT_DESC LONGTEXT_ID


---- ---------------------------------------
IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS
-------- --------------------------------
40421 Alexeyer ProStraight bar 928
Lifting Bar
1381 65

40422 Pro Curling BarCurling bar 929


1382 50

41010 Prostar 10 Ten pound weight 517


Pound Weight
8

41020 Prostar 20 Twenty pound weight527


Pound Weight
12

41050 Prostar 50 Fifty pound weight557


Pound Weight
25

41080 Prostar 80 Eighty pound weight587


Pound Weight
35

41100 Prostar 100 One hundred pound 607


Pound Weightweight
45

50169 Major League Baseball 676


Baseball
1119 4.29

......................................................................................................................................................
B-20 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Data
.....................................................................................................................................................

ID NAME SHORT_DESC LONGTEXT_ID


---- -----------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
50273Chapman HelmetBatting helmet 780
1223 22.89

50417 Griffey GloveOutfielders glove 924


1367 80

50418 Alomar GloveInfielders glove 925


1368 75

50419 Steinbach GloveCatchers glove 926


1369 80

50530Cabrera Bat Thirty inch bat 1037


1480 45

50532 Puckett Bat Thirty-two inch bat 1039


1482 47

50536 Winfield BatThirty-six inch bat 1043


1486 50

Note: This display has been formatted.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-21
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_REGION Description and Data


Column Name Null? Datatype
------------------------------ ----------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)

SQL> SELECT * FROM s_region;

ID NAME
--- --------------------------
1 North America
2 South America
3 Africa / Middle East
4 Asia
5 Europe

......................................................................................................................................................
B-22 Oracle iDS Forms: Build Internet Applications II
S_TITLE Description and Data
.....................................................................................................................................................

S_TITLE Description and Data


Column Name Null? Datatype
---------------------------------- ----------------
TITLE NOT NULL VARCHAR2(25)

SQL> SELECT * FROM s_title;

TITLE
------------------------
President
Sales Representative
Stock Clerk
VP, Administration
VP, Finance
VP, Operations
VP, Sales
Warehouse Manager

8 rows selected.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-23
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

Oracle8i Objects: Types, Tables


emp_type_ObjCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

emp_type_RefCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID REF OF DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

dept_type
--------------------------------- ----------------
ID NUMBER
NAME VARCHAR2(25)
REGION_ID NUMBER(7)

......................................................................................................................................................
B-24 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

Tables

oo_emp_Table_ObjCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
ID LAST_NAME FIRST_NAME USERID
--------- --------------------- --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
-----------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1Velasquez Carmencvelasqu
03-MAR-90 President
DEPT_TYPE(50, Administration, 1)
2500

2Ngao LaDorislngao
08-MAR-90 1 VP Operations
DEPT_TYPE(41, Operations, 1)
1450

3Nagayama Midorimnagayam
17-JUN-91 1 VP Sales
DEPT_TYPE(31, Sales, 1)
1400

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-25
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- ----------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
4 Quick-To-See Mark mquickto
07-APR-90 1 VP Finance
DEPT_TYPE(10, Finance, 1)
1450

5 Ropeburn Audry aropebur


04-MAR-90 1 VP Administration
DEPT_TYPE(50, Administration, 1)
1550

6 Urguhart Molly murguhar


18-JAN-91 2 Warehouse Manager
DEPT_TYPE(41, Operations, 1)
1200

7 Menchu Roberta rmenchu


14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, Operations, 2)
1250

8 Biri Ben bbiri


07-APR-90 2 Warehouse Manager
DEPT_TYPE(43, Operations, 3)
1100

9 Catchpole Antoinette acatchpo


09-FEB-92 2 Warehouse Manager
DEPT_TYPE(44, Operations, 4)
1300

......................................................................................................................................................
B-26 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- ------------------------------ --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
10 Havel Marta mhavel
27-FEB-91 2 Warehouse Manager
DEPT_TYPE(45, Operations, 5)
1307

11 Magee Colin cmagee


14-MAY-90 3 Sales Representative
DEPT_TYPE(31, Sales, 1)
1400 10

12 Giljum Henry hgiljum


18-JAN-92 3 Sales Representative
DEPT_TYPE(32, Sales, 2)
1490 13

13 Sedeghi Yasmin ysedeghi


18-FEB-91 3 Sales Representative
DEPT_TYPE(33, Sales, 3)
1515 10

14 Nguyen Mai mnguyen


22-JAN-92 3 Sales Representative
DEPT_TYPE(34, Sales, 4)
1525 15

15 Dumas Andre adumas


09-OCT-91 3 Sales Representative
DEPT_TYPE(35, Sales, 5)
145018

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-27
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- -------------- --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
16 Maduro Elena emaduro
07-FEB-92 6 Stock Clerk
DEPT_TYPE(41, Operations, 1)
1400

17 Smith George gsmith


08-MAR-90 6 Stock Clerk
DEPT_TYPE(41, Operations, 1)
940

18 Nozaki Akira anozaki


09-FEB-91 7 Stock Clerk
DEPT_TYPE(42, Operations, 2)
1200

19 Patel Vikram vpatel


06-AUG-91 7 Stock Clerk
DEPT_TYPE(42, Operations, 2)
795

20 Newman Chad cnewman


21-JUL-91 8 Stock Clerk
DEPT_TYPE(43, Operations, 3)
750

21 Markarian Alexander amarkari


26-MAY-91 8 Stock Clerk
DEPT_TYPE(43, Operations, 3)
850

......................................................................................................................................................
B-28 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- ------------------------------ --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
22 Chang Eddie echang
30-NOV-90 9 Stock Clerk
DEPT_TYPE(44, Operations, 4)
800

23 Patel Radha rpatel


17-OCT-90 9 Stock Clerk
DEPT_TYPE(34, Sales, 4)
795

24 Dancs Bela bdancs


17-MAR-91 10 Stock Clerk
DEPT_TYPE(45, Operations, 5)
860

25 Schwartz Sylvie sschwart


09-MAY-91 10 Stock Clerk
DEPT_TYPE(45, Operations, 5)
1100

oo_emp_Table_RefCol
Name Null? Type
------------------------------ ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-29
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

DEPT_ID REF OF DEPT_TYPE


SALARY NUMBER(11,2)
COMMISSION_PCTNUMBER(4,2)

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 Velasquez Carmen cvelasqu
03-MAR-90 President
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
2500

2 Ngao LaDoris lngao


08-MAR-90 1 VP Operations
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450

3 Nagayama Midori mnagayam


17-JUN-91 1 VP Sales
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400

4 Quick-To-See Mark mquickto


07-APR-90 1 VP Finance
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450

5 Ropeburn Audry aropebur


04-MAR-90 1 VP Administration
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1550
......................................................................................................................................................
B-30 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- ------------------ --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
6 Urguhart Molly murguhar
18-JAN-91 2 Warehouse Manager
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1200

9 Catchpole Antoinette acatchpo


09-FEB-92 2 Warehouse Manager
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1300

10 Havel Marta mhavel


27-FEB-91 2 Warehouse Manager
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1307

11 Magee Colin cmagee


14-MAY-90 3 Sales Representative
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400 10

13 Sedeghi Yasmin ysedeghi


18-FEB-91 3 Sales Representative
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1515 10

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-31
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- ------------------ --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
14 Nguyen Mai mnguyen
22-JAN-92 3 Sales Representative
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1525 15

15 Dumas Andre adumas


09-OCT-91 3 Sales Representative
0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450 18

16 Maduro Elena emaduro


07-FEB-92 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400

17 Smith George gsmith


08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
940

18 Nozaki Akira anozaki


09-FEB-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1200

......................................................................................................................................................
B-32 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
19 Patel Vikram vpatel
06-AUG-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
795

20 Newman Chad cnewman


21-JUL-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
750

21 Markarian Alexander amarkari


26-MAY-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
850

22 Chang Eddie echang


30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
800

23 Patel Radha rpatel


17-OCT-90 9 Stock Clerk
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
795

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-33
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
24 Dancs Bela bdancs
17-MAR-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
860

25 Schwartz Sylvie sschwart


09-MAY-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1100

oo_dept_table
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER
NAME VARCHAR2(25)
REGION_ID NUMBER(7)

ID NAME REGION_ID
-------------------- ------------- ----------------
10 Finance 1
31 Sales 1
32 Sales 2
33 Sales 3
34 Sales 4
35 Sales 5
41 Operations 1
42 Operations 2
43 Operations 3

......................................................................................................................................................
B-34 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

44 Operations 4
45 Operations 5
50 Administration 1

rel_emp_Table_Objcol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 Velasquez Carmen cvelasqu
03-MAR-90 President
DEPT_TYPE(50, Administration, 1)
2500

2 Ngao LaDoris lngao


08-MAR-90 1 VP Operations
DEPT_TYPE(41, Operations, 1)
1450

3 Nagayama Midori mnagayam


17-JUN-91 1 VP Sales
DEPT_TYPE(31, Sales, 1)
1400
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-35
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
4 Quick-To-See Mark mquickto
07-APR-90 1 VP Finance
DEPT_TYPE(10, Finance, 1)
1450

5 Ropeburn Audry aropebur


04-MAR-90 1 VP Administration
DEPT_TYPE(50, Administration, 1)
1550

6 Urguhart Molly murguhar


18-JAN-91 2 Warehouse Manager
DEPT_TYPE(41, Operations, 1)
1200

7 Menchu Roberta rmenchu


14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, Operations, 2)
1250

8 Biri Ben bbiri


07-APR-90 2 Warehouse Manager
DEPT_TYPE(43, Operations, 3)
1100

9 Catchpole Antoinette acatchpo


09-FEB-92 2 Warehouse Manager
DEPT_TYPE(44, Operations, 4)
1300

......................................................................................................................................................
B-36 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
10 Havel Marta mhavel
27-FEB-91 2 Warehouse Manager
DEPT_TYPE(45, Operations, 5)
1307

11 Magee Colin cmagee


14-MAY-90 3 Sales Representative
DEPT_TYPE(31, Sales, 1)
1400 10

12 Giljum Henry hgiljum


18-JAN-92 3 Sales Representative
DEPT_TYPE(32, Sales, 2)
1490 13

13 Sedeghi Yasmin ysedeghi


18-FEB-91 3 Sales Representative
DEPT_TYPE(33, Sales, 3)
1515 10

14 Nguyen Mai mnguyen


22-JAN-92 3 Sales Representative
DEPT_TYPE(34, Sales, 4)
1525 15

15 Dumas Andre adumas


09-OCT-91 3 Sales Representative
DEPT_TYPE(35, Sales, 5)
1450 18

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-37
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
16 Maduro Elena emaduro
07-FEB-92 6 Stock Clerk
DEPT_TYPE(41, Operations, 1)
1400

17 Smith George gsmith


08-MAR-90 6 Stock Clerk
DEPT_TYPE(41, Operations, 1)
940

18 Nozaki Akira anozaki


09-FEB-91 7 Stock Clerk
DEPT_TYPE(42, Operations, 2)
1200

19 Patel Vikram vpatel


06-AUG-91 7 Stock Clerk
DEPT_TYPE(42, Operations, 2)
795

20 Newman Chad cnewman


21-JUL-91 8 Stock Clerk
DEPT_TYPE(43, Operations, 3)
750

21 Markarian Alexander amarkari


26-MAY-91 8 Stock Clerk
DEPT_TYPE(43, Operations, 3)
850

......................................................................................................................................................
B-38 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
22 Chang Eddie echang
30-NOV-90 9 Stock Clerk
DEPT_TYPE(44, Operations, 4)
800

23 Patel Radha rpatel


17-OCT-90 9 Stock Clerk
DEPT_TYPE(34, Sales, 4)
795

24 Dancs Bela bdancs


17-MAR-91 10 Stock Clerk
DEPT_TYPE(45, Operations, 5)
860

25 Schwartz Sylvie sschwart


09-MAY-91 10 Stock Clerk
DEPT_TYPE(45, Operations, 5)
1100

rel_emp_Table_RefCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-39
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

DEPT_ID REF OF DEPT_TYPE


SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

......................................................................................................................................................
B-40 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 Velasquez Carmen cvelasqu
03-MAR-90 President
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
2500

2 Ngao LaDoris lngao


08-MAR-90 1 VP Operations
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450

3 Nagayama Midori mnagayam


17-JUN-91 1 VP Sales
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400

4 Quick-To-See Mark mquickto


07-APR-90 1 VP Finance
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450

5 Ropeburn Audry aropebur


04-MAR-90 1 VP Administration
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1550

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-41
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
6 Urguhart Molly murguhar
18-JAN-91 2 Warehouse Manager
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1200

9 Catchpole Antoinette acatchpo


09-FEB-92 2 Warehouse Manager
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1300

10 Havel Marta mhavel


27-FEB-91 2 Warehouse Manager
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1307

11 Magee Colin cmagee


14-MAY-90 3 Sales Representative
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400 10

13 Sedeghi Yasmin ysedeghi


18-FEB-91 3 Sales Representative
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1515 10

......................................................................................................................................................
B-42 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
14 Nguyen Mai mnguyen
22-JAN-92 3 Sales Representative
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1525 15

15 Dumas Andre adumas


09-OCT-91 3 Sales Representative
0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1450 18

16 Maduro Elena emaduro


07-FEB-92 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1400

17 Smith George gsmith


08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
940

18 Nozaki Akira anozaki


09-FEB-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1200

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-43
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
19 Patel Vikram vpatel
06-AUG-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
795

20 Newman Chad cnewman


21-JUL-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
750

21 Markarian Alexander amarkari


26-MAY-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
850

22 Chang Eddie echang


30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
800

23 Patel Radha rpatel


17-OCT-90 9 Stock Clerk
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
795

......................................................................................................................................................
B-44 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................

ID LAST_NAME FIRST_NAME USERID


---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
24 Dancs Bela bdancs
17-MAR-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
860

25 Schwartz Sylvie sschwart


09-MAY-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1100

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-45
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

......................................................................................................................................................
B-46 Oracle iDS Forms: Build Internet Applications II
................................

Mouse Movement Events


Appendix C: Mouse Movement Events
.....................................................................................................................................................

Introduction
Overview
You have already seen how to use mouse action triggers and built-ins. This appendix
explains how to develop drag-and-drop functionality with Client Server forms
applications.

Objectives
After completing this appendix, you should be able to implement drag-and-drop
functionality with Client Server forms.

Drag and Drop

Items in original positions

Item-A highlighted

Items repositioned

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
C-2 Oracle iDS Forms: Build Internet Applications II
Introduction
.....................................................................................................................................................

Notes Page

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II C-3
Appendix C: Mouse Movement Events
.....................................................................................................................................................

Drag and Drop


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

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.

......................................................................................................................................................
C-4 Oracle iDS Forms: Build Internet Applications II
Drag and Drop
.....................................................................................................................................................

Summary

In this appendix, you should have learned how to:


Drag and Drop Items

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II C-5
Appendix C: Mouse Movement Events
.....................................................................................................................................................

Summary
In this Appendix, you should have learned how to implement drag-and-drop
functionality in your Client Server form applications by using appropriate mouse
triggers and system variables.

Mouse Triggers
When_Mouse_Move
When_Mouse_Up
When_Mouse_Down

Mouse System Varaiables


:SYSTEM.MOUSE_ITEM
SYSTEM.MOUSE_X_POS
:SYSTEM.MOUSE_Y_POS

......................................................................................................................................................
C-6 Oracle iDS Forms: Build Internet Applications II
................................

Introduction to
Oracle8i Object Features
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Objectives

After completing this appendix, you should be able


to do the following:
Describe the new Oracle8i scalar data types
Describe object types and objects
Describe object tables, object columns, and
object views
Describe the INSTEAD-OF triggers
Describe object REFs
Identify the display of objects in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
In this appendix you will review certain object features of Oracle8i. This appendix
also explains how these objects are displayed in the Object Navigator.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-3
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

New Oracle8i Scalar Data Types

NCHAR
NVARCHAR2
FLOAT
NLS types

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-4 Oracle iDS Forms: Build Internet Applications II
New Oracle8i Data Types
......................................................................................................................................................

New Oracle8i Data Types


Scalar Data Types
NCHAR stores fixed-length (blank-padded if necessary) NLS character
data. How the data is represented internally depends on the national
character set, which might use a fixed-width encoding such as
US7ASCII or a variable-width encoding such as JA16SJIS.
NVARCHAR2 stores variable-length NLS character data. How the data
is represented internally depends on the national character set, which
might use a fixed-width encoding such as WE8EBCDIC37C or a
variable-width encoding such as JA16DBCS.
FLOAT is a subtype of NUMBER. However, you cannot specify a scale
for FLOAT variables. You can specify only a binary precision, which is
the total number of binary digits.
There is no change to the way scalar data types are displayed in Oracle Forms
Developer. The new data types are automatically converted to existing Oracle Forms
Developer item data types.

NLS Types
Oracle8i offers extended National Language Support (NLS) including national
character sets and the data types NCHAR and NVARCHAR2, which store NLS data.
With NLS, number and date formats adapt automatically to the language conventions
specified for a user session. Thus, users around the world can interact with the Oracle
Database Server in their native languages. NLS is discussed in Oracle8i Server
Reference Manual.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-5
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Types

Attributes

ORDER
po_no
custinfo
line_items
amount

Methods

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-6 Oracle iDS Forms: Build Internet Applications II
Object Types
......................................................................................................................................................

Object Types
An object type is a user-defined composite data type. You build object types from
predefined data types or from previously defined object types. When you create an
object type you specify the component types from which it is built. You also specify
the functions and procedures that can act on the object type. Thus, an object type is in
some ways similar to a record type, and in some ways similar to a package.
An object type must have one or more attributes and can contain methods.

Attributes An object type is similar to a record type in that it is composed of one or


more subparts that are of predefined data types. Record types call these subparts fields,
but object types call these subparts attributes.
Attributes define the object structure.
CREATE TYPE address_type AS OBJECT
(address VARCHAR2(30),
city VARCHAR2(15),
stateCHAR(2),
zip CHAR(5));
CREATE TYPE phone_type AS OBJECT
(country NUMBER(2),
area NUMBER(4),
phoneNUMBER(9));
Just as the fields of a record type can be of other record types, the attributes of an
object type can be of other object types. Such an object type is called nested.
CREATE TYPE address_and_phone_type AS OBJECT
(address address_type,
phonephone_type);
Object types are like record types in another sense: Both of them must be declared as
types before the actual object or record can be declared.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-7
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Types

Ship

ORDER

Check Cancel
status

Hold

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-8 Oracle iDS Forms: Build Internet Applications II
Object Types
......................................................................................................................................................

Object Types (continued)

Methods An object type is also similar to a package. Once an object is declared, its
attributes are similar to package variables. Like packages, object types can contain
procedures and functions. In object types, these subprograms are known as methods.
A method describes the behavior of an object type.
Like packages, object types can be declared in two parts: a specification and a body.
Like package variables, attributes declared in the object type specification are public
and those declared in the body are private. As with package subprograms, all methods
are defined in the package body, but only those whose specification appears in the
object type specification are public methods.
Here is an example of an object type:
CREATE TYPE dept_type AS OBJECT
(dept_idNUMBER(2),
dnameVARCHAR2(14),
loc VARCHAR2(3),
MEMBER PROCEDURE set_dept_id (d_id NUMBER),
PRAGMA RESTRICT_REFERENCES (set_dept_id,
RNDS,WNDS,RNPS,WNPS),
MEMBER FUNCTION get_dept_id RETURN NUMBER,
PRAGMA RESTRICT_REFERENCES (get_dept_id,
RNDS,WNDS,RNPS,WNPS));
CREATE TYPE BODY dept_type AS
MEMBER PROCEDURE set_dept_id (d_id NUMBER)
IS
BEGIN
dept_id := d_id;
END;
MEMBER FUNCTION get_dept_id
RETURN NUMBER
IS
BEGIN
RETURN (dept_id);
END;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-9
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Tables

Object table based on object type

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-10 Oracle iDS Forms: Build Internet Applications II
Creating Oracle8i Objects
......................................................................................................................................................

Creating Oracle8i Objects


Introduction
After you have declared an object type, you can create objects based on the type.

Object Tables
One way to create an object is to create a table whose rows are objects of that object
type.
Here is an example of an object table declaration:
CREATE TABLE o_dept OF dept_type;
SQL and PL/SQL treat object tables very similarly to relational tables, with the
attribute of the object corresponding to the columns of the table, but there are
significant differences. The most important difference is that rows in an object table
are assigned object IDs (OIDs) and can be referenced by using a REF type.
Note: REF types are reviewed later.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-11
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Columns

Object column based on object type

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-12 Oracle iDS Forms: Build Internet Applications II
Object Columns
......................................................................................................................................................

Object Columns
Another construct that you can base on an object type is an object column in a
relational table. Here is an example of a relational table creation statement with an
object column:
CREATE TABLE o_customer (
custid NUMBER (6) NOT NULL,
name VARCHAR2 (45),
repid NUMBER (4) NOT NULL,
creditlimit NUMBER (9,2),
address address_type,
phone phone_type);
In the object table, the rows of a table are objects. In a relational table with an object
column, the column is an object. The table will usually have standard columns, as well
as one or more object column.
Object columns are not assigned object IDs (OIDs), and therefore cannot be
referenced by using object REF values.
Note: Object REFs are reviewed later in this section.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-13
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Views

Object-oriented Object Relational


application view table

Object views based on object types

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-14 Oracle iDS Forms: Build Internet Applications II
Object Views
......................................................................................................................................................

Object Views
Often the most difficult part of adopting a new technology is the conversion process
itself. For example, a large enterprise might have several applications accessing the
same data stored in relational tables. If such an enterprise decided to start using object-
relational technology, it would not convert all of the applications at once, but would
convert the applications one at a time.
This presents a problem. The applications that have been converted need the data
stored as objects, while the applications that have not been converted need the data
stored in relational tables.
This dilemma is addressed by object views. Like all views, an object view transforms
the way a table appears to a user, without changing the actual structure of the table.
Object views make relational tables look like object tables. This enables developers to
postpone converting the data from relational structures to object-relational structures
until after all of the applications have been converted. During the conversion process,
the object-relational applications can operate against the object view, while the
relational applications can continue to operate against the relational tables.
Objects accessed through object views are assigned Object IDs (OIDs) and can be
referenced by using Object REFs.
Note: Object REFs are reviewed later in this section.
Here is an example of an object view creation statement:
CREATE VIEW emp_view OF emp_type
WITH OBJECT OID (eno)
AS
SELECT e.empno, e.ename, e.sal, e.job
FROM emp e;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-15
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

INSTEAD-OF Triggers

DECLARE

BEGIN

EXCEPTION

END;

Nonupdatable view INSTEAD-OF trigger

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-16 Oracle iDS Forms: Build Internet Applications II
INSTEAD-OF Triggers
......................................................................................................................................................

INSTEAD-OF Triggers
INSTEAD-OF triggers provide a transparent way of modifying views that cannot be
modified directly through SQL DML statements (INSERT, UPDATE, and DELETE).
These triggers are called INSTEAD-OF triggers because, unlike other types of
triggers, Oracle fires the trigger instead of executing the triggering statement. The
trigger performs update, insert, or delete operations directly on the underlying tables.
Users write normal INSERT, DELETE, and UPDATE statements against the view, and
the INSTEAD-OF trigger works invisibly in the background to make the right actions
take place.
INSTEAD-OF triggers are activated for each row.
Note: Although you can use INSTEAD-OF triggers with any view, they are typically
required with object views.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-17
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

References to Objects

OID

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-18 Oracle iDS Forms: Build Internet Applications II
Referencing Objects
......................................................................................................................................................

Referencing Objects
Introduction
In relational databases, primary-key values are used to uniquely identify records. In
object-relational databases, OIDs provide an alternate method.
When a row in an object table or object view is created, it is assigned automatically a
unique identifier called an object ID (OID).

Object REFs
With relational tables, you can associate two records by storing the primary key of one
record in one of the columns (the foreign-key column) of another.
In a similar way, you can associate a row in a relational table to an object by storing
the OID of an object in a column of a relational table.
Or you can associate two objects by storing the OID of one object in an attribute of
another.
The stored copy of the OID then becomes a pointer, or reference (REF), to the original
object.
The attribute or column that holds the OID is of data type REF.
Note: Object columns are not assigned OIDs and cannot be pointed to by a REF.
Here is an example of a table declaration that includes a column with a REF data type:
CREATE TABLE o_emp
( empno NUMBER(4) NOT NULL,
ename VARCHAR2(10),
job VARCHAR2(10),
mgr NUMBER(4),
hiredate DATE,
sal NUMBER(7,2),
comm NUMBER(7,2),
dept REF dept_type SCOPE IS o_dept) ;
Note: The REF is scoped here to restrict the reference to a single table, o_dept. The
object itself is not stored in the table; only the OID value for the object is stored there.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-19
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Types in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

Object Type Wizard

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-20 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................

Displaying Oracle8i Objects in the Object Navigator


In the Database Objects section, the Object Navigator lists declared types, along with
tables, views, and other Oracle objects.

Object Types
Both the attributes and the methods are listed under each type. Additionally, the nested
types within address_and_phone_type are displayed in an indented sublevel.
This convention is used for nested object and object type displays throughout Oracle
Forms Developer.

Oracle8i Type Wizard


You can create object types by using the Oracle8i Type Wizard, which enables you to
define attributes and methods.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-21
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Tables in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

Object Columns in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-22 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................

Object Tables
Object tables are displayed like relational tables, with the attributes of the object
displayed like columns in a relational table. Additionally, the object table type name is
displayed in parentheses after the name of the object table.

Object Columns
Object columns are displayed with the object type in parentheses after the column
name, and with the attributes of the type indented underneath the column name.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-23
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object Views in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

INSTEAD-OF Trigger Dialog Box

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-24 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................

Object Views
Object views are displayed like any other view, except that the object type they are
based on is written in parentheses after the view name.

INSTEAD-OF Triggers
You can create INSTEAD-OF database triggers through the trigger creation dialog
box, just as you would any other database trigger.
INSTEAD-OF INSERT, UPDATE, and DELETE triggers allow you to directly insert,
update, and delete against object views. They can also be used with any other type of
view that does not allow direct DML.
When a view has an INSTEAD-OF trigger, the code in the trigger is executed in place
of the triggering DML code.

Reference For more information about INSTEAD-OF triggers, see:


Oracle8i Server SQL Reference Manual
Oracle8i Concepts Manual

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-25
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Object REFs in Object Navigator

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-26 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................

Object REFs
Object types that contain attributes of type REF, and relational tables that have
columns of type REF, display the keyword REF before the name of the object type that
is being referenced.
The attributes of the referenced object type are displayed indented underneath the
column or attribute.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-27
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

Summary

In this appendix, you should have learned how:


Oracle8i introduced three new scalar datatypes.
Objects and object types allow representation of
complex data.
Three kinds of objects are object tables,
object columns, and object views.

Copyright Oracle Corporation, 2001. All rights reserved.

Summary

In this appendix, you should have learned how to:


INSTEAD-OF triggers allow DML on
object views.
Object REFs store the object identifier of
certain types of objects.
The Object Navigator can display certain
types of objects.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
D-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
New Oracle8i Data Types
Oracle8i introduced three new scalar data types and new composite data types such as
object types.

Objects
Three kinds of objects are object tables, object columns, and object views.
INSTEAD-OF triggers allow DML on object views.
Object REFs store the Object Identifier of certain types of objects.

Oracle8i Objects In the Object Navigator


The Object Navigator can display certain types of objects.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-29
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................

......................................................................................................................................................
D-30 Oracle iDS Forms: Build Internet Applications II
................................

Menu Run-Time
Parameters
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Objectives

After completing this appendix, you should be able to


customize menu modules using substitution
parameters.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson, you will learn how to modify menus dynamically, as well as
how to control application security through menu access.

Objectives
After completing this lesson, you should be able to customize menu modules
by using substitution parameters.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-3
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Built-in Substitution Parameters

UN Current username

PW Current password

AD Directory name

SO Current menu name

TT Terminal type

LN Language used

Copyright Oracle Corporation, 2001. All rights reserved.

User-Named Substitution Parameters

Design time Run time

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-4 Oracle iDS Forms: Build Internet Applications II
Substitution Parameters
......................................................................................................................................................

Substitution Parameters
What Is a Substitution Parameter?
A substitution parameter is a two-character variable of type CHAR that is
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 Form 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.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-5
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Parameter Properties

- Name
- Label
- Maximum Length
- Case Restriction
- Menu Parameter
- Conceal Data Initial Value
- Associated Menus - Required
- Hint

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-6 Oracle iDS Forms: Build Internet Applications 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
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 users input to
either uppercase, lowercase, or none
Conceal Data The property that determines whether the users input is ech-
oed on 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 No to
allow the parameter value to be set to Null
Hint The text string displayed on the message line of the console

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-7
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Substitution Parameter Built-ins

QUERY_PARAMETER
APPLICATION_PARAMETER

Copyright Oracle Corporation, 2001. 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

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-8 Oracle iDS Forms: Build Internet Applications II
Substitution Parameter Built-ins
......................................................................................................................................................

Substitution Parameter Built-ins


Prompting for Substitution Parameter Values
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).
PLUS80W &UN/&PW @&CF

Referencing a Parameter in a PL/SQL Routine


Prefix the parameter name with an 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);

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-9
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Validating Substitution
Parameter Values

MENU_SUCCESS function:
Returns TRUE if the user does not cancel
the Enter Parameter Values dialog box
Is used in a WHILE loop

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-10 Oracle iDS Forms: Build Internet Applications II
Validating a Substitution Parameter Value
......................................................................................................................................................

Validating a Substitution Parameter Value


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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-11
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Summary

In this lesson, you should have learned how to


customize menu modules using substitution
parameters.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
E-12 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
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

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-13
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

......................................................................................................................................................
E-14 Oracle iDS Forms: Build Internet Applications II
................................

Handling Server-
SideErrors
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Objectives

After completing this appendix, you should be able to


do the following:
Handle server-side database errors
Obtain the cause of declarative-constraint
violations

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
F-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson covers the use of Oracle server features in Form Builder
applications. You will learn about handling Oracle server errors, including
declarative-constraint violations.

Objectives
At the end of this lesson, you should be able to:
Handle errors raised by the Oracle server
Obtain the cause of declarative-constraint violations

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-3
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Obtaining the Cause of Declarative-


Constraint Violation

Predefined error messages for


declarative constraints:
Primary/unique key; foreign key; check
ORA-02291: integrity constraint
(schema.constraint) violated
parent key not found
Obtaining the name of violated constraint:
Function STRIP_CONSTRAINT_NAME

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
F-4 Oracle iDS Forms: Build Internet Applications II
Obtaining the Cause of Declarative-Constraint Violations
......................................................................................................................................................

Obtaining the Cause of Declarative-Constraint Violations


To handle declarative-constraint violations effectively, you must use the
predefined error message to determine the constraint that was violated.

Predefined Error Messages for Declarative Constraints


Constraint Error Message
Primary Key ORA-00001: unique constraint (schema.constraint) violated
Unique Key
Foreign Key ORA-02291: integrity constraint (schema.constraint) violatedparent
key not found
ORA-02292: integrity constraint (schema.constraint) violatedchild
record found
Check ORA-02290: check constraint (schema.constraint) violated

Obtaining the Name of the Violated Constraint


You can use string functions, such as the following, to strip out the name of
the violated constraint from the Oracle Server error message.
FUNCTION strip_constraint_name (p_error_text in VARCHAR2)
RETURN VARCHAR2
IS
v_start_pos NUMBER(4);
v_end_pos NUMBER(4);
BEGIN
v_start_pos := INSTR(p_error_text, ., INSTR(p_error_text, ());
v_end_pos := INSTR(p_error_text, ), v_start_pos);
RETURN(SUBSTR(p_error_text, v_start_pos + 1,v_end_pos -
v_start_pos - 1));
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-5
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Customizing Oracle Server


Error Messages

Replacing declarative-constraint error messages:


Strip the constraint name from
DBMS_ERROR_TEXT or SQLERRM
Retrieve the customized message from
the messages table

Copyright Oracle Corporation, 2001. All rights reserved.

Customizing Oracle Server


Error Messages

Replacing database-trigger error messages:


Strip the application error messages from
DBMS_ERROR_TEXT or SQLERRM
Function STRIP_APPLICATION_ERROR
Replacing stored-program-unit error messages:
Same as for database triggers, except
SQLERRM only

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
A foreign-key constraint violation can have two causes: parent key not
found or child record found. Therefore, two error messages are
associated with one foreign-key constraint name.

......................................................................................................................................................
F-6 Oracle iDS Forms: Build Internet Applications II
Customizing Oracle Server Error Messages
......................................................................................................................................................

Customizing Oracle Server Error Messages


Replacing Error Messages Caused by Declarative-Constraint Violations
The error is reported in DBMS_ERROR_TEXT (implicit DML) or
SQLERRM (explicit DML). Once you have obtained the name of the
violated constraint from the Oracle server error message, you can use this
name to specify an appropriate customized message. A flexible approach for
this is to maintain a table of messages. You can then use the constraint name
to retrieve the corresponding message from this table.

Replacing Error Messages Caused by Database Triggers


The error is reported in DBMS_ERROR_TEXT (implicit DML) or
SQLERRM (explicit DML). The first part of the error message is the
message specified in RAISE_APPLICATION_ERROR in the database
trigger, which is already a customized message. You can strip out this
application-error message from the Oracle server error message by using the
following function:
FUNCTION strip_application_error (p_error_text in VARCHAR2)
RETURN VARCHAR2
IS
v_end_pos NUMBER(4);
BEGIN
v_end_pos := INSTR(p_error_text, ORA-, 5) - 2;
IF v_end_pos > 0 THEN
RETURN(SUBSTR(p_error_text, 12, v_end_pos - 11));
ELSE
RETURN(SUBSTR(p_error_text, 12));
END IF;
END;

Replacing Error Messages Caused by Stored Program Units


The error is reported in SQLERRM only. The customized message is
obtained in the same way as for database triggers.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-7
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Example Procedure for Handling


Oracle Server Errors

If the Oracle server error is a


declarative-constraint error:
Strip the constraint name from the
Oracle server error text.
Adjust the name of the foreign-key constraints.
Retrieve the message from the messages table.

Copyright Oracle Corporation, 2001. All rights reserved.

Example Procedure for Handling


Oracle Server Errors

If the Oracle server error is an application error:


Strip the application error from the Oracle
server error text.
Raise FORM_TRIGGER_FAILURE.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
F-8 Oracle iDS Forms: Build Internet Applications II
Example Procedure for Handling Oracle Server Errors
......................................................................................................................................................

Example Procedure for Handling Oracle Server Errors


PROCEDURE handle_server_error (p_server_error_code IN NUMBER,
p_server_error_text IN VARCHAR2)
IS
v_message_id VARCHAR2(255);
BEGIN -- handle_server_error
IF p_server_error_code IN (-1, -2290, -2291, -2292) THEN
/* PK/UK/FK/CK-constraint violation error. */
v_message_id := strip_constraint_name(p_server_error_text);
/* Foreign-key constraint has two associated error
messages.*/
IF p_server_error_code = -02291 THEN
/* Foreign-key violation - parent key not found. */
v_message_id := v_message_id || _PARENT;
ELSIF p_server_error_code = -02292 THEN
/* Foreign-key violation - child record found. */
v_message_id := v_message_id || _CHILD;
END IF;
MESSAGE(retrieve_message(v_message_id));
RAISE form_trigger_failure;
ELSIF p_server_error_code between -20999 and -20000 THEN
/* Application error caused by database trigger or stored
program unit. */
MESSAGE(strip_application_error(p_server_error_text));
RAISE form_trigger_failure;
END IF;
END handle_server_error;
Note: The STRIP_CONSTRAINT_NAME and
STRIP_APPLICATION_ERROR functions have already been shown earlier
in this lesson. The RETRIEVE_MESSAGE function retrieves a message
with a given ID from a messages table.
Call the HANDLE_SERVER_ERROR procedure from the appropriate
triggers and program units.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-9
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Example Procedure for Handling


Oracle Server Errors

Handle errors caused by implicit DML


On-Error trigger on form:
IF ERROR_TYPE = FRM AND
ERROR_CODE IN (40508, 40509, 40510) THEN
handle_server_error(DBMS_ERROR_CODE,
DBMS_ERROR_TEXT);
END IF;

Handle errors caused by explicit DML or


stored Program Units:
EXCEPTION
EXCEPTION
WHEN
WHEN OTHERS
OTHERS THEN
THEN
handle_server_error(SQLCODE,
handle_server_error(SQLCODE, SQLERRM);
SQLERRM);

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
Error code 40508 is insert failed. Error code 40509 is update failed. Error
code 40510 is delete failed.

......................................................................................................................................................
F-10 Oracle iDS Forms: Build Internet Applications II
Example Procedure for Handling Oracle Server Errors
......................................................................................................................................................

Handling Oracle Server Errors Caused by Implicit DML


Always define an On-Error trigger to handle Oracle server errors caused by
base table DML.

On-Error Trigger at Form Level


BEGIN
IF ERROR_TYPE = FRM AND ERROR_CODE IN (40508, 40509, 40510) THEN
handle_server_error(DBMS_ERROR_CODE,DBMS_ERROR_TEXT);
END IF;
/* Show default FRM-error message. */
MESSAGE(ERROR_TYPE || TO_CHAR(-ERROR_CODE) || : || ERROR_TEXT);
RAISE form_trigger_failure;
END;

Handling Oracle Server Errors Caused By Explicit DML or Stored


Program Unit Calls
Define a WHEN OTHERS exception handler in all triggers and program
units that execute explicit DML or call stored program units.
BEGIN
/* DML statements or calls to stored program units. */
EXCEPTION
WHEN others THEN
handle_server_error(SQLCODE, SQLERRM);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-11
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

Summary

In this lesson, you should have learned how to:


Replacing Oracle Server error messages with
customized messages
Constraint: strip constraint name and
retrieve message
DB triggers and stored program units:
strip application error

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
F-12 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
Handling Errors Raised by the Oracle Server
Causes: Declarative constraints, database triggers, stored program units
Trap implicit-DML errors by using DBMS_ERROR_CODE and
DBMS_ERROR_TEXT in an On-Error trigger
Trap explicit DML errors and stored program unit errors by using
SQLCODE and SQLERRM in a WHEN OTHERS exception handler

Replacing Oracle Server Error Messages with Customized Messages


Declarative constraint: Strip the constraint name from the Oracle Server
error message and retrieve the message from the messages table
Database triggers and stored program units: Strip the application error
message from the Oracle Server error message

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-13
Appendix F: Handling Server-SideErrors
......................................................................................................................................................

......................................................................................................................................................
F-14 Oracle iDS Forms: Build Internet Applications II
................................

EMP_PKG Package
Appendix G: EMP_PKG Package
......................................................................................................................................................

Package Specification
/*******************************************************/
/* This is an example of a stored procedure that: */
/* query, insert, update, delete, and lock rows of the */
/* EMP table. */
/* A package is used to logically group the related */
/* data types and procedures */
/*******************************************************/
PACKAGE emp_pkg AS

TYPE emprec IS RECORD(


--- Defines eack row of the table EMP
empno emp.empno%TYPE,
ename emp.ename%TYPE,
job emp.job%TYPE,
mgr emp.mgr%TYPE,
hiredate emp.hiredate%TYPE,
sal emp.sal%TYPE,
comm emp.comm%TYPE,
deptno emp.deptno%TYPE);

--- Defines each row of the table EMP.EMPNO


TYPE empnorec IS RECORD ( empno emp.empno%TYPE);

--- Define the Ref Cursor


TYPE empcur IS REF CURSOR RETURN emprec;

--- Defines the Table of Records EMP


TYPE emptab IS TABLE OF emprec INDEX BY BINARY_INTEGER;

--- Defines the Table of Records EMP.EMPNO


TYPE empnotab IS TABLE OF empnorec INDEX BY BINARY_INTEGER;

......................................................................................................................................................
G-2 Oracle iDS Forms: Build Internet Applications II
Package Specification
......................................................................................................................................................

--- Defines the procedures used for querying records


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

--- Defines the procedures used for DML operations


PROCEDURE empinsert (block_data IN emptab);
PROCEDURE empupdate (block_data IN emptab);
PROCEDURE empdelete (block_data IN empnotab);
PROCEDURE emplock (block_data IN empnotab);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-3
Appendix G: EMP_PKG Package
......................................................................................................................................................

Package Body
PACKAGE BODY emp_pkg AS
/**************************/
/* QUERY USING REF CURSOR */
/**************************/
PROCEDURE empquery_refcur( block_data IN OUT empcur,
p_deptno IN NUMBER)
IS
BEGIN
OPEN block_data FOR
SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno
FROM emp
WHERE deptno = NVL(p_deptno, deptno)
ORDER BY empno;
END;

. . .

......................................................................................................................................................
G-4 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................

/********************************/
/* QUERY USING TABLE OF RECORDS */
/********************************/
PROCEDURE empquery( block_data IN OUT emptab,
p_deptno IN NUMBER)
IS
i NUMBER;
CURSOR empselect IS
SELECT empno, ename, job, mgr, hiredate,
sal, comm, deptno
FROM emp
WHERE deptno = NVL(p_deptno, deptno)
ORDER BY empno;
BEGIN
OPEN empselect;
i := 1;
LOOP
FETCH empselect INTO block_data(i).empno,
block_data(i).ename,
block_data(i).job,
block_data(i).mgr,
block_data(i).hiredate,
block_data(i).sal,
block_data(i).comm,
block_data(i).deptno;
EXIT WHEN empselect%NOTFOUND;
i := i + 1;
END LOOP;
END;
. . .

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-5
Appendix G: EMP_PKG Package
......................................................................................................................................................

/**********/
/* INSERT */
/**********/
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, job, mgr,
hiredate, sal, comm, deptno)
VALUES( block_data(i).empno, block_data(i).ename,
block_data(i).job, block_data(i).mgr,
block_data(i).hiredate, block_data(i).sal,
block_data(i).comm, block_data(i).deptno);
END LOOP;
END;

. . .

......................................................................................................................................................
G-6 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................

/**********/
/* UPDATE */
/**********/
PROCEDURE empupdate(block_data IN emptab)
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
UPDATE emp
SET ename = block_data(i).ename,
job = block_data(i).job,
mgr = block_data(i).mgr,
hiredate = block_data(i).hiredate,
sal = block_data(i).sal,
comm = block_data(i).comm,
deptno = block_data(i).deptno
WHERE empno = block_data(i).empno;
END LOOP;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-7
Appendix G: EMP_PKG Package
......................................................................................................................................................

/**********/
/* DELETE */
/**********/
PROCEDURE empdelete(block_data IN empnotab)
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
DELETE FROM emp WHERE empno = block_data(i).empno;
END LOOP;
END;
/********/
/* LOCK */
/********/
PROCEDURE emplock(block_data IN empnotab)
IS
i NUMBER;
cnt NUMBER;
block_rec emprec;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
SELECT empno, ename, job, mgr,
hiredate, sal, comm, deptno
INTO block_rec
FROM emp
WHERE empno = block_data(i).empno
FOR UPDATE OF ename NOWAIT;
END LOOP;
END;
END;

......................................................................................................................................................
G-8 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................

To have an idea of how Form Builder works when a data block is based on a
stored procedure returning a REF CURSOR, you can run the following
script under Sql*Plus:
DECLARE
v_rec emp_pkg.emprec;
v_ref emp_pkg.empcur;
BEGIN
emp_pkg.emp_query_refcur(v_ref, 10);
LOOP
FETCH v_ref INTO v_rec;
EXIT WHEN v_ref%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_rec.empno);
DBMS_OUTPUT.PUT_LINE(v_rec.ename);
DBMS_OUTPUT.PUT_LINE(v_rec.job);
DBMS_OUTPUT.PUT_LINE(v_rec.mgr);
DBMS_OUTPUT.PUT_LINE(v_rec.hiredate);
DBMS_OUTPUT.PUT_LINE(v_rec.sal);
DBMS_OUTPUT.PUT_LINE(v_rec.comm);
DBMS_OUTPUT.PUT_LINE(v_rec.deptno);
END LOOP;
CLOSE v_ref;
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-9
Appendix G: EMP_PKG Package
......................................................................................................................................................

......................................................................................................................................................
G-10 Oracle iDS Forms: Build Internet Applications II
................................

Working with ActiveX


Controls
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Objectives

After completing this appendix, you should be able


to do the following:
Explain the differences between VBX, OCX,
and ActiveX controls
Access ActiveX properties at design time and
run time
Import ActiveX control methods and event
packages
Customize event handling

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................

Introduction
Overview
In this appendix, you will learn how to include and use ActiveX controls in
your Oracle Forms Developer application.

Objectives
After completing this lesson, you should be able to do the following:
Explain the differences between VBX, OCX, and ActiveX controls
Access ActiveX properties at design time and run time
Import ActiveX control methods and events packages
Customize event handling

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-3
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

What Are VBX, OCX and


ActiveX Controls?
VBX
Custom Interface Object
Special dynamic link library
OCX
Independent program module
Run in any Windows application that is
OLE-enabled
ActiveX
Third version of OCX
Provide integrated controls in Browsers

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-4 Oracle iDS Forms: Build Internet Applications II
What Are VBX, OCX, and ActiveX Controls?
......................................................................................................................................................

What Are VBX, OCX, and ActiveX Controls?


VBX, OCX, and ActiveX controls provide encapsulated functionality that
you can embed into your application.
Instead of one monolithic application that provides you with almost every
feature that you want, component objects and good integration can provide
you with a light-weight custom application to suit all your needs.
Word processor documents, spreadsheet documents, knob controls, and
video clips are examples of component objects that can enhance the
capabilities of your form. Instead of re-creating functionality that already
exists, you can access these capabilities by exploiting a VBX, an OCX, or an
ActiveX control.

What Is a VBX?
Short for Visual Basic custom control, a VBX is a reusable software
component designed for use in many different applications. While VBXs
can be used in other environments, they were initially created for developing
Windows applications with Visual Basic. An application developer can use a
number of selected VBXs to quickly develop an application.

What Is an OCX?
Short for OLE Custom control, an OCX is an independent program module
that can be accessed by other programs in a Windows environment. OCX
controls end with the .ocx extension. OCX controls represent Microsofts
second generation of control architecture, the first being VBX controls
written in Visual Basic.

What Is an ActiveX?
ActiveX controls are a superset of OLE Custom control (OCX). ActiveX is
an open platform that combines desktop and Web technologies. An ActiveX
control can be automatically downloaded and executed by a Web browser.
ActiveX is not a programming language, but rather a set of rules for how
applications should share information. Programmers can develop ActiveX
controls in a variety of languages, including C, C++, Visual Basic, and Java.
They represent Microsofts third generation of control architecture, the first
being VBX controls and the second OCX controls.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-5
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

VBX, OCX, and ActiveX Controls


Comparison

VBX OCX ActiveX


Controls Controls Controls

Operating 16-bit applications Both 16- and 32-bit


platform only platforms

Candidate Only those written Any application with an


applications with a specific OLE container type
interface to VBXs

Coding Proprietary Standard OLE2


interface

Web- No No Yes
enabled

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-6 Oracle iDS Forms: Build Internet Applications II
Comparison of VBX, OCX, and ActiveX Controls
......................................................................................................................................................

Comparison of VBX, OCX, and ActiveX Controls


A VBX is an extension of Microsoft Visual Basic and is designed to work
within applications written with a specific interface to VBXs. They are
16-bit-only controls designed to execute an event.
An OCX is an extension of Windows Open Architecture, so it is designed to
run in any Windows application that is OLE-enabled. OCX controls support
16- and 32-bit platforms, can execute events, and give the developer the
ability to code methods and properties.
ActiveX controls are the third version of OLE controls (OCX). This means
that all OCX controls are ActiveX controls. They provide a number of
enhancements specifically designed to facilitate distribution of components
over high-latency networks and to provide integration of controls into Web
browsers. You cannot, however, deploy ActiveX controls with Web forms.
The table below summarizes some of the differences among VBX controls,
OCX controls, and ActiveX controls.

VBX Controls OCX Controls ActiveX Controls


16-bit Both 16- and 32-bit Both 16- and 32-bit
Operating applications only platforms platforms
platform
Only those Any application with an Any application with an
written with a OLE container type OLE container type
Candidate specific interface
applications to VBXs
Proprietary Standard OLE2 Standard OLE2
Coding
interface
No No Yes
Web-enabled

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-7
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

ActiveX in Form Builder

ActiveX controls:
Dynamic library in .ocx files
Support events, properties, and methods
ActiveX control item:
Container for the ActiveX control
Single-record property set to Yes

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-8 Oracle iDS Forms: Build Internet Applications II
ActiveX in Form Builder
......................................................................................................................................................

ActiveX in Form Builder


What Are ActiveX Controls?
Form Builder provides support for ActiveX controls. ActiveX controls are
reusable components that you can embed in your Form Builder application.
Form Builder acts as an ActiveX control container.
ActiveX controls are a special type of dynamic library. A single ActiveX file
that is distributed with the .ocx extension can contain more than one class
of ActiveX objects.

ActiveX Control Components


Each ActiveX control exposes a set of:
Properties: Properties define the ActiveX controls physical and logical
attributes.
Methods: Methods define actions that the ActiveX control can perform.
Events: Events denote some change in status in the ActiveX control.
A client application manipulates an ActiveX control by writing values to
and obtaining values from its properties, invoking methods that are used to
perform actions, and intercepting and acting on events.

ActiveX Control Item


The ActiveX Control Item type creates a container for your ActiveX control.
An ActiveX control is not a separate application, but a server that plugs into
an ActiveX container.
It is recommended that you use ActiveX controls in blocks with the Single
Record property set to Yes. The Single Record property is not applicable to
multiple record blocks.You should set the Single Record property to Yes
because single records are immediately initialized when Forms run time
starts up. For multiple records, each record is not initialized until you
navigate to the record. Without initialization, the ActiveX Control Item is
empty, giving the impression that no ActiveX control is available.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-9
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Implementing an ActiveX Control in Form


Builder

1. Create an ActiveX Control Container.


2. Insert an ActiveX Control.
3. Import the desired ActiveX Control
methods and events.
4. Write the appropriate PL/SQL code.

Copyright Oracle Corporation, 2001. All rights reserved.

Creating an ActiveX
Control Item

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-10 Oracle iDS Forms: Build Internet Applications II
Implementing an ActiveX Control
......................................................................................................................................................

Implementing an ActiveX Control


Using an ActiveX Control in Form Builder
To use an ActiveX control in Form Builder:
1 Create an ActiveX control container.
2 Insert an ActiveX control.
3 Import the desired ActiveX control methods and events.
4 Write the appropriate PL/SQL codecalling property accessors,
invoking methods, or responding to eventsto interact with the
ActiveX control.

Creating an ActiveX Control Item


You can create an ActiveX control item by:
Converting an existing item into an ActiveX control item
Using the ActiveX control tool in the Layout Editor
Using Create Icon in the Object Navigator
Using the Data Block Wizard
To create an ActiveX control item in the Layout Editor:
1 Invoke the Layout Editor.
2 Click the ActiveX control tool.
3 Click the canvas.
The ActiveX control item is displayed.
4 Double-click the ActiveX control item.
The Properties Palette is displayed for the item.
5 Set the item properties as required.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-11
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Inserting an ActiveX Control

In the Layout Editor:


1. Select the ActiveX control item.
2. Click the right mouse button.
3. Select Insert Object
in the pop-up
menu.
4. Select a
control type.

Copyright Oracle Corporation, 2001. All rights reserved.

ActiveX Control Properties

Set the following


ActiveX Control
properties:

OLE
OLE Class
Class
Control
Control Properties
Properties
About
About Control
Control
Control
Control Help
Help

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
If you have created a container using the OCX button from the Layout
Editor, then Create Control is the only available option on the Insert Object
dialog box.

......................................................................................................................................................
H-12 Oracle iDS Forms: Build Internet Applications II
Inserting an ActiveX Control in an ActiveX Control Item
......................................................................................................................................................

Inserting an ActiveX Control in an ActiveX Control Item


Inserting an ActiveX Control
1 In the Layout Editor, select the ActiveX control item.
2 Click the right mouse button to enable the pop-up menu.
3 Select Insert Object.
4 In the Insert Object dialog box, click the Create Control option button to
display the valid control types.
5 Click a control type.
6 Click OK.

ActiveX Control Properties


Once the ActiveX control is inserted, you can set the following properties:

Property Name Description


OLE Class Determines what class of OLE objects can reside in an OLE
container. (You select a specific class if you want to create an
application that allows end users to change the current OLE object in
the OLE container, but want to restrict the end users to creating OLE
objects from a particular class.)
Control Properties Displays the specific properties for the current ActiveX control
About Control Displays information about the control (Please note that this feature
might not be exposed by the control that you are using.)
Control Help Displays online Help for the control (Please note that this feature
might not be exposed by the control that you are using.)

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-13
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Importing ActiveX Methods and Events


Packages

1 Select Program OLE Importer

2 6
- Program Units
+ PackageName1 (Spec)
3 + PackageName1 (Body)
+ ...
4 5

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-14 Oracle iDS Forms: Build Internet Applications II
Importing ActiveX Control Methods and Events Packages
......................................................................................................................................................

Importing ActiveX Control Methods and Events Packages


ActiveX controls export interfaces that expose methods and events. Form
Builder imports the methods and events in PL/SQL, enabling you to interact
with ActiveX controls in the native Form Builder environment.

Importing ActiveX Control Methods and Events


1 Select Program>OLE Importer...
The OLE Importer dialog box appears.
2 Select an OLE Class.
The methods and events packages appear for the selected OLE class.
3 Control-click on the desired methods and events packages.
4 Select the Methods check box to import the methods.
5 Select the Properties check box to import the get and set accessors for
properties.
6 Click OK.
In the Object Navigator, notice the newly created packages under the
Program Units node.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-15
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Interacting with an ActiveX Control

You can interact for:


Setting and getting ActiveX control properties
Invoking ActiveX control methods
Responding to ActiveX control events

Copyright Oracle Corporation, 2001. All rights reserved.

Setting and Getting ActiveX Control


Properties

Three methods:
Bind variable Syntax

:Item(item_name).OCX.server_name.property
:Item( item_name).OCX.server_name.property

Example

:item(ActXitem).OCX.Spindial.spindialctrl
:item( ActXitem).OCX.Spindial.spindialctrl
.1.Needleposition:=:item(ActXitem).OCX.
.1.Needleposition:=:item(ActXitem).OCX.
Spindial.spindialctrl.1.Needleposition
Spindial.spindialctrl.1.Needleposition
++ 1;
1;

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-16 Oracle iDS Forms: Build Internet Applications II
Setting and Getting ActiveX Control Properties
......................................................................................................................................................

Setting and Getting ActiveX Control Properties


Once the ActiveX control is inserted and the methods and events packages
are imported, you can interact with ActiveX controls in many ways:
Setting and getting ActiveX control properties
Invoking ActiveX control methods
Responding to ActiveX control events
There are several ways to set and get ActiveX properties values.

Bind Variable Syntax


You can use the bind variable syntax to assign or retrieve property values.
:item(item_name).ocx.server_name.property
Server_name represents the name of the server. This name is the one you
have selected for the OLE Class property. Property is the name of a specific
property of the ActiveX control. To obtain more information, see the Control
Help property, if available, or the documentation.
/* Setting an ActiveX control property using bind variable
syntax */
:item(ActXitem).OCX.Spindial.spindialctrl.1.Needleposition
:=
:item(ActXitem).OCX.Spindial.spindialctrl.1.Needleposition +1;
/* ActXitem is the name of the item,
Spindial.spindialctrl.1 is the name of the ActiveX
control server, and Needleposition is the name of the
property. */
/* The following code also works if your system.cursor_item
is an ActiveX control: */
:form.cursor_item.OCX.spindial.spindialctrl.1.Needlposition :=
:form.cursor_item.OCX.spindial.spindialctrl.1.Needlposition + 1;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-17
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Setting and Getting ActiveX Control


Properties

Property accessors (PL/SQL procedures)

tblname varchar2;
tblname := table_pkg.TableName(
:item(Oblk.Oitm).interface);

Copyright Oracle Corporation, 2001. All rights reserved.

Setting and Getting ActiveX Control


Properties

Control properties dialog box


Displays ActiveX-specific
properties
See Control
Help property
or
documentation

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-18 Oracle iDS Forms: Build Internet Applications II
Setting and Getting ActiveX Control Properties
......................................................................................................................................................

Property Accessors (PL/SQL Procedures)


You can set and get property values with the program units, called property
accessor functions and property accessor procedures, generated from the
OLE Importer. Use the property accessor functions to get a property value,
and use the property accessor procedures to set a property value.
/* Getting an ActiveX control property using get accessor*/
tblname varchar2;
tblname := table_pkg.TableName(:item(Oblk.Oitm).interface);
/* table_pkg is the name of the program unit created from
the OLE Importer. TableName is the name of the property
accessor. Oblk is the name of the block and Oitm is the
name of the item.*/

Control Properties Dialog Box from the Property Palette


1 In the Object Navigator, double-click the object icon next to the ActiveX
control item to display the Property Palette.
2 Click the Control Properties property.
The Control Properties dialog box appears.
3 Set the control properties accordingly.
4 Click OK.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-19
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Invoking ActiveX Control Methods

MMVX_DMMVX.PLAY(:item
MMVX_DMMVX.PLAY(:item
((video_ocx.video
video_ocx.video).INTERFACE);
).INTERFACE);

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-20 Oracle iDS Forms: Build Internet Applications II
Invoking ActiveX Control Methods
......................................................................................................................................................

Invoking ActiveX Control Methods


Methods define actions that the ActiveX control can perform.

How to Invoke a Method


You can access methods exposed by an ActiveX control with the program
units generated from the OLE Importer. Call any of the methods in any of
the packages available under the Program Units node. To obtain information
on a specific method of an ActiveX control, see the documentation of this
ActiveX control or, if available, the Control Help property.

Example
/* Getting a cell value from a Spread Table ActiveX control
using the GetCellByColRow method provided in the
SpreadTable package */
DECLARE
Cur_Row number;
Cur_Col number;
OLEObj OleObj;
BEGIN
Cur_Row:=SpreadTable.CurrentRow(:ITEM(BLK.ITM).interface);
Cur_Col:=SpreadTable.CurrentCol(:ITEM(BLK.ITM).interface);
OLEObj:=SpreadTable.GetCellByColRow(:ITEM(BLK.ITM).interface,
Cur_Col, Cur_Row);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-21
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Responding to ActiveX Control Events

Two ways to deal with events:


Directly call the appropriate restricted procedure.

PROCEDURE /*Click*/ event4294966696


(interface OleObj);
BEGIN
/* Write your code here */
END;

Code the On-Dispatch-Event trigger.

Copyright Oracle Corporation, 2001. All rights reserved.

Responding to ActiveX Control Events

All event procedures are restricted.


To run in unrestricted mode, use:

FORMS4W.DISPATCH_EVENT
(RESTRICTED_UNALLOWED);

Initialization events do not fire.


Use the When-New-Item-Instance or
When-New-Record-Instance triggers in place.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-22 Oracle iDS Forms: Build Internet Applications II
Responding to ActiveX Control Events
......................................................................................................................................................

Responding to ActiveX Control Events


ActiveX controls invoke events. Form Builder exposes these events in the
events package created from the OLE Importer. The events are defined by
the ActiveX control. Each event is associated with a PL/SQL procedure
defined in the events package. The procedures are named according to an
internal numeric representation as defined by the control. When the control
fires an event, the code in the procedure is automatically executed. You are
responsible for providing the code to respond to the event. Type directly into
the event package body and compile the package. The restricted procedure
produced by an event has an application programming interface similar to
the following:
PROCEDURE /*Click*/ event4294966696(interface OleObj);
Another way to deal with the event is to add code to the On-Dispatch-Event
trigger.

Restricted or Unrestricted Mode


All event procedures are restricted; that is, go_item cannot be called from
within the procedure code. However, there are instances when the same
event may apply to multiple items and a go_item is necessary; this is the
unrestricted case.
In the unrestricted case, you need to do the following: In the On-Dispatch-
Event Trigger (block or form level), call:
FORMS4W.DISPATCH_EVENT(RESTRICTED_ALLOWED);
FORMS4W.DISPATCH_EVENT(RESTRICTED_UNALLOWED);
There is no need to explicitly call the event procedure because it will
automatically be called following the On-Dispatch trigger code.

Initialization Events
Initialization events for ActiveX controls do not fire in Forms run time.
These initialization events are intentionally disabled. Instead, you can use
When-New-Item-Instance or When-New-Record-Instance triggers in place
of the controls native initialization events.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-23
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Handling Exceptions

When a failure occurs,


the FORMS_OLE_FAILURE is raised.
Use LAST_OLE_EXCEPTION built-in
to get more detailed information.

. . .
WHEN FORMS_OLE_FAILURE THEN
ExceptNum :=LAST_OLE_EXCEPTION(errScr,
errDescription, errHelpfile,
errHelpContext);
. . .

Copyright Oracle Corporation, 2001. All rights reserved.

Technical Note
The LAST_OLE_EXCEPTION built-in takes variables, not constants.

......................................................................................................................................................
H-24 Oracle iDS Forms: Build Internet Applications II
Handling Exceptions
......................................................................................................................................................

Handling Exceptions
FORMS_OLE_FAILURE Exception
When a failure is detected in handling an ActiveX control method, an FRM
message appears or the FORMS_OLE_FAILURE exception is raised. When
a FORMS_OLE_FAILURE exception is raised, you can get more detailed
information regarding the cause of the exception by calling the
LAST_OLE_EXCEPTION built-in.
/*
Handling the exception raised as a result of calling:
Var_To_Number(To_Variant(Jane));
An exception is raised because Jane is not a number.
*/
DECLARE
errCode PLS_INTEGER;
errSrc VARCHAR2(200);
errDescription VARCHAR2(2000);
errHelpfile VARCHAR2(200);
errHelpContext PLS_INTEGER;

BEGIN
. . .
WHEN form_ole_failure THEN
errCode := LAST_OLE_EXCEPTION(errSrc,
errDescription,
errHelpfile,
errHelpContext);
-- Inform the user of the problem
MESSAGE(errSrc||;||errDescription);
END;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-25
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Registering an ActiveX Control

Two methods to register:


Implicitly register using the installation
program.
Use regsvr32.exe explicitly.
ActiveX controls require supporting DLL:
Must be in \Windows\System or search path
Reregister the ActiveX control if you move it
or rename its directory.

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-26 Oracle iDS Forms: Build Internet Applications II
Registering an ActiveX Control
......................................................................................................................................................

Registering an ActiveX Control


You must register all ActiveX controls. If you install an ActiveX control by
using the installation program supplied with the ActiveX control, the
registration is most likely taken care of by the installation program. For
manual registration of ActiveX controls, use regsvr32.exe; this
program is available with Microsoft development tools and from ActiveX
control vendors.

Supporting Files
Most ActiveX controls require a supporting DLL, such as the Microsoft
Foundation Class run-time library, mfc40.dll. The DLL must be in the
\WINDOWS\SYSTEM directory or in the search path. If the DLL is out of
date or missing, your ActiveX control will not register properly. Most
reputable ActiveX control suppliers provide documentation regarding the
version and name of the DLLs required; some even supply and install them
along with the ActiveX controls.

Moving ActiveX Control Files


At installation, the directories in which the ActiveX control is installed are
registered in the Windows Registration Database in Windows 95 and
Windows NT, making the ActiveX control visible to your development
environment. If you move the ActiveX control to a different directory, or
rename the directory, the information in the registry is no longer valid. If
you must move the ActiveX control or rename its directory, use the
regsrv32.exe or regActiveX.exe utilities provided with most
Microsoft development products to reregister the ActiveX in its new
location.

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-27
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
.

Summary

VBX, OCX, and ActiveX controls


Differences between controls
ActiveX control in Form Builder
Create an ActiveX control container
Set and get ActiveX control properties
Invoke ActiveX control methods
Respond to ActiveX control events
Register an ActiveX control

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
H-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................

Summary
In this lesson, you saw how to include and use ActiveX controls in your
Oracle Developer application.
VBX, OCX, and ActiveX controls
Differences between controls
ActiveX control in Form Builder
Create an ActiveX control
Set and get ActiveX control properties
Invoke ActiveX control methods
Respond to ActiveX control events
Register an ActiveX control

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-29
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

......................................................................................................................................................
H-30 Oracle iDS Forms: Build Internet Applications II
................................

Using Oracle Server Roles


at Run Time
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................

Oracle Server Views for Roles

SESSION_ROLES
ROLE_ROLE_PRIVS
ROLE_SYS_PRIVS
ROLE_TAB_PRIVS

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
I-2 Oracle iDS Forms: Build Internet Applications II
Using Oracle Server Roles at Run Time
......................................................................................................................................................

Using Oracle Server Roles at Run Time


Overview
You can manipulate roles dynamically at run time by using Forms. For
example, you can select views from the data dictionary to get information
about existing roles. Subprograms belonging to the DBMS_SESSION
package enable you to modify the roles that are used by the menu module to
enforce security.

SESSION_ROLES View
Roles that the user currently has enabled
Column Description
ROLE Name of the role

ROLE_ROLE_PRIVS View
Information about roles granted to other roles
Column Description
ROLE Name of the role
GRANTED_ROLE Role that was granted
ADMIN_OPTION Subprogram that signifies that the role was granted with the ADMIN
option

ROLE_SYS_PRIVS View
Information about system privileges granted to roles
Column Description
ROLE Name of the role
PRIVILEGES System privileges granted to the role
ADMIN_OPTION Column that signifies the grant was with the ADMIN option

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-3
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................

Oracle Server Views for Roles

SESSION_ROLES
ROLE_ROLE_PRIVS
ROLE_SYS_PRIVS
ROLE_TAB_PRIVS

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
I-4 Oracle iDS Forms: Build Internet Applications II
Using Oracle Server Roles at Run Time
......................................................................................................................................................

ROLE_TAB_PRIVS View
Information about table privileges granted to roles.
Column Description
ROLE Name of the role
OWNER Owner of the object
TABLE_NAME Name of the object
COLUMN_NAME Name of the column, if applicable
PRIVILEGE Object privilege granted to the role
GRANTABLE YES if the role was granted with the ADMIN option, otherwise NO

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-5
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................

Procedures for Managing Roles

DBMS_SESSION.SET_ROLE
DBMS_SESSION.IS_ROLE_ENABLED

Copyright Oracle Corporation, 2001. All rights reserved.

......................................................................................................................................................
I-6 Oracle iDS Forms: Build Internet Applications II
Procedures for Managing Roles
......................................................................................................................................................

Procedures for Managing Roles


Package Description
DBMS_SESSION DBMS_SESSION is a standard
package that comprises many
subroutines. Two of them are used
to manage menu module roles
dynamically.
DBMS_SESSION.SET_ROLE (RoleName) This package is used to assign a
particular role to the current user.
DBMS_SESSION.IS_ROLE_ENABLED (RoleName)

Example
The following Pre-Form trigger uses the DBMS_SESSION package to test a
users role before allowing access to the application.
IF not (DBMS_SESSION.IS_ROLE_ENABLED(ADMINISTRATIVE) or
(DBMS_SESSION.IS_ROLE_ENABLED(TECHNICAL)
THEN
MESSAGE(You are not authorized to run this application);
PAUSE;
RAISE form_trigger_failure;
END IF;

......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-7
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................

......................................................................................................................................................
I-8 Oracle iDS Forms: Build Internet Applications II

Вам также может понравиться