Sunteți pe pagina 1din 264

Oracle Developer:

Build Forms II

Volume 2 • Instructor Guide

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

44112GC10
Production 1.0
May 1999
M08752
Author Copyright  Oracle Corporation, 1999. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It is


Mark Sullivan
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
Louise Barnfield 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 Boehrs
252.227-7013, Rights in Technical Data and Computer Software (October 1988).
Jacquelyn Bruce
This material or any portion of it may not be copied in any form or by any means
Phyllis Chan without the express prior written permission of the Worldwide Education Services
Bulent Cinarkaya group of Oracle Corporation. Any other copying is a violation of copyright law and
Laurent Dereac may result in civil and/or criminal penalties.

Mark Doran If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Rights,” as defined in
Gillian Elias
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Tushar Gadhia
The information in this document is subject to change without notice. If you find
Stephen Gramann any problems in the documentation, please report them in writing to Education
Nancy Greenberg Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Ursula Hovy Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Uwe Jentzsch
Oracle Developer, Oracle Server, and PL/SQL are trademarks or registered
Leta A. Johnson
trademarks of Oracle Corporation.
Jan Keuben
All other products or company names are used for identification purposes only,
Steve Lirette and may be trademarks of their respective owners.
Jayne Marlow
Rita Morin
Daphne Nougier
Christin Nowakowski
Bryan Roberts
Bert Salyga
Helene Schwann
Hiroyuki Sugiyama
Pal Tarcsay
Bart Van der Laar
Jack Walsh

Publisher
Kelly Lee
Sherry Polm
Contents
.....................................................................................................................................................

Preface
Profile xv
Related Publications xvi
Typographic Conventions xvii

Lesson 1: Managing Projects with Project Builder


Introduction 1-3
Introducing Project Builder 1-5
Project Builder Terminology 1-7
Project Builder Benefits 1-9
Project Builder User Interface 1-11
Project Builder User Interface 1-13
Creating Projects and Subprojects 1-15
Adding Project Files 1-17
Subdirectories Added as Subprojects 1-19
Creating Connections 1-21
Working with Project Files 1-23
Establishing Dependencies 1-25
Building Projects 1-27
Delivering Projects 1-29
Summary 1-33
Practice Session Overview: Lesson 1 1-35
Practice 1 1-36

Lesson 2: Creating a Menu Module


Introduction 2-3
Components of the Menu Module 2-5
The Default Menu 2-7
The Menu Editor 2-9
Creating a Menu Module 2-11
Module Properties 2-13
Menu Properties 2-15
Menu Item Properties 2-17
Menu Item Types 2-19

.....................................................................................................................................................
Oracle Developer: Build Forms II iii
Contents
.....................................................................................................................................................

Menu Item Command Types 2-21


Implementing Menu Toolbars 2-23
Storing the Menu Module 2-25
Attaching the Menu Module 2-27
Pop-up Menus 2-29
Summary 2-31
Practice Session Overview: Lesson 2 2-33
Practice 2 2-34

Lesson 3: Managing Menu Modules


Introduction 3-3
Using PL/SQL in Menu Item Code 3-5
Useful Built-in Menu Subprograms 3-7
Showing and Hiding the Current Menu 3-9
Managing Menu Security 3-11
Defining Security Roles 3-13
Assigning Access to Menu Items 3-15
Summary 3-17
Practice Session Overview: Lesson 3 3-19
Practice 3 3-20

Lesson 4: Programming Function Keys


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

.....................................................................................................................................................
iv Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................

Lesson 5: Responding to Mouse Events


Introduction 5-3
What Are Mouse Events? 5-5
Responding to Mouse Movement 5-7
Responding to Mouse Button Actions 5-11
Summary 5-17
Practice Session Overview: Lesson 5 5-19
Practice 5 5-20

Lesson 6: Controlling Windows and Canvases Programmatically


Introduction 6-3
Using Window-Interaction Triggers 6-5
Built-ins for Manipulating Windows 6-7
Built-ins for Manipulating Canvases 6-9
Working with Tab-Style Canvases 6-11
Windows and Blocks 6-15
Manipulating Window Properties Programmatically 6-17
Showing Multiple Windows 6-19
Closing Windows 6-21
Blocks with Many Items 6-23
Summary 6-25
Practice Session Overview: Lesson 6 6-27
Practice 6 6-28

Lesson 7: Defining Data Sources


Introduction 7-3
Data Source Types 7-5
Basing a Data Block on a FROM Clause Query 7-7
Basing a Data Block on a Stored Procedure 7-9
Example of a Query Using a REF Cursor Procedure 7-11
Example of Query Using a Table of Records Procedure 7-13
Example of DML Using a Stored Procedure 7-15
Deciding Whether to Use a REF Cursor or a Table
of Records 7-17

.....................................................................................................................................................
Oracle Developer: Build Forms II v
Contents
.....................................................................................................................................................

Data Block Wizard 7-19


Data Block Properties 7-21
Data Source Guidelines 7-23
Summary 7-27
Practice Session Overview: Lesson 7 7-29
Practice 7 7-30

Lesson 8: Working with Oracle8 Objects in Form Builder


Introduction 8-3
What Are Object Types? 8-5
Review of Objects 8-7
Object REFs 8-9
Supported Oracle8 Features 8-11
How Oracle Developer Treats Objects 8-13
Object Type Displays 8-15
Creating Data Blocks Based on Oracle8 Objects 8-17
Selecting Object Table Columns 8-19
Selecting Object Column Attributes 8-21
Blocks with REF Lookups 8-23
The REF Column Value 8-25
LOVs for REFs 8-27
Summary 8-29
Practice Session Overview: Lesson 8 8-31
Practice 8 8-32

Lesson 9: Controlling Data Block Relationships


Introduction 9-3
Creating a Relation 9-5
Block Coordination 9-7
Coordinate Blocks Using REFs 9-9
Characteristics of Relation-Handling Triggers 9-11
Principles of Relation-Handling Code 9-13
Obtaining Relation-Handling Information 9-15
Implementing a Coordination-Type Toggle 9-17

.....................................................................................................................................................
vi Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................

Forcing a Commit Per Master 9-19


Summary 9-21
Practice Session Overview: Lesson 9 9-23
Practice 9 9-24

Lesson 10: Building Multiple Form Applications


Introduction 10-3
OPEN_FORM to Invoke Additional Forms 10-5
Closing Forms 10-7
Navigating Between Forms 10-9
Transaction Processing for Opened Forms 10-11
CALL_FORM to Invoke Additional Forms 10-13
Transaction Processing for Called Forms 10-15
NEW_FORM to Invoke Additional Forms 10-19
Controlling Open Forms and Called Forms Together 10-21
Different Ways of Invoking Forms 10-23
Using Form Parameters 10-25
Parameter Lists 10-29
Creating and Manipulating Parameter Lists 10-31
Passing Data Between Forms 10-33
Summary 10-35
Practice Session Overview: Lesson 10 10-37
Practice 10 10-38

Lesson 11: Working with Record Groups


Introduction 11-3
Record Groups 11-5
Using Record Groups 11-7
Defining Record Groups at Design Time 11-9
Built-in Functions for Controlling Record Groups 11-11
Defining Query Record Groups Programmatically 11-17
Defining Nonquery Record Groups Programmatically 11-19
Manipulating Record Group Rows 11-21
Manipulating Selected Record Group Rows 11-23

.....................................................................................................................................................
Oracle Developer: Build Forms II vii
Contents
.....................................................................................................................................................

Defining Global Record Groups 11-25


Manipulating List Items Programmatically 11-27
Implementing Dynamic List Items 11-29
Adding Values to Combo Boxes 11-31
Summary 11-33
Practice Session Overview: Lesson 11 11-35
Practice 11 11-36

Lesson 12: Including Charts and Reports


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

Lesson 13: Applying Timers


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

Lesson 14: Using Server Features in Form Builder


Introduction 14-3
Using Oracle Server Functionality in Forms 14-5
Dealing with PL/SQL Code 14-7

.....................................................................................................................................................
viii Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................

PL/SQL8 Support 14-9


New PL/SQL8 Scalar Data Types 14-11
Unsupported Client-Side PL/SQL8 Features 14-13
Handling Errors Raised by the Oracle Server 14-15
Performing DDL with FORMS_DDL 14-19
Using FORMS_DDL 14-21
Summary 14-23
Practice Session Overview: Lesson 14 14-25
Practice 14 14-26

Lesson 15: Using Reusable Components


Introduction 15-3
Reusable Components 15-5
Reusable Components List 15-7
The Calendar Class 15-11
Calendar Object Group Content 15-13
Built-in for Manipulating the Calendar 15-15
Summary 15-17
Practice Session Overview: Lesson 15 15-19
Practice 15 15-20

Appendix A: Practice Solutions


Practice 1 Solutions A-2
Practice 2 Solutions A-5
Practice 3 Solutions A-9
Practice 4 Solutions A-12
Practice 5 Solutions A-16
Practice 6 Solutions A-18
Practice 7 Solutions A-21
Practice 8 Solutions A-25
Practice 9 Solutions A-29
Practice 10 Solutions A-34
Practice 11 Solutions A-36
Practice 12 Solutions A-42

.....................................................................................................................................................
Oracle Developer: Build Forms II ix
Contents
.....................................................................................................................................................

Practice 13 Solutions A-45


Practice 14 Solutions A-49
Practice 15 Solutions A-55

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
Oracle8 objects: types, tables B-24

Appendix C: Project Builder Addendum


Introduction C-3
Team Development with Project Builder C-5
Generating and Printing Project Reports C-11
Defining New Module Types C-13
Identifying New Module Types C-15
Describing New Module Types C-17
Actions for New Module Types C-19
An Icon for New Module Types C-21
Modifying Types Using Actions C-23
Customizing Actions by Using Macros C-25
Customizing the Launcher C-29
Inheritance in Project Builder C-31
Actions C-33

.....................................................................................................................................................
x Oracle Developer: Build Forms II
Contents
.....................................................................................................................................................

Summary C-35

Appendix D: Introduction to Oracle8 Object Features


Introduction D-3
New Oracle8 Data Types D-5
Object Types D-7
Creating Oracle8 Objects D-11
Object Columns D-13
Object Views D-15
INSTEAD-OF Triggers D-17
Referencing Objects D-19
Displaying Oracle8 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

.....................................................................................................................................................
Oracle Developer: Build Forms II xi
Contents
.....................................................................................................................................................

What Are VBX, OCX, and ActiveX Controls? H-5


Comparison of VBX, OCX, and ActiveX Controls H-7
ActiveX in Form Builder H-9
Implementing an ActiveX Control H-11
Inserting an ActiveX Control in an ActiveX Control Item H-13
Importing ActiveX Control Methods and Events Packages H-15
Setting and Getting ActiveX Control Properties H-17
Invoking ActiveX Control Methods H-21
Responding to ActiveX Control Events H-23
Handling Exceptions H-25
Registering an ActiveX Control H-27
Summary H-29

Appendix I: Using Oracle Server Roles at Run Time


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

Appendix J: Instructor Note


Introduction J-2
How the Project Is Organized J-3
Project Setup J-4
Launching the Files J-8

.....................................................................................................................................................
xii Oracle Developer: Build Forms II
A
................................

Practice Solutions
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 1 Solutions
1 Create a connection to the database.
Create a new connection.
a
File––>New––>Connection
b Name the connection SUMMIT and specify the connect string. Your
instructor should provide this information.
Enter the title, username, password, and database.
2 Create an initial project.
a Create a new project (use the Project Wizard).
Tools––>Project Wizard
b Name the project “Oracle Developer: Build Forms II”. Assign to this
project the connection created earlier, and save it as summit.upd in
the Lab directory. Do not add files to this project.
Enter a Project Registry Filename of summit.upd in the Lab
subdirectory and click Next. Enter a Title of Oracle Developer:
Build Forms II. Enter a Project Directory of the Lab
subdirectory and click Next. Select Summit as the Pre-Defined
Connection and click Next. Click Next to skip the Author and
Comments fields. Select “Create an empty project” and click
Finish.
3 Create a subproject and add files to it.
a Using the Project Wizard, create a subproject named Summit
Application that belongs to Oracle Developer: Build Forms II.
Select the project node in the Project Navigator. Select Tools
––>Project Wizard in the main menu. Select “Create a sub-
project under an existing project” and click Next. Click Next to
accept Oracle Developer: Build Forms II as the Parent Project.
Enter Summit Application as the Title. Enter the Lab
subdirectory as the Project Directory and click Next. Select
Summit as the Pre-Defined Connection and click Next. Click
Next to skip the Author and Comments fields.
b From the labs directory, add:
- baseball.tif
- calendar.pll
- copy.ico

......................................................................................................................................................
A-2 Developer/2000: Build Forms II
Practice 1 Solutions
......................................................................................................................................................

-
customers.fmb
-
Form_Builder_II.olb
-
pr11_2f.txt
-
pr7_3a.sql
Click Finish to accept “Select files to add to a project.” The “Add
Files to Project” dialog box appears. Select the files and press
Enter.
c Give a file items a more meaningful title.
In the Project Navigator, select the pr11_2f.txt file and change
the name of its entry to Delete Record Group Script. Examine
the Property Palette for the item and note that the Filename
property has not changes.
4 Explore the Project Navigator.
a Examine the state of the Project Navigator. Note that Project Builder
has added executable versions of the Oracle source files that you
added to the project.
There is no formal solution.
b Turn off the Show Implicit Items option. Note what happens to the
Project Navigator display.
Select Tools––>Preferences––>Navigator and clear the Show
Implied Items check box.
c Experiment with Project Builder’s different views.
Select the different views under the Navigator menu.
5 Deliver the project.
a Invoke the Delivery Wizard and deliver all files.
Select Tools––>Deliver Wizard from the main menu. Select the
name of the project from the list, select the “Deliver all files”
option, and click the Next button.
b Create Oracle Installer scripts on your local file system.
Select the “Deliver locally and create Oracle Installer scripts”
option, enter the destination subdirectory, and click on the Next
button. Name the Script Summit_Install, and use the Summit
program group. Do not ship the Oracle Developer Runtime
environment with the installation. Click the Next button to
continue.

......................................................................................................................................................
Developer/2000: Build Forms II A-3
Appendix A: Practice Solutions
......................................................................................................................................................

cInclude all the deliverable files in the project.


Click the Next button to accept the default list of files.
d Accept the default delivery directories.
Click the Next button to accept the default delivery directories.
e Do not set any environmental variables upon installation.
Click the Next button to continue.
f Verify the settings, and finish the delivery.
Click the Finish button.
If you have time...
6 Create a subproject from a subdirectory and add files to it.
Using the Project Wizard, create a subproject named Lab_Sol that
belongs to Oracle Developer: Build Forms II . Automatically include all
files in that subdirectory.
In the Project Navigator, select the name of the project that you just
created. From the menu, select Project––> Add Directory to Project.
Select the Lab_Sol subdirectory and click the OK button.

......................................................................................................................................................
A-4 Developer/2000: Build Forms II
Practice 2 Solutions
......................................................................................................................................................

Practice 2 Solutions
1 Create a new menu module.
a Using the following screenshot as a guideline, create a new menu
module called M_SUMMIT.

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. Set the properties as follows:

......................................................................................................................................................
Developer/2000: Build Forms II A-5
Appendix A: Practice Solutions
......................................................................................................................................................

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

......................................................................................................................................................
A-6 Developer/2000: Build Forms II
Practice 2 Solutions
......................................................................................................................................................

Visible in
Menu Magic Command Visible Horiz. Menu Icon
Label Item Type Item Type in Menu Toolbar Filename
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’ ) ;

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:

......................................................................................................................................................
Developer/2000: Build Forms II A-7
Appendix A: Practice Solutions
......................................................................................................................................................

• 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.
e Run and test the ORDERS form.
2 Add pop-up menus to the CUSTOMERS form.
a Open the CUSTOMERS form module.
b Copy the EDIT_MENU menu from the M_SUMMIT menu module to the
CUSTOMERS form. Attach this pop-up menu to the Comments item.
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.

......................................................................................................................................................
A-8 Developer/2000: Build Forms II
Practice 3 Solutions
......................................................................................................................................................

Practice 3 Solutions
1 Define a check menu item.
a Open the M_SUMMIT menu module and create a new menu item to
the right of Query and rename it Image.
See previous solution.
b Create a new menu item under Image and name it Image Activate.
See previous solution.
Set the properties as follows:

Menu Label Menu Item Type Command Type


Image Activate Check PL/SQL

c Import the text for the Image Activate menu item by using the
pr3_1c.txt file. The menu item name must be
IMAGE_ACTIVATE.
In the PL/SQL Editor, select File->Import Text. Import the
H:\Lab\pr3_1c.txt file.
DECLARE
product_image_id ITEM := FIND_ITEM(’s_item.product_image’ );
image_description_id ITEM := FIND_ITEM(’s_item.image_description’);
image_button_id ITEM := FIND_ITEM(’control.image_button’ );
BEGIN
IF GET_ITEM_PROPERTY(product_image_id,displayed) = ’TRUE’ THEN
SET_ITEM_PROPERTY( product_image_id, DISPLAYED,
PROPERTY_FALSE);
SET_ITEM_PROPERTY( image_description_id, DISPLAYED,
PROPERTY_FALSE );
SET_ITEM_PROPERTY( image_button_id, LABEL, ’Image On’);
SET_MENU_ITEM_PROPERTY( ’image_menu.image_activate’, CHECKED,
PROPERTY_FALSE );
ELSE
SET_ITEM_PROPERTY(product_image_id, DISPLAYED, PROPERTY_TRUE );
SET_ITEM_PROPERTY(image_description_id, DISPLAYED,
PROPERTY_TRUE );
SET_ITEM_PROPERTY(image_button_id, LABEL, ’Image Off’);
SET_MENU_ITEM_PROPERTY(’image_menu.image_activate’, CHECKED,
PROPERTY_TRUE );
END IF;

......................................................................................................................................................
Developer/2000: Build Forms II A-9
Appendix A: Practice Solutions
......................................................................................................................................................

END;

Save and compile the menu module.


d
e Run and test the ORDERS form.
2 Synchronize the menu module with the form.
a Write startup code for the M_SUMMIT menu module that
synchronizes the Image Activate menu item with the Image button.
You can import the pr3_2a.txt file.
Use the Startup Code menu module property to invoke the PL/SQL Editor.
IF GET_ITEM_PROPERTY(’CONTROL.IMAGE_BUTTON’, LABEL) =’Image Off’
THEN
SET_MENU_ITEM_PROPERTY(’IMAGE_MENU.IMAGE_ACTIVATE’, CHECKED,
PROPERTY_TRUE );
END IF;

Save and compile your module.


b
3 The menu items Sort By and Image are not relevant to the
CUSTOMERS form and therefore should have no effect.
a Attach the menu module to the CUSTOMERS form.
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 disable
these options when the CUSTOMERS form is opened. You can
replace the exisiting code with the code from the pr3_3b.txt
file. You may need to change the code to conform to the exact names
you gave to the Main Menu and its menu items.
Remove the existing code and replace with the following code.
Use the SYSTEM.CURRENT_FORM variable to get the name
of the current form, and use the
SET_MENU_ITEM_PROPERTY built-in procedure to disable
these options.
IF :SYSTEM.CURRENT_FORM = 'CUSTOMERS'
THEN
SET_MENU_ITEM_PROPERTY('MAIN_MENU.SORT_BY', ENABLED,
PROPERTY_FALSE);
SET_MENU_ITEM_PROPERTY('MAIN_MENU.IMAGE', ENABLED, PROPERTY_FALSE);
ELSIF GET_ITEM_PROPERTY('CONTROL.IMAGE_BUTTON', LABEL) ='Image Off'

......................................................................................................................................................
A-10 Developer/2000: Build Forms II
Practice 3 Solutions
......................................................................................................................................................

THEN
SET_MENU_ITEM_PROPERTY(’IMAGE_MENU.IMAGE_ACTIVATE’, CHECKED,
PROPERTY_TRUE );
END IF;
c Save and compile the module.
d Run the CUSTOMERS form and test your application.Execute a
Query and click the Orders button to move to the ORDERS form.
Note that the Sort By and Image menu items are disabled when the
CUSTOMERS form is current, and that they are enabled when the
ORDERS form is current.

......................................................................................................................................................
Developer/2000: Build Forms II A-11
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 4 Solutions
1 Create and modify a key trigger.
a Open the ORDERS form module and replace the M_SUMMIT menu
module with the DEFAULT&SMARTBAR menu.
b Run the form and make sure that you understand the default behavior
of [Duplicate Record], by invoking it once while the cursor is on a
queried record in the S_ORD block and again when the cursor is on a
new record.
c Redefine [Duplicate Record] so that a new record is created before
the record duplication occurs. Redefine [Duplicate Record] at the
form level.

Key-Duprec at Form Level


CREATE_RECORD;
DUPLICATE_RECORD;

d In the S_ORD block, redefine [Duplicate Record] in such a way that


the Id item is emptied after duplication. This code should be
executed in addition to and after the form level code.

Key-Duprec on the S_ORD Block


:s_ord.id := NULL;

Set the Execution Hierarchy property for this trigger to After.


e In the S_ITEM block, redefine [Duplicate Record] in such a way that
the item_id, product_id, description, and price items are emptied
after duplication. This code should be executed in addition to and
after the form level code.

Key-Duprec on the S_ITEM Block


:s_item.item_id := NULL;
:s_item.product_id := NULL;
:s_item.description := NULL;
:s_item.price := NULL;

Set the Execution Hierarchy property for this trigger to After.


f Save, generate, and test the ORDERS form.
If you have time...

......................................................................................................................................................
A-12 Developer/2000: Build Forms II
Practice 4 Solutions
......................................................................................................................................................

2 Disable function keys.


a Make sure that only the function keys [Duplicate Record],
[Execute Query], [Enter Query], [Create Record], [Clear Block],
[Up], and [Down] can be used for the S_ORD master block. All
function keys should be available for the S_ITEM detail block.

Key-Exeqry on the S_ORD Block


EXECUTE_QUERY;

Key-Entqry on the S_ORD Block


ENTER_QUERY;

Key-CreRec on the S_ORD Block


CREATE_RECORD;

Key-ClrBlk on the S_ORD Block


CLEAR_BLOCK;

Key-Up on the S_ORD Block


UP;

Key-Down on the S_ORD Block


DOWN;

Key-Others on the S_ORD Block


MESSAGE(’Function Not Allowed’);

b Test whether you can exit from the form by selecting the [Exit] key
in the master block.
You cannot exit the form by selecting the [Exit] key in the master
block.

......................................................................................................................................................
Developer/2000: Build Forms II A-13
Appendix A: Practice Solutions
......................................................................................................................................................

c Add a form-level Key-Exit trigger to perform the exit functionality


of the CONTROL.EXIT_BUTTON item.

Key-Exit at Form Level


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

d Test again whether you can exit from the form by selecting [Exit] in
the master block. Explain this behavior.
If there is no key trigger defined for a function key at the same
level as Key-Others, Forms searches at a higher level for such a
key trigger.

e Modify the When-Button-Pressed trigger of the


CONTROL.EXIT_BUTTON item to activate the same functionality
when you select the [Exit] function key. Remove the existing code.

When-Button-Pressed on the CONTROL.EXIT_BUTTON Item


Remove the existing code and replace with the following code.
DO_KEY(’exit_form’);

......................................................................................................................................................
A-14 Developer/2000: Build Forms II
Practice 4 Solutions
......................................................................................................................................................

3 Create and modify a key trigger.


a Create an alert called DELETE_ALERT.
b For the S_ORD and S_ITEM blocks, redefine [Delete Record] so
that the alert is displayed when a record is deleted. Modify the
message displayed, depending on the block where the cursor is.

Key-Delrec on the S_ORD Block


SET_ALERT_PROPERTY(’DELETE_ALERT’, ALERT_MESSAGE_TEXT, ’Do you want
to delete this order?’);
IF SHOW_ALERT(’DELETE_ALERT’) = ALERT_BUTTON1
THEN
DELETE_RECORD;
END IF;

Key-Delrec on the S_ITEM Block


SET_ALERT_PROPERTY(’DELETE_ALERT’, ALERT_MESSAGE_TEXT, ’Do you want
to delete this line item?’);
IF SHOW_ALERT(’DELETE_ALERT’) = ALERT_BUTTON1
THEN
DELETE_RECORD;
END IF;

c Specify new text to be displayed in the run-time Show Keys help


window.
In the Key-Delrec on the S_ORD block, set the Keyboard Help
Text trigger property to “Remove Order” and set the Display in
Keyboard Help property to Yes. In the Key-Delrec on the
S_ITEM block, set the Keyboard Help Text trigger property to
“Remove Line Item” and set the Display in Keyboard Help
property to Yes.

......................................................................................................................................................
Developer/2000: Build Forms II A-15
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 5 Solutions
In this practice, you provide additional functionality in your forms by
defining mouse-event triggers.
1 In the CUSTOMERS form, define a mouse-event trigger on
S_CUSTOMER.COMMENTS that invokes the item’s editor when the
user double-clicks the item.

WHEN-MOUSE-DOUBLECLICK on s_customer.comments
EDIT_TEXTITEM;

2 In the ORDERS form convert the CONTROL.SHOW_HELP_BUTTON


button into a display item capable of displaying a single large character.
Change the item type property and choose a font that allows large
character sizes (such as Times New Roman). Set the font size to 24. Set
Bevel to none. Adjust the item size so that one character is visible inside
it. Since only the first character of the item name is visible in the Layout
Editor, this item appears as S. The item’s background color should match
the toolbar, and its text color should be green.
There is no formal solution.
3 In the ORDERS form, define a When-Mouse-Enter trigger at form level
that assigns a value of ? to the display item
CONTROL.SHOW_HELP_BUTTON. This should occur only when the
mouse is in the CV_ORDER canvas.

WHEN-MOUSE-ENTER at Form Level


IF :SYSTEM.MOUSE_CANVAS = ’CV_ORDER’
THEN
:control.show_help_button := ’?’;
END IF;

......................................................................................................................................................
A-16 Developer/2000: Build Forms II
Practice 5 Solutions
......................................................................................................................................................

4 Create a When-Mouse-Enter trigger on


CONTROL.SHOW_HELP_BUTTON that uses the SHOW_VIEW
built-in to display the CV_HELP. Remove the When-Button-Pressed
trigger.

WHEN-MOUSE-ENTER trigger on control.show_help_button


SHOW_VIEW(’cv_help’);

5 Create a When-Mouse-Leave trigger on


CONTROL.SHOW_HELP_BUTTON that hides the CV_HELP. Use the
HIDE_VIEW built-in to achieve this. Delete the
CONTROL.HIDE_HELP_BUTTON button.

WHEN-MOUSE-LEAVE trigger on control.show_help_button


HIDE_VIEW(’cv_help’);

6 Save, compile, and run the ORDERS form to test. The stacked canvas,
CV_HELP is displayed only if the current item is not obscured. Ensure,
at least, that the first entered item in the form is CV_HELP will not
obscure.
You might decide to advertise Help only while the cursor is in
certain items, or move the stacked canvas to a position that does not
overlay enterable items.
The CV_HELP canvas, of course, could also be shown in its own
window, if appropriate.

If you have time...


7 Modify the When-Mouse-Enter and When-Mouse-Leave triggers to
display the Cv_Help canvas, even if the current item is obscured. You
can replace the existing code with the code from the pr5_7_1.txt
and pr5_7_2.txt files.

WHEN-MOUSE-ENTER trigger on control.show_help_button


:GLOBAL.save_item_name := :SYSTEM.CURSOR_ITEM;
GO_ITEM(’s_ord.id’);
SHOW_VIEW(’cv_help’);

WHEN-MOUSE-LEAVE trigger on control.show_help_button


HIDE_VIEW(’cv_help’);
GO_ITEM(:GLOBAL.save_item_name);

......................................................................................................................................................
Developer/2000: Build Forms II A-17
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 6 Solutions
1 Manipulate a multiple-window form.
a Open the ORDERS form module.
b Make sure that when a user closes the orders window by way of the
system-menu box, the form is exited. Also make sure that when a
user closes the inventory window by way of the system-menu box,
the cursor navigates to the orders window. If cursor navigation
succeeds, the inventory window should closed. Create a When-
Window-Closed trigger. You can import the pr6_1b.txt file.

When-Window-Closed Trigger at Form Level


IF :SYSTEM.EVENT_WINDOW = ’WIN_ORDER’
THEN
DO_KEY(’exit_form’);
ELSIF :SYSTEM.EVENT_WINDOW = ’WIN_INVENTORY’
THEN
GO_BLOCK(’s_ord’);
END IF;

c Save, compile, and test the form.


There is no formal solution.
d Make sure that a user cannot make any window larger than it was at
the startup of the form. You should save the size of the windows at
the startup of the form, and create a procedure called
CHECK_WINDOW_SIZE that resets the size of the current window
if the new width and height are larger than the initial one. Create a
When-New-Form-Instance trigger. You can replace the existing code
with the code from the pr6_1d1.txt file. Next, create the
procedure CHECK_WINDOW_SIZE. You can import the code from
the pr6_1d2.txt file. Create a When-Window-Resized trigger
that calls the procedure.
The following solution assumes that the window sizes at form
startup are stored in global variables with names of the general
form:
GLOBAL.WIDTH_<window_name> and
GLOBAL.HEIGHT_<window_name>

......................................................................................................................................................
A-18 Developer/2000: Build Forms II
Practice 6 Solutions
......................................................................................................................................................

Note: In multiple-form applications, it is better to use form parameters than


global variables, because form parameters are not visible to other forms.

When-New-Form-Instance Trigger at Form Level


EXECUTE_QUERY;
:GLOBAL.width_win_order :=
GET_WINDOW_PROPERTY(’win_order’,WIDTH);
:GLOBAL.height_win_order :=
GET_WINDOW_PROPERTY(’win_order’, HEIGHT);
:GLOBAL.width_win_inventory :=
GET_WINDOW_PROPERTY(’win_inventory’, WIDTH);
:GLOBAL.height_win_inventory :=
GET_WINDOW_PROPERTY(’win_inventory’, HEIGHT);

PROCEDURE check_window_size( p_window IN VARCHAR2 )


IS
v_window_max_widthNUMBER;
v_window_max_heightNUMBER;
BEGIN
v_window_max_width := NAME_IN(’GLOBAL.width_’ || p_window );
v_window_max_height := NAME_IN(’GLOBAL.height_’ || p_window );
IF v_window_max_width < TO_NUMBER(
GET_WINDOW_PROPERTY(p_window, WIDTH) )
THEN
SET_WINDOW_PROPERTY(p_window, WIDTH, v_window_max_width );
END IF;
IF v_window_max_height < TO_NUMBER(
GET_WINDOW_PROPERTY(p_window, HEIGHT) )
THEN
SET_WINDOW_PROPERTY(p_window, HEIGHT, v_window_max_height );
END IF;
END check_window_size;

When-Window-Resized Trigger at Form Level


check_window_size( :SYSTEM.EVENT_WINDOW );

......................................................................................................................................................
Developer/2000: Build Forms II A-19
Appendix A: Practice Solutions
......................................................................................................................................................

2 Manipulate the MDI application window.


a Open the CUSTOMERS form module.
b At the startup of the form, maximize the MDI application window,
and display an appropriate title. You can import the pr6_2b.txt
file.

When-New-Form-Instance Trigger at Form Level


SET_WINDOW_PROPERTY( forms_mdi_window, WINDOW_STATE, MAXIMIZE );
SET_WINDOW_PROPERTY( forms_mdi_window, TITLE, ’Summit Sporting
Goods Application’);

If you have time...


3 Open the EMPLOYEES form, and use the CONTROL.HELP_TAB text
item to display a hint or description for the current tab page.
a Create a When-Tab-Page-Changed trigger to populate this item with
an appropriate message for each page. You can import the
pr6_3a.txt file.

When-Tab-Page-Changed Trigger at Form Level


:control.help_tab := ’Displays ’|| Initcap(:SYSTEM.TAB_NEW_PAGE)
|| ’ information about ------------------>’ ;
b Test and verify your module.
c Modify the When-Tab-Page-Changed trigger to change the label on
the Comment tab page. When Comment is the topmost page, change
its label to Employee XX, where XX is the employee’s ID number
(emp.id). When any other tab page is topmost, change the label back
to Comment. You can import the pr6_3c.txt file.

When-Tab-Page-Changed Trigger at Form Level


:control.help_tab := ’Displays ’|| Initcap(:SYSTEM.TAB_NEW_PAGE)
|| ’ information about ------------------>’ ;

IF :SYSTEM.TAB_NEW_PAGE = ’COMMENT’ THEN


SET_TAB_PAGE_PROPERTY(’CANVAS2.COMMENT’, LABEL, ’Employee ’ ||
:EMP.ID);
ELSE
SET_TAB_PAGE_PROPERTY(’CANVAS2.COMMENT’, LABEL, ’Comment’);
END IF;

......................................................................................................................................................
A-20 Developer/2000: Build Forms II
Practice 7 Solutions
......................................................................................................................................................

Practice 7 Solutions
1 Base the EMP block on a subquery.
a Open the EMPLOYEES form module.
b Set the Query Data Source Type EMP block property to From Clause
Query.
In the EMP block Property Palette, under the Database node,
change Query Data Source Type to From Clause Query.
c In the Query Data Source Name property enter the SELECT
statement. Your query should return all the columns from the S_EMP
table joined with the columns from the S_DEPT table. Remember to
enclose your select SELECT statement in parentheses. You can copy
and paste the content of the pr7_1c.txt file.
The SELECT statement is:
(SELECT e.ID,
USERID,
LAST_NAME,
FIRST_NAME,
START_DATE,
TITLE,
MANAGER_ID,
DEPT_ID,
SALARY,
COMMISSION_PCT,
COMMENTS,
d.ID NUM,
REGION_ID,
NAME
FROM s_emp e, s_dept d
WHERE e.dept_id = d.id)

d When a block’s Query Data Source Type is Table, the ROWID of


each row is implicitly queried when the row is retrieved from the
database. This ROWID value is used in the WHERE clause of any
subsequent UPDATE, DELETE, or SELECT FOR UPDATE
statements issued by Oracle Forms.
When a block’s Query Data Source Type is From Clause Query, the
ROWID value is not implicitly retrieved. Therefore, the ROWID

......................................................................................................................................................
Developer/2000: Build Forms II A-21
Appendix A: Practice Solutions
......................................................................................................................................................

value cannot be used in subsequent statements. Instead, Oracle


Forms constructs the WHERE clause using the primary key values
of each row.
Configure the EMP block so that Oracle Forms will use the primary
key values when constructing the WHERE clause. Set the KeyMode
property for the EMP block to Updatable. Set the Enforce Primary
Key property for the EMP block to Yes. Set the Primary Key
property for the Id item to Yes.
e Save, run, and test your module.
2 Enable DML on the EMP block without using transactional triggers.
a Set the block DML Target Name.
In the EMP block Property Palette, under the Advanced
Database node, change DML Data Target Name to S_EMP.
b Prevent Oracle Forms from attempting to update the columns from
the S_DEPT table. On the Property Palette for the item, set the Query
Only property to Yes, and the Update Allowed and Insert Allowed
properties to No for the S_DEPT items (NUM, NAME,
REGION_ID).
There is no formal solution.
c Remove the appropriate transactional triggers.
Remove the On-Insert, On-Update, On-Delete, and On-Lock
triggers.
d Save, run, and test your module.
If you have time...
3 Create a server-side package containing a procedure to return a REF
cursor.
Using the code in the pr7_3a.sql file in your labs directory, create
the Orders package body and package specification.
Use SQL*Plus to run the file, or use the Stored Procedure editor
in Forms and copy and paste the code from the file.
4 Modify the Ord_Sum block in the ord_sum.fmb module to base it on
the stored procedure.
a Open the ord_sum.fmb module. Change the Query Data Source
Type of the Ord_Sum block to Procedure. Change the DML Data
Target Type to None (this block does not allow any inserts, updates,
or deletes).

......................................................................................................................................................
A-22 Developer/2000: Build Forms II
Practice 7 Solutions
......................................................................................................................................................

In the Ord_Sum block Property Palette, under the Database


node, change Query Data Source Type to Procedure.
Under the Advanced Database node, change DML Data Target
Type to None.
b Set the Query Data Source Name to the name of the stored procedure
in the package.
Under the Database node, change Query Source Name to
ORDERS_PKG.QUERY_PROC. You can find the procedure
name by double-clicking the package body name under the
Stored Program Units node in the Object Navigator.
c Specify the Query Data Source Columns to match the items in the
Ord_Sum block.
The column names and types are:
ID, Number
NAME, Varchar2(255)
TOTAL, Number
There is no formal solution.
d Specify the procedure arguments. The first argument is the REF
cursor that will be used by Forms to populate the block. The second
argument is used to pass the value of the list box
(:Choose.View_Type) to the procedure to determine which SELECT
statement is used. These arguments should match the arguments to
the package procedure.
The arguments are:

Argument Type Type Name Mode Value


Resultset RefCursor (No Value) In Out (No Value)
P_View Varchar2 (No Value) In :Choose.View_Type

e Add a trigger on the View_Type item so that the data in the Ord_Sum
block is updated when the list box value changes.
Hint: You need to execute a query in the Ord_Sum block.
Add a When-List-Changed trigger to Choose.View_Type as follows:\
GO_BLOCK(’ord_sum’);
EXECUTE_QUERY;

Alternative Method: In the Choose.View_Type Property Palette,


change Mouse Navigate to No. Now the cursor remains in the
Ord_Sum block and there is no need to code the Go_Block
statement.

......................................................................................................................................................
Developer/2000: Build Forms II A-23
Appendix A: Practice Solutions
......................................................................................................................................................

5 Save and run your form. Observe the behavior of the record count in the
console and the scroll bar as you scroll through the records. What do you
deduce from this behavior?
The record count increments as Forms fetches more records, and
the scroll bar button changes size as more records are fetched. From
this we can deduce that a block based on a REF Cursor stored
procedure benefits from array fetches, just like a block based
directly on a table.

......................................................................................................................................................
A-24 Developer/2000: Build Forms II
Practice 8 Solutions
......................................................................................................................................................

Practice 8 Solutions
1 Create a block based on a relational table.
Create a new form called OO_DEPT.
a
Select Forms in the Object Navigator and click the Create
button. Select the newly created form name and change it to
OO_DEPT.
b Create a block by using the Data Block Wizard. Base the block on
the object table OO_DEPT_TABLE, and include all the columns. Do
not enforce data integrity.
Select Data Blocks in the Object Navigator and click the Create
button. Click the OK button to use the Data Block Wizard. Click
the Next button to base the new block on a table. Click the
Browse button to view a list of tables. (If you are not currently
connected to the database, you are asked to supply connect
information.) Select OO_DEPT_TABLE and click the OK
button. Click the >> button and Next button to select all the
available columns.
c Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display, and use a tabular
layout with three displayed records and a scroll bar. Do not enter a
frame title.
Click the Finish button to create the block and to invoke the
Layout Wizard. Click the Next button to use a new content
canvas. Click the >> button and the Next button to select all
available items for display. Click the Next button to accept the
default prompts. Select the Tabular option button and click the
Next button to specify a tabular layout. Change the Records
Displayed value to 3, and select the Display Scrollbar check box.
Click the Next button, then the Finish button.
d Test and save the form.
There is no formal solution.
2 Create a block based on a relational table with an object column.
a Create a form called OBJ_COL.
Select Forms in the Object Navigator and click the Create
button. Select the newly created form name and change it to
OBJ_COL.

......................................................................................................................................................
Developer/2000: Build Forms II A-25
Appendix A: Practice Solutions
......................................................................................................................................................

Create a block by using the Data Block Wizard. Base the block on
b
the relational table REL_EMP_TABLE_OBJCOL. Select the
columns ID, FIRST_NAME, and LAST_NAME. Expand the object
column DEPT_ID and select the attributes ID and NAME. Note the
name that is given to the new item. Do not enforce data integrity.
Select Data Blocks in the Object Navigator and click the Create
button. Click the OK button to use the Data Block Wizard. Click
the Next button to base the new block on a table. Click the
Browse button to view a list of tables. Select
REL_EMP_TABLE_OBJCOL and click the OK button. Select
the ID column and click the > button. Repeat this process for the
FIRST_NAME and LAST_NAME columns. Expand the
DEPT_ID object column to display the objects attributes. Select
the ID attribute and click the > button. Repeat the process for
the NAME attribute. Click the Next button to continue.
c Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display. Change the prompt for
item DEPT_ID to Department ID and DEPT_ID_NAME to
Department Name. Use a form layout. Do not enter a frame title.
Finish following the wizard.
Click the Finish button to create the block and to invoke the
Layout Wizard. Click the Next button to use a new content
canvas. Click the >> button and the Next button to select all
available items for display. Select the prompt for the
DEPT_ID_ID item and change it. Repeat the process for the
DEPT_ID_NAME item. Click the Next button to continue. Click
the Next button to specify a form layout. Do not enter a Frame
Title. Click the next button to accept the default records
displayed. Click the Finish button.
d Examine the properties for the item dept_id_name. Pay particular
attention to the database properties. Later, you will compare and
contrast these properties with the properties set for a REF column.
There is no formal solution.
e Test and save the form.
There is no formal solution.
3 Create a block based on a relational table with an REF column and an
LOV to populate the REF column.

......................................................................................................................................................
A-26 Developer/2000: Build Forms II
Practice 8 Solutions
......................................................................................................................................................

a Create a form called REF_COL.


Select Forms in the Object Navigator and click the Create
button. Select the newly created form name and change it to
REF_COL.
b Create a block by using the Data Block Wizard. Base the block on
the relational table REL_EMP_TABLE_REFCOL. Select the
columns ID, FIRST_NAME and LAST_NAME. Do not enforce data
integrity.
Select “Data Blocks” in the Object Navigator and press the
Create button. Press the OK button to use the Data Block
Wizard. Press the Next button to base the new block on a table.
Press the Browse button to view a list of tables. Select
REL_EMP_TABLE_REFCOL and press the OK button. Select
the id column and press the > button. Repeat that process for the
first name and last name columns.
c Note that there are two items called DEPT_ID. The first is
expandable and has the term “LOOKUP” in parenthesis after the
name. The second represents the REF column value itself. Expand
the first DEPT_ID item and select the attributes ID and NAME. (Do
not select the second DEPT_ID item. The REF item is included
automatically when the LOV is created.)
Expand the dept_id object column to display the object
attributes. Select the id attribute and click the > button. Repeat
the process for the name attribute. Click the Next button to
continue.
d The Data Block Wizard offers to create an LOV for the REF item
dept_id. Select the check box, and select OO_DEPT_TABLE as the
source for the LOV.
Select the dept_id check box. Press the ... button, select the
OO_DEPT_TABLE table and click the OK button. Click the
Next button to continue.
e Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display. Do not enter a frame
title. (Note that the REF item DEPT_ID is included in the list of
items in the Object Navigator but is not included in the list of
available items in the Layout Wizard. REF item values are normally
not displayed, so by default the REF item is assigned to the Null
canvas.)

......................................................................................................................................................
Developer/2000: Build Forms II A-27
Appendix A: Practice Solutions
......................................................................................................................................................

Click the Finish button to create the block and to invoke the
Layout Wizard. Click the Next button to use a new content
canvas. Click the >> button and the Next button to select all
available items for display. Change the prompt for item
dept_id_id to Department Id and dept_id_name to Department
Name. Use a form layout. Do not enter a Frame Title. Finish
following the wizard.
f Examine the database properties for the item DEPT_ID_NAME. Pay
particular attention to the database properties. Notice that the Query
Only property is set to Yes.
There is no formal solution.
g Select the item DEPT_ID from the Object Navigator, and examine
the Canvas property. Also, notice that an LOV and associated record
group now exist.
There is no formal solution.
h Test and save the form, including the LOV.
There is no formal solution.

......................................................................................................................................................
A-28 Developer/2000: Build Forms II
Practice 9 Solutions
......................................................................................................................................................

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

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 checkboxes appropriately in


the Toolbar canvas.

......................................................................................................................................................
Developer/2000: Build Forms II A-29
Appendix A: Practice Solutions
......................................................................................................................................................

c Make sure that the first check box enables a user to toggle between
immediate coordination and deferred coordination. You can import
the pr9_2c.txt file.

When-Checkbox-Changed on CONTROL.IMMEDIATE
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
pr9_2d.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;
eTest and save the form.
There is no formal solution.
If you have time...
3 Add a detail block based on a REF relation to the OO_DEPT table.
a Open the OO_DEPT form in the Object Navigator.
There is no formal solution.

......................................................................................................................................................
A-30 Developer/2000: Build Forms II
Practice 9 Solutions
......................................................................................................................................................

Create a new block by using the Data Block Wizard. Base the block
b
on the table REL_EMP_TABLE_REFCOL, and include the id,
first_name, last_name, and dept_id REF columns. Do not enforce
data integrity, and do not create an LOV.
Select Data Blocks in the Object Navigator and click the Create
button. Click the OK button to use the Data Block Wizard. Click
the Next button to base the new block on a table. Click the
Browse button to view a list of tables. (If you are not currently
connected to the database, you are asked to supply connect
information.) Select OO_EMP_TABLE_REFCOL and click the
OK button. Select the id column and click the > button. Repeat
the process for the first_name, last_name, and dept_id REF
columns. (In the display, the entry DEPT_ID without the word
Lookup after it represents the dept_id REF column. Click the
Next button to continue.
c Create a relationship between the two blocks using the REF value.
Click the Create Relationship button. Select the block
OO_DEPT_TABLE and click the OK button. Click the Next
button to continue.
d Finish following the Data Block Wizard and invoke the Layout
Wizard. Select all available items for display, and use a tabular
layout with three displayed records and a scroll bar. Do not specify a
frame title.
Click the Finish button to create the block and to invoke the
Layout Wizard. Click the Next button to use the existing content
canvas. Click the >> button and the Next button to select all
available items for display. Click the Next button to accept the
default prompts. Select the Tabular option button and click the
Next button to specify a tabular layout. Change the Records
Displayed value to 3, and select the Display Scrollbar check box.
Click the Next button, then the Finish button.
e Test and save the form.
There is no formal solution.
4 Synchronize the check boxes at form startup.
a Open the ORDERS form module.
b Create a procedure called INIT_RELATION_CHECK_BOXES.
This procedure synchronizes the IMMEDIATE and AUTO_QUERY

......................................................................................................................................................
Developer/2000: Build Forms II A-31
Appendix A: Practice Solutions
......................................................................................................................................................

check boxes with the current default value. You can import the
pr9_4b.txt file.
PROCEDURE init_relation_check_boxes
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.
init_relation_check_boxes;
EXECUTE_QUERY;
:GLOBAL.width_win_order := GET_WINDOW_PROPERTY(’win_order’, WIDTH);
:GLOBAL.height_win_order := GET_WINDOW_PROPERTY(’win_order’,HEIGHT);
:GLOBAL.width_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’,
WIDTH);
:GLOBAL.height_win_inventory := GET_WINDOW_PROPERTY(’win_inventory’,
HEIGHT);

5 Implement foreign-key delete rules.


a Open the CUSTOMERS form module. Change the Menu Module
property to DEFAULT&SMARTBAR.
b Create a procedure called CHECK_DEL_CUS. This procedure
displays an error message as soon as a user tries to delete a customer
for which matching orders exist. You can import the pr9_5b.txt
file.
PROCEDURE check_del_cus ( p_cus_id IN NUMBER )

......................................................................................................................................................
A-32 Developer/2000: Build Forms II
Practice 9 Solutions
......................................................................................................................................................

IS
CURSOR c_ord IS
SELECT ’X’
FROM s_ord
WHERE customer_id = p_cus_id;
v_dummy VARCHAR2(1);
ord_exists EXCEPTION;
BEGIN
OPEN c_ord;
FETCH c_ord INTO v_dummy;
IF c_ord%FOUND
THEN
CLOSE c_ord;
RAISE ord_exists;
ELSE
CLOSE c_ord;
END IF;
EXCEPTION
WHEN ord_exists THEN
MESSAGE(’Cannot delete customer while matching orders
exist.’);
RAISE FORM_TRIGGER_FAILURE;
END check_del_cus;
c Call the procedure when a user selects the delete function key.

Key-Delrec Trigger on S_CUSTOMER Block


check_del_cus(:s_customer.id);
DELETE_RECORD;
d Save, compile, and run the module.

......................................................................................................................................................
Developer/2000: Build Forms II A-33
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 10 Solutions
1 Produce a multiple form application by linking the CUSTOMERS and
the EMPLOYEES forms.
a In the control block of the CUSTOMERS form, create a button
called EMPLOYEE_BUTTON. Place it on the CV_CUST canvas,
below the Orders button.
b Define a trigger for CONTROL.EMPLOYEE_BUTTON that calls
the EMPLOYEES form with the current sales representative ID.
- Change the Mouse Navigate property of
CONTROL.EMPLOYEE_BUTTON to No.
- Create a parameter list called SALES.
- Add the SALES_ID parameter to the parameter list. The type of this
parameter is TEXT_PARAMETER, and it is initialized with the
value of the SALES_REP_ID item.
- Invoke the EMPLOYEES form by using the CALL_FORM built-in.
You can import the pr10_1b.txt file.

When-Button-Pressed on the CONTROL.EMPLOYEE_BUTTON Item


DECLARE
p_list_id PARAMLIST;
BEGIN
IF NOT ID_NULL( GET_PARAMETER_LIST( ’sales’ ) )
THEN
DESTROY_PARAMETER_LIST(’sales’);
END IF;
p_list_id := CREATE_PARAMETER_LIST(’sales’);
ADD_PARAMETER( p_list_id, ’sales_id’, TEXT_PARAMETER,
TO_CHAR( :s_customer.sales_rep_id ));
CALL_FORM(’employees’, NO_HIDE, DO_REPLACE, NO_QUERY_ONLY,
p_list_id );
END ;

c Open the EMPLOYEES form module.


d In the Object Navigator, create a parameter called SALES_ID.
e Add a trigger to ensure that queries on the employee block are
restricted by the value of the SALES_ID parameter. Replace the
existing code with the code in the pr10_1e.txt file.

Pre-Query Trigger on the EMP Block

......................................................................................................................................................
A-34 Developer/2000: Build Forms II
Practice 10 Solutions
......................................................................................................................................................

DEFAULT_VALUE(’’, ’GLOBAL.sales_rep_id’);
IF :GLOBAL.sales_rep_id IS NOT NULL AND :PARAMETER.sales_id IS NULL
THEN
:emp.num := :GLOBAL.sales_rep_id;
ELSE
:emp.num := :PARAMETER.sales_id;
END IF;

f Save and compile each form, then run the CUSTOMERS form
module. Test the application by exiting the EMPLOYEE form using
the menu or the toolbar.
If you have time...
2 Transaction processing for called forms:
a Make sure that any changes in the EMPLOYEES form that are
posted by a user are not rolled back by Forms upon exit.

Key-Exit Trigger at Form Level: EMPLOYEES Form


EXIT_FORM( ASK_COMMIT, NO_ROLLBACK );

b Make sure that when the CUSTOMERS form calls the


EMPLOYEES form, [Commit] performs a post. You can import the
pr10_2b.txt file.

Key-Commit Trigger at Form Level: EMPLOYEES Form


IF GET_APPLICATION_PROPERTY( CALLING_FORM ) IS NULL
THEN
COMMIT_FORM;
ELSE
POST;
END IF;

c Save and compile each form, then run the CUSTOMERS form
module and test your application.

......................................................................................................................................................
Developer/2000: Build Forms II A-35
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 11 Solutions
1 Create a dynamic list item. This functionality avoids having to create a
new item to display the department name.
a Open the EMPLOYEES form module.
There is no formal solution.
b Create a design time query record group that contains IDs and names
of departments. Name your record group DEPT_ID.
In the Object Navigator, create a record group named DEPT_ID based
on the query below:
SELECT name || ’ in region ’ || TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
ORDER BY 1
There is no formal solution.
c Convert the text item DEPT_ID into a list item, Combo Box Style.
Resize it in the Layout Editor.
There is no formal solution.
d Create an element in the list. Label: Dummy and Value: 0
There is no formal solution.
e Create a procedure called LIST_FROM_DESIGNTIME_GROUP.
This procedure accepts the list item name as an argument and
populates the list item dynamically at runtime, using the design-time
query record group. You can import the pr11_1e.txt file.
PROCEDURE List_From_DesignTime_Group (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 List_From_DesignTime_Group;

......................................................................................................................................................
A-36 Developer/2000: Build Forms II
Practice 11 Solutions
......................................................................................................................................................

f Call the procedure each time a new record is created. You can import
the pr11_1f.txt file.

When-Create-Record Trigger on the EMP Block,


CLEAR_LIST(’EMP.DEPT_ID’);
LIST_FROM_DESIGNTIME_GROUP(’EMP.DEPT_ID’);
g Save, compile, and test the module.
There is no formal solution.

If you have time...


2 Create a multirecord select list form. This practice shows how to create a
list of values where the user can select multiple values. This lab uses a
global record group.
a Exit Form Builder.
b Run Form Builder and create a new form based on a template named
lov_prod_template.fmb.
c Examine this new module and save it as lov_product.fmb.
This new form contains a multi-record block based on the
S_PRODUCT table. Only the ID, NAME, and
SUGGESTED_WHLSL_PRICE columns are displayed.
This form also contains an OK button and a Cancel button
without any code.
This form contains two visual attributes called DESELECTED
and SELECTED.
d Create a When-Mouse-Click trigger at the PROD_LOV_BLK block
level that selects or clears a record when a user presses Control-
clicks for a product.
Write the code to create a record group if it does not already exist
and add columns to the group for each item in the
PROD_LOV_BLK block. If the record group exists write the code to
retrieve the internal ID for each column in the record group.
Write the code to check whether the record selected is already in the
record group. If so, loop through each item in the record to keep the
visual attribute from being highlighted, and then remove the record
from the record group.
If the user selects a record that was not already in the group, write the
code to add the record to the record group and loop through each

......................................................................................................................................................
Developer/2000: Build Forms II A-37
Appendix A: Practice Solutions
......................................................................................................................................................

item in the block to keep the color highlighted.


Use the SELECTED and DESELECTED visual attributes in your
code to change the color of a selected or cleared record.
You can import the pr11_2d.txt file.

When-Mouse-Click Trigger on the PROD_LOV_BLK Block


DECLARE
rg_id RECORDGROUP := FIND_GROUP(’sel_records’);
recno_id GROUPCOLUMN;
prodno_id GROUPCOLUMN;
prodname_id GROUPCOLUMN;
prodprice_id GROUPCOLUMN;
no_rows NUMBER(7);
desel VARCHAR2(5) := ’no’;
itm VARCHAR2(80);
lst VARCHAR2(100);
BEGIN
--
IF :SYSTEM.MOUSE_BUTTON_MODIFIERS = ’Control+’ THEN
-- If record group does not exist
-- create it and add columns to the
-- group for each item in the PROD_LOV_BLK
IF ID_NULL(rg_id) THEN
rg_id := CREATE_GROUP(’sel_records’, GLOBAL_SCOPE);
recno_id := ADD_GROUP_COLUMN(rg_id,’recno’,NUMBER_COLUMN);
prodno_id := ADD_GROUP_COLUMN(rg_id,’prodno’,NUMBER_COLUMN);
prodname_id := ADD_GROUP_COLUMN(rg_id,’prodname’, CHAR_COLUMN,
80);
prodprice_id := ADD_GROUP_COLUMN(rg_id,’prodprice’,
NUMBER_COLUMN);

-- if the record group does exist


-- retrieve the internal id for each
-- column in the record group
ELSE
recno_id := FIND_COLUMN(’sel_records.recno’);
prodno_id := FIND_COLUMN(’sel_records.prodno’);
prodname_id := FIND_COLUMN(’sel_records.prodname’);
prodprice_id := FIND_COLUMN(’sel_records.prodprice’);
END IF;

......................................................................................................................................................
A-38 Developer/2000: Build Forms II
Practice 11 Solutions
......................................................................................................................................................

-- check to see if record CNTL


-- clicked on is already in the record
-- group - if so loop thru each item
-- in the block to set the visual
-- attribute back from being highlighted,
-- and then remove record from
-- record group
no_rows := GET_GROUP_ROW_COUNT(rg_id);
FOR i IN 1..no_rows LOOP
IF TO_NUMBER(:SYSTEM.MOUSE_RECORD) =
GET_GROUP_NUMBER_CELL(recno_id, i) THEN
desel := ’yes’;
itm := GET_BLOCK_PROPERTY(:SYSTEM.CURSOR_BLOCK, FIRST_ITEM);
itm := :SYSTEM.CURSOR_BLOCK || ’.’ || itm;
LOOP
DISPLAY_ITEM(itm, ’DESELECTED’);
itm := GET_ITEM_PROPERTY(itm, NEXTITEM);
EXIT WHEN itm IS NULL;
itm := :SYSTEM.CURSOR_BLOCK || ’.’ || itm;
END LOOP;
DELETE_GROUP_ROW(rg_id, i);
EXIT;
END IF;
END LOOP;

-- if CNTL click on a record that


-- was not already in the group
-- add the record to the record group
-- and loop through each
-- item in the block to set the color
-- to be highlighted for each.
IF desel != 'yes' THEN
ADD_GROUP_ROW(rg_id,end_of_group);
SET_GROUP_NUMBER_CELL(recno_id, no_rows+1,
TO_NUMBER(:SYSTEM.MOUSE_RECORD));
SET_GROUP_NUMBER_CELL(prodno_id, no_rows+1, :prod_lov_blk.id);
SET_GROUP_CHAR_CELL(prodname_id, no_rows+1, :prod_lov_blk.name);
SET_GROUP_NUMBER_CELL(prodprice_id, no_rows+1,
:prod_lov_blk.suggested_whlsl_price);
itm := GET_BLOCK_PROPERTY( :SYSTEM.CURSOR_BLOCK , FIRST_ITEM );

......................................................................................................................................................
Developer/2000: Build Forms II A-39
Appendix A: Practice Solutions
......................................................................................................................................................

itm := :SYSTEM.CURSOR_BLOCK || ’.’ || itm;


LOOP
DISPLAY_ITEM(itm, ’SELECTED’);
itm := GET_ITEM_PROPERTY(itm, NEXTITEM);
EXIT WHEN itm IS NULL;
itm := :SYSTEM.CURSOR_BLOCK || ’.’ || itm;
END LOOP;
END IF;
END IF;
END;

e Create the code for the OK button. This button enables the user to
exit the form.
DO_KEY(’EXIT_FORM’);
f Create the code for the Cancel button in the PROD_LOV_BLK
block.
Create a When-Button-Pressed trigger that deletes the record group
before returning to the ITEM block. You can import the
pr11_2f.txt file.

When-Button-Pressed Trigger at PROD_LOB_BLK.CANCEL_PB Item


IF NOT ID_NULL(FIND_GROUP(’sel_records’)) THEN
DELETE_GROUP(’sel_records’);
END IF;
DO_KEY(’EXIT_FORM’);

g In the ORDERS form, modify the When-Button-Pressed trigger for


the CONTROL.PRODUCT_LOV_BUTTON. The new code should
check the existing products in the S_ITEM block, so that products
already ordered do not show up in the list. The trigger then calls the
PROD_LOV_BLK form, passing the list of existing products using a
GLOBAL variable. You can import the pr11_2g.txt file.
:GLOBAL.where_cls := ’ id NOT IN (’;
GO_BLOCK(’item’);
FIRST_RECORD;
IF:SYSTEM.RECORD_STATUS != ’NEW’ THEN
LOOP
:GLOBAL.where_cls := :GLOBAL.where_cls ||
TO_CHAR(:item.product_id);

......................................................................................................................................................
A-40 Developer/2000: Build Forms II
Practice 11 Solutions
......................................................................................................................................................

NEXT_RECORD;
EXIT WHEN :SYSTEM.LAST_RECORD = ’TRUE’;
:GLOBAL.where_cls := :GLOBAL.where_cls || ’,’';
END LOOP;
:GLOBAL.where_cls := :GLOBAL.where_cls || ’,’ ||
TO_CHAR(:item.product_id) || ’)’;
END IF;
CALL_FORM(’lov_product’, NO_HIDE);
h In the LOV_PRODUCT form, create a When-New-Form-Instance
trigger to retrieve the list of products excluding the products that
exist in the S_ITEM block. You should use the global variable
created earlier. You can import the pr11_2h.txt file.

When-New-Form-Instance Trigger at Form Level


DEFAULT_VALUE(’’, ’'GLOBAL.where_cls’);
SET_BLOCK_PROPERTY(’prod_lov_blk’, DEFAULT_WHERE,
:GLOBAL.where_cls);
EXECUTE_QUERY;

i In the ORDERS form, modify the When-Button-Pressed trigger for


the CONTROL.PRODUCT_LOV_BUTTON. After you call the
form, the code creates records in the S_ITEM block for each row
selected in the record group. The code then deletes the record
group.You can import the pr11_2i.txt file. Place the new code
after the existing code.
j Save, run, and test your forms. To select multiple items, select the
first item, hold the Control key down, and then select other items.

......................................................................................................................................................
Developer/2000: Build Forms II A-41
Appendix A: Practice Solutions
......................................................................................................................................................

Practice 12 Solutions
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the CUSTOMERS form module.
There is no formal solution.
b Create a new tab page on the TAB_CUSTOMER canvas. Name this
page CHART and change the label name.
There is no formal solution.
Open the FormBuilder_II.olb object library. Copy the
OBJ_CHART object group into the CUSTOMERS form. This object
group contains a block named S_ORD. Only one item from this
block is visible: TITLE. This item displays a title for the chart.
In the Object Navigator, double-click the icon next to the
FORM_BUILDER_II object library node.
From the Chart tab, select the OBJ_CHART object group and
drag it to the object group node in the CUSTOMERS form.
Select Copy.
c From the Layout Editor, use the Chart tool to drag a chart area onto
the chart tab page. Select Use the Chart Wizard from the New Chart
Object dialog box. Do not specify a title for the chart.
There is no formal solution.
d Select Column as chart type, Plain as chart subtype.
There is no formal solution.
e Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
There is no formal solution.
f Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
There is no formal solution.
g Click the Finish button. Save, run, and test your form. To display the
chart, click in the Title item on the Chart tab.
2 Create a report object based on the S_CUSTOMER block. This report
displays a customer list using a tabular layout. Display only the ID,
NAME, COUNTRY, and REGION_ID fields.
a Open the CUSTOMERS form.

......................................................................................................................................................
A-42 Developer/2000: Build Forms II
Practice 12 Solutions
......................................................................................................................................................

b Create a new report object.


- Select the Report Object node in the Object Navigator.
- Click the Create icon.
- Specify a filename of myreport and a block name.
- Click OK.
This will invoke the Report Builder. Within the Report Wizard:
- Choose the report style Tabular.
- Select the ID, NAME, COUNTRY, and CREDIT_RATING fields.
- Do not select fields to total.
- Change labels and widths for your fields.
- Select a template for your report.
c Save your report and exit Report Builder.
d Set the Execution Mode report object property to runtime and the
Report Destination Type report object property to screen.
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 into the control
block. Display this button on the CV_CUSTOMER canvas.
f Create a When-Button-Pressed trigger on the
CUST_REP_BUTTON button to run the report.
DECLARE
myvar VARCHAR2(50);
BEGIN
myvar := RUN_REPORT_OBJECT(’my_report’);
END ;
g Change the Query All Record property value to Yes for the
S_CUSTOMER block.
h Save, run, and test your form. Query a customer record before
calling the report.

......................................................................................................................................................
Developer/2000: Build Forms II A-43
Appendix A: Practice Solutions
......................................................................................................................................................

If you have time...


3 Create a new tab page from which the user can run different report
layouts.
a Open the Form_Builder_II.olb object library.
In the Object Navigator, double-click the icon next to the
FORM_BUILDER_II object library node.
b From the Report tab page, select all the report objects and copy them
to the CUSTOMERS form.
c Change the filename property to each report so that the path is
correct for your environment.
Do this in the Object Navigator.
d From the Report tab page, select the REPORT block and copy it to
the CUSTOMERS form. Organize this block so it is the last block in
sequence.
Do this in the Object Navigator.
e From the Report tab page, select the REPORT tab page object and
copy it to the CUSTOMERS form. Organize this tab page so it is the
last tab page in sequence.
Do this in the Object Navigator.
f Save, run, and test your form.

......................................................................................................................................................
A-44 Developer/2000: Build Forms II
Practice 13 Solutions
......................................................................................................................................................

Practice 13 Solutions
1 Show ”About...” information at the startup of the form.
a Open the CUSTOMERS form module.
b Add a window and a canvas to the form that are used to display the
two control items. This window could be considered an ”About...”
window and should be a modal dialog window. Set the Hide on Exit
property to Yes for this window.
Create a window named ABOUT. Set the Window Style property
to Dialog. Set the Modal Property to Yes. Set both the X Position
and Y Position properties to 100.
Create a canvas named ABOUT. Set the Window property to
ABOUT.
c Create manually a new control block, called ABOUT. Create two
items in the ABOUT block that are used to display the user name and
the current date and time.
Create a content canvas named ABOUT. In the layout editor,
create two text items named user_name and client date. Create
the text items on the ABOUT canvas and in the ABOUT block.
Set the Database Item property for both items to No. Adjust the
canvas size appropriately.
d Show the ”About...” window for a short period of time at the startup
of the form. You can import the pr13_1d1.txt file for the
When-New-Form-Instance trigger. Add the new code after the
existing code. You can import the pr13_1d2.txt file for the
When-Timer-Expired trigger. Append the new code to the end of the
existing code.

When-New-Form-Instance Trigger at Form Level


. . .
DECLARE
cst_show_time CONSTANT NUMBER(4) := 4000;
v_timer_id TIMER;
BEGIN
:about.user_name := USER;
:about.client_date := :SYSTEM.CURRENT_DATETIME;
v_timer_id := CREATE_TIMER(’ABOUT’,cst_show_time,NO_REPEAT );
GO_ITEM(’about.user_name’);
END;

......................................................................................................................................................
Developer/2000: Build Forms II A-45
Appendix A: Practice Solutions
......................................................................................................................................................

When-Timer-Expired Trigger at Form Level


IF GET_APPLICATION_PROPERTY( TIMER_NAME ) = ’ABOUT’
THEN
GO_ITEM( ’s_customer.id’);
END IF;

If you have time...


2 Automatically ask the users if they want to commit after a set period of
1
time.
a Open the CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING, which indicates at all times whether
rows of the S_CUSTOMER table are locked. Append the new code
to the end of the existing code.

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

......................................................................................................................................................
A-46 Developer/2000: Build Forms II
Practice 13 Solutions
......................................................................................................................................................

Write a When-Timer-Expired trigger to display an alert if locks are


d
still pending after a certain period of time elapses. This alert should
ask the user to commit or roll back the changes. You can replace the
existing code with the code from the pr13_2d.txt file.
Note: You need to create an alert called ASK_SAVE.
Define an alert (called ASK_SAVE) of style Caution with a Yes and a
No button. Define an appropriate message.

When-Timer-Expired Trigger at Form Level


IF GET_APPLICATION_PROPERTY( TIMER_NAME ) = ’ABOUT’'
THEN
GO_ITEM('s_customer.id');
ELSIF 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 the Post-Database-Commit trigger to give the NULL value to


the global variable.You can import the pr13_2e.txt file.

Post-Database-Commit Trigger at Form Level


:GLOBAL.locks_pending := NULL;

......................................................................................................................................................
Developer/2000: Build Forms II A-47
Appendix A: Practice Solutions
......................................................................................................................................................

f Create the On-Rollback trigger to implement the default rollback


processing and give the NULL value to the global variable. You can
import the pr13_2f.txt file.

On-Rollback Trigger at Form Level


ISSUE_ROLLBACK( GET_APPLICATION_PROPERTY( savepoint_name ) );
IF FORM_SUCCESS
THEN
:GLOBAL.locks_pending := NULL;
END IF;

......................................................................................................................................................
A-48 Developer/2000: Build Forms II
Practice 14 Solutions
......................................................................................................................................................

Practice 14 Solutions
1 Handle errors caused by declarative constraints violations.
aOpen the CUSTOMERS form module. This form is based on the
S_CUSTOMER table. A primary key constraint is declared on the
column Id.
b Run the CUSTOMERS form and try to add a new customer with an
existing customer number. Assign the new record an Id of 201 and a
name of Dummy. What FRM-error message do you get? What
Oracle server error message do you get? (Select [Display Error] to
see the message.)
FRM-40508: ORACLE error : unable to INSERT record.
ORA-00001: unique constraint
(schema.S_CUSTOMER_ID_PK) violated.
c Which trigger must you use to trap error messages caused by
violation of this constraint?
The On-Error trigger.
d Which built-in functions must you use to get error messages caused
by violations of this constraint?
The DBMS_ERROR_CODE and DBMS_ERROR_TEXT built-
in functions.
e Trap and replace the default constraint-violation message with your
own message. Use the function STRIP_CONSTRAINT_NAME to
detect which constraint was violated. You can import the
pr14_1e1.txt file to create the function and the
pr14_1e2.txt file to replace the existing code in the trigger.
Note: The function STRIP_CONSTRAINT_NAME accepts a complete
server error message, strips away the error number and prefix, and returns a
more readable error message. The details of this function are covered in
Appendix F, “Handling Server Side Errors.”
FUNCTION strip_constraint_name
/* Strips constraint name (without schema prefix) from server-error
message. */
( p_error_text IN VARCHAR2
)
RETURN VARCHAR2
IS
v_start_pos NUMBER(4);

......................................................................................................................................................
Developer/2000: Build Forms II A-49
Appendix A: Practice Solutions
......................................................................................................................................................

v_end_pos NUMBER(4);
BEGIN -- strip_constraint_name
/* Get position of dot, starting from position of left
parenthesis. */
v_start_pos := INSTR( p_error_text, ’.’, INSTR( p_error_text,
’(’ ) );
IF v_start_pos > 0 THEN
/* Get position of right parenthesis, starting from
position of dot. */
v_end_pos := INSTR( p_error_text, ’)’, v_start_pos );
/* Return constraint name between dot and right
parenthesis. */
RETURN( SUBSTR( p_error_text, v_start_pos + 1, v_end_pos -v_
start_pos - 1 ) );
ELSE
RETURN( null );
END IF;
END strip_constraint_name;

On-Error Trigger at Form Level


DECLARE
v_constraint_name VARCHAR2(255);
BEGIN
IF error_type = ’FRM’ AND error_code IN ( 40508, 40509,
40510) THEN
IF DBMS_ERROR_CODE in ( -1, -2290, -2291, -2292 ) THEN
/* PK/UK/FK/CK-constraint violation error. */
v_constraint_name := strip_constraint_name(
DBMS_ERROR_TEXT );
IF v_constraint_name = ’S_CUSTOMER_ID_PK’ THEN
MESSAGE( ’This customer already exists.’ );
END IF;
RAISE FORM_TRIGGER_FAILURE;
END IF;
END IF;
/* Show default FRM-error message. */
MESSAGE( ERROR_TYPE || TO_CHAR( -ERROR_CODE ) || ’: ’ ||
ERROR_TEXT );
RAISE FORM_TRIGGER_FAILURE;
END;

......................................................................................................................................................
A-50 Developer/2000: Build Forms II
Practice 14 Solutions
......................................................................................................................................................

fSave and compile the form. Try to insert a duplicate Id value, and
note the displayed message.
There is no formal solution.
If you have time ...
2 Handle errors caused by stored program units.
a Open the CUSTOMERS form module.
b Implement immediate primary-key checking in the CUSTOMERS
form by creating a procedure called CHECK_PK_CUST. Call this
procedure from an appropriate trigger. You can import the
pr14_2b1.txt file to create the procedure and the
pr14_2b2.txt file to replace the existing code in the trigger.
PROCEDURE check_pk_cust
( p_cust_id IN NUMBER
, p_rowid IN VARCHAR2
)
IS
CURSOR c_cust is
SELECT 0
FROM s_customer d
WHERE d.id = p_cust_id
AND ( d.rowid <> p_rowid OR p_rowid IS NULL );
r_cust c_cust%ROWTYPE;
cust_exists EXCEPTION;
BEGIN -- check_pk_cust
OPEN c_cust;
FETCH c_cust INTO r_cust;
IF c_cust%FOUND THEN
CLOSE c_cust;
RAISE cust_exists;
ELSE
CLOSE c_cust;
END IF;
EXCEPTION
WHEN cust_exists THEN
MESSAGE( ’This customer already exists.’ );
RAISE FORM_TRIGGER_FAILURE;
END check_pk_cust;

......................................................................................................................................................
Developer/2000: Build Forms II A-51
Appendix A: Practice Solutions
......................................................................................................................................................

When-Validate-Item Trigger on the S_CUSTOMER.ID Item


:global.customer_id := :s_customer.id;
CHECK_PK_CUST( :s_customer.id, :s_customer.rowid);
c Run the form and try to add a new customer with an existing
customer number. Enter an Id value of 201 and press [Next Item] to
fire the When-Validate-Item trigger. What error do you get?
This customer already exists.
This is the error message specified by the Forms Designer in
procedure CHECK_PK_CUST. It is not an FRM-error message
or an Oracle server error.
d Drag the CHECK_PK_CUST procedure to the database under your
user account. Delete the local CHECK_PK_CUST procedure in your
form.
There is no formal solution.
e Examine the stored procedure CHECK_PK_CUST in the Stored
Program Unit editor. Explain the errors that are shown. Correct the
errors by using RAISE_APPLICATION_ERROR.
The errors are caused because MESSAGE is a built-in procedure
and FORM_TRIGGER_FAILURE is a built-in exception to
Oracle Forms. It is therefore not known in the Oracle server.
Correct this by replacing the built-in procedure and the built-in
exception with a single statement, for example:
RAISE_APPLICATION_ERROR( -20000, ’This customer already exists.’);
f Run the form and try to add a new customer with an existing
customer number. What FRM-error messages do you get? What
Oracle server error message do you get? (Select [Display Error] to
see the message.)
FRM-40735: WHEN-VALIDATE-ITEM trigger raised
unhandled exception ORA-20000.
After selecting [Display Error] you get the following message:
FRM-42100: No errors encountered recently.
g Which trigger must you use to trap error messages caused by stored
procedures?
You must trap the error messages in the trigger in which you call
the stored procedure, in this case the When-Validate-Item
trigger.

......................................................................................................................................................
A-52 Developer/2000: Build Forms II
Practice 14 Solutions
......................................................................................................................................................

h Which built-in functions must you use to get error messages caused
by stored procedures?
The SQLCODE and SQLERRM functions.
i Trap and replace the default error message with your own message.
Use the function STRIP_APPLICATION_ERROR to get the
application-error text. You can import the pr14_2i1.txt file to
create the function and the pr14_2i2.txt file to replace the
existing code in the trigger.
FUNCTION strip_application_error
/* Strips application-error message, without error number, from
server-error message.
This is the first error of the full server-error message. */
( p_error_text in varchar2
)
RETURN VARCHAR2
IS
v_end_pos NUMBER(4);
BEGIN -- strip_application_error
/* Get position of (second) ORA-error, starting from
position 5. */
v_end_pos := INSTR( p_error_text, ’ORA-’, 5 ) - 2;
IF v_end_pos > 0 THEN
/* Return application error message (without ORA-error
number) before next ORA-error. */
RETURN( SUBSTR( p_error_text, 12, v_end_pos - 11 ) );
else
/* Server error only contains application error; remove
ORA-error in front. */
RETURN( SUBSTR( p_error_text, 12 ) );
END IF;
END strip_application_error;

When-Validate-Item Trigger on the S_CUSTOMER.ID Item


BEGIN
:GLOBAL.customer_id := :s_customer.id;
check_pk_cust( :s_customer.id, :s_customer.rowid) ;
EXCEPTION
WHEN OTHERS THEN
IF SQLCODE BETWEEN -20999 AND -20000 THEN

......................................................................................................................................................
Developer/2000: Build Forms II A-53
Appendix A: Practice Solutions
......................................................................................................................................................

/* Application error caused by database trigger or


stored program unit. */
MESSAGE( strip_application_error( SQLERRM ) );
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
j Save, compile and test the form.

......................................................................................................................................................
A-54 Developer/2000: Build Forms II
Practice 15 Solutions
......................................................................................................................................................

Practice 15 Solutions
1 Create a picklist by using the picklist class. This picklist enables the end
user to make selections from two lists, one showing the products
available and the other showing the objects selected.
Note: To reuse the code you wrote in practice 10 question 2, we have
provided most of the code by way of an object library.
a Create a new form module.
b Open the Form_Builder_II.olb object library.
c From the Picklist Basic tab page, drag and copy the
PICKLIST_BASIC object group to the Object Groups node in your
module and release it. Copy the object group, do not subclass the
object group. This object group contains a canvas, a window, and a
block. The block contains two buttons, with the code to return the
products selected in the picklist to the orders form.
d From the Picklist Class tab page, copy the PICKLIST object group
into your new form module. This object group contains all the
objects to implement the picklist. Organize the CONTROL block so
it is the last block in sequence.
Do this in the Object Navigator.
e Attach the picklist.pll library to your form.
f Create a When-New-Form-Instance trigger to populate the List_In.
Create an instance of the picklist with the CREATE_PICKLIST
procedure. Populate the List_in, using the
POPULATE_PICKLIST_WITH_QUERY function, with the results
of a query that returns the IDs, names, and suggested prices from the
S_PRODUCT table. (Retrieve the list of products excluding the
products that exists in the S_ITEM block. You should use the global
variable from practice 11.) Select the first element in the list by using
the SET_PICLIST_SELECTION procedure, and display both lists
by using the DISPLAY_PICKLIST procedure. You can import the
pr15_1f.txt file.
DECLARE
dummy NUMBER;
BEGIN
DEFAULT_VALUE(’’, ’GLOBAL.where_cls’);
pick_list.create_picklist;

......................................................................................................................................................
Developer/2000: Build Forms II A-55
Appendix A: Practice Solutions
......................................................................................................................................................

dummy :=
pick_list.populate_picklist_with_query(pick_list.list_in,
’SELECT name, id FROM s_product WHERE ’ || :GLOBAL.where_cls
|| ’ ORDER BY 1’);
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;
g Save your form using the filename PickList.fmb. Compile your
form.
h Open the ORDERS form module.
i Modify the When-Button-Pressed trigger for the
CONTROL.PRODUCT_LOV_BUTTON so that it calls your new
form module. Comment out the old CALL_FORM line, it called an
LOV from an earlier lab.
. . .
CALL_FORM(’picklist’, NO_HIDE );
. . .
jSave, run, and test your form.
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 pr15_2c.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-56 Developer/2000: Build Forms II
Practice 15 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 pr15_2d.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
’Order Date’, -- window title
’OK’, -- ok button label
’Cancel’, -- cancel button label
TRUE, -- highlight weekend days
FALSE, -- autoconfirm selection
FALSE); -- autoskip after selection
e Save, run, and test your form.

......................................................................................................................................................
Developer/2000: Build Forms II A-57
Appendix A: Practice Solutions
......................................................................................................................................................

......................................................................................................................................................
A-58 Developer/2000: Build Forms II
B
................................

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 Developer: Build Forms II
S_CUSTOMER Description
.....................................................................................................................................................

S_CUSTOMER Description
Column NameNull?Datatype
-----------------------------------------------------
ID NOT NULLNUMBER(7)
NAMENOT NULLVARCHAR2(50)
PHONE VARCHAR2(25)
ADDRESS VARCHAR2(400)
CITY VARCHAR2(30)
STATE VARCHAR2(20)
COUNTRYVARCHAR2(30)
ZIP_CODEVARCHAR2(75)
CREDIT_RATINGVARCHAR2(9)
SALES_REP_IDNUMBER(7)
REGION_IDNUMBER(7)
COMMENTSVARCHAR2(255)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-3
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_CUSTOMER Data

SQL> SELECT * FROM s_customer;

IdName Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
201Unisports 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.

202Oj Atheletics 81-20101 6741 Takashi Blvd.


Osaka Japan
Poor 14 4
Customer Should Always Pay By Cash Until His Credit Rating
Improves.

203Delhi 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 Developer: Build Forms II
S_CUSTOMER Data
.....................................................................................................................................................

S_CUSTOMER Data (continued)

IdName Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
204Womansport 1-206-104-0103 281 King Street
Seattle Washington USA
98101 EXCELLENT 11 1

205Kam’s Sporting Goods 852-3692888 15 Henessey Road


Hong Kong EXCELLENT 15 4

206Sportique 33-2257201 172 Rue de Rivoli


Cannes France
EXCELLENT 15 5
Customer specializes in Soccer. Likes to order accessories in
bright colors.

207Sweet Rock Sports 234-603620 6 Saint Antoine


Lagos Nigeria
GOOD 3

.....................................................................................................................................................
Oracle Developer: Build Forms II B-5
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_CUSTOMER Data (continued)

IdName Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
208Muench Sports 49-527454 435 Gruenestrasse
Stuttgart Germany
GOOD 15 5
Customer usually pays small orders by cash and large orders on
credit.

209Beisbol Si! 809-352689 789 Playa Del Mar


San Pedro de Macon’s Dominican Republic
EXCELLENT 11 1

210Futbol Sonora 52-404562 3 Via Saguaro Nogales


EXCELLENT 12 2
Customer is difficult to reach by phone. Try mail.

211Kuhn’s Sports 42-111292 7 Modrany


Prague Czechoslovakia
EXCELLENT 15 5

.....................................................................................................................................................
B-6 Oracle Developer: Build Forms II
S_CUSTOMER Data
.....................................................................................................................................................

S_CUSTOMER Data (continued)

IdName Phone Address


------ ------------------ ------------ -----------
City State Country
------------------ ---------------- -----------
Zip_code Credit_ra Sales_rep_id Region_id
---------- --------- ------------ ---------
Comments
--------------------------------------------------
212Hamada Sport 20-1209211 57A Corniche
Alexandria Egypt
EXCELLENT 13 3
Customer orders sea and water equipment.

213Big John’s Sports 1-415-555-6281 4783 18th Street Emporium


San Francisco CA USA
94117 EXCELLENT 11 1
Customer has a dependable credit record.

214Ojibway Retail 1-716-555-7171 415 Main Street


Buffalo NY USA
14202 POOR 11 1

215Sporta Russia 7-3892456 6000 Yekatamina


St. Petersburg Russia
POOR 15 5
This customer is very friendly, but has difficulty paying bills.
Insist upon cash.

15 rows selected.

Note: The above display has been formatted.

.....................................................................................................................................................
Oracle Developer: Build Forms II B-7
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_DEPT Description and Data


Column NameNull?Datatype
-------------------------------------------------
ID NOT NULLNUMBER(7)
NAMENOT NULLVARCHAR2(25)
REGION_IDNUMBER(7)

SQL> SELECT * FROM s_dept;

IDNAMEREGION_ID
------ ---------------------------------
10Finance1
31Sales1
32Sales2
33Sales3
34Sales4
35Sales5
41Operations1
42Operations2
43Operations3
44Operations4
45Operations5
50Administration1

12 rows selected.

.....................................................................................................................................................
B-8 Oracle Developer: Build Forms II
S_EMP Description
.....................................................................................................................................................

S_EMP Description
Column NameNull?Datatype
----------------------------------------------------
ID NOT NULLNUMBER(7)
LAST_NAMENOT NULLVARCHAR2(25)
FIRST_NAMEVARCHAR2(25)
USERIDVARCHAR2(8)
START_DATEDATE
COMMENTVARCHAR2(255)
MANAGER_IDNUMBER(7)
TITLE VARCHAR2(25)
DEPT_IDNUMBER(7)
SALARYNUMBER(11,2)
COMMISSION_PCTNUMBER(4,2)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-9
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_EMP Data

SQL> SELECT * FROM s_emp;

IDLAST_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 Developer: Build Forms II
S_EMP Data
.....................................................................................................................................................

S_EMP Data (continued)

IDLAST_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 Developer: Build Forms II B-11
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_EMP Data (continued)

IDLAST_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

25 rows selected.

Note: The above display has been formatted.


.....................................................................................................................................................
B-12 Oracle Developer: Build Forms II
S_ITEM Description
.....................................................................................................................................................

S_ITEM Description
Column NameNull?Datatype
-------------------------------------------------
ORD_IDNOT NULLNUMBER(7)
ITEM_IDNOT NULLNUMBER(7)
PRODUCT_IDNOT NULLNUMBER(7)
PRICE NUMBER(11,2)
QUANTITY NUMBER(9)
QUANTITY_SHIPPEDNUMBER(9)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-13
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_ITEM Data

SQL> SELECT * FROM s_item;

ORD_IDITEM_IDPRODUCT_IDPRICEQUANTITYQUANTITY_SHIPPED
-------------- ----------- -------------- -----------------
100110011135500500
100210013380400400
10031002114500500
100530326582600600
1007410108250250
10063043320450450
10041002336400400
101130421161515
10134101082020
1015501694.294040
101650417802727
101750530455050
101441100453535
101240422503030
10212010828100100
1022202011234545
103130433201515
10323277971111
10412051097 7
104430421163535
10422051281212
10433032116691919
10515027322.81616
105350532472828
105250419801313

.....................................................................................................................................................
B-14 Oracle Developer: Build Forms II
S_ITEM Data
.....................................................................................................................................................

S_ITEM Data (continued)

ORD_IDITEM_IDPRODUCT_IDPRICEQUANTITYQUANTITY_SHIPPED
-------------- ----------- -------------- -----------------
106120108284646
10645027322.897575
106550418759898
106650419802727
1062202011232121
1063501694.29125125
107120106115050
107320201115130130
107530421165555
10743032116697575
107220108282222
108120510999
108641080355050
108741100454242
108532861605757
10822051281818
10843277976060
10833032116698585
109110011140150150
10953042618.25500500
109750418754343
109632861605050
10943032658215001500
109210012175600600
10931002221.95300300
11015027322.891717
110250536502323
111140421652727
111241080352929
97120106910001000
9723032115005050
981404218577
9912051091818
9922051282525
99350417805353
99450530456969
112120106115050

62 rows selected.

Note: The above display has been formatted.

.....................................................................................................................................................
Oracle Developer: Build Forms II B-15
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_ORD Description and Data


Column NameNull?Datatype
---------------------------------------------------
ID NOT NULLNUMBER(7)
CUSTOMER_IDNOT NULL NUMBER(7)
DATE_ORDEREDDATE
DATE_SHIPPEDDATE
SALES_REP_IDNUMBER(7)
TOTAL NUMBER(11,2)
PAYMENT_TYPEVARCHAR2(6)
ORDER_FILLEDVARCHAR2(1)

SQL> SELECT * FROM s_ord;

ID CUSTOMER_IDDATE_ORDEDATE_SHIPSALES_REP_IDTOTALPAYMENORDER_F
--- -------------------------------------------------------------
100 204 31-AUG9210-SEP-9211601100CREDITY
101 205 31-AUG-9215-SEP-92148056.6CREDITY
102 206 01-SEP-9208-SEP-92158335CREDITY
103 208 02-SEP-9222-SEP-9215377CASHY
104 208 03-SEP-9223-SEP-921532430CREDITY
105 209 04-SEP-92 18-SEP-92112722.24CREDITY
106 210 07-SEP-92 15-SEP-921215634CREDITY
107 211 07-SEP-9221-SEP-9215142171CREDITY
108 212 07-SEP-9210-SEP-9213149570CREDITY
109 213 08-SEP-92 28-SEP-92111020935CREDITY
110 214 09-SEP-92 21-SEP-92111539.13CASHY
111 204 09-SEP-92 21-SEP-92112770CASHY
97 201 28-AUG-92 17-SEP-921284000CREDITY
98 202 31-AUG-92 10-SEP-9214595CASHY
99 203 31-AUG-92 18-SEP-92147707CREDITY
112 210 31-AUG-92 10-SEP-9212550CREDITY

16 rows selected.

.....................................................................................................................................................
B-16 Oracle Developer: Build Forms II
S_PRODUCT Description
.....................................................................................................................................................

S_PRODUCT Description
Column NameNull?Datatype
---------------------------------------------------
ID NOT NULLNUMBER(7)
NAMENOT NULLVARCHAR2(50)
SHORT_DESCVARCHAR2(255)
LONGTEXT_IDNUMBER(7)
IMAGE_ID NUMBER(7)
SUGGESTED_WHLSL_PRICE‘NUMBER(11,2)
WHLSL_UNITSVARCHAR2(25)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-17
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_PRODUCT Data

SQL> SELECT * FROM s_product;

ID NAMESHORT_DESCLONGTEXT_ID
-----------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
10011BootBeginner’s ski boot518
1001150

10012Ace Ski BootIntermediate ski boot519


1002200

10013Pro Ski BootAdvanced ski boot520


1003410

10021Bunny Ski PoleBeginner’s ski pole528


101116.25

10022Ace Ski PoleIntermediate ski pole529


101221.95

10023Pro Ski PoleAdvanced ski pole530


101340.95

20106Junior Soccer BallJunior soccer ball613


11

20108World Cup Soccer BallWorld cup soccer ball615


28

20201World Cup NetWorld cup net708


123

.....................................................................................................................................................
B-18 Oracle Developer: Build Forms II
S_PRODUCT Data
.....................................................................................................................................................

S_PRODUCT Data (continued)

ID NAMESHORT_DESCLONGTEXT_ID
-------------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
20510Black Hawk Knee pads, pair1017
Knee Pads9

20512Black Hawk Elbow pads, pair1019


Elbow Pads8

30321Grand Prix Bicycle Road bicycle828


12911669

30326Himalaya BicycleMountain bicycle833


1296582

30421Grand PrixRoad bicycle tires927


Bicycle Tires16

30426Himalaya TiresMountain bicycle tires933


18.25

30433New Air PumpTire pump940


20

32779Slaker Water Water bottle1286


Bottle7

32861Safe-T HelmetBicycle helmet1368


1829 60

40421Alexeyer ProStraight bar928


Lifting Bar
138165

40422Pro Curling BarCurling bar929


138250

.....................................................................................................................................................
Oracle Developer: Build Forms II B-19
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_PRODUCT Data (continued)

ID NAMESHORT_DESCLONGTEXT_ID
-------------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
40421Alexeyer ProStraight bar928
Lifting Bar
138165

40422Pro Curling BarCurling bar929


138250

41010Prostar 10 Ten pound weight517


Pound Weight
8

41020Prostar 20Twenty pound weight527


Pound Weight
12

41050Prostar 50 Fifty pound weight557


Pound Weight
25

41080Prostar 80 Eighty pound weight587


Pound Weight
35

41100Prostar 100 One hundred pound 607


Pound Weightweight
45

50169Major League Baseball676


Baseball
11194.29

.....................................................................................................................................................
B-20 Oracle Developer: Build Forms II
S_PRODUCT Data
.....................................................................................................................................................

S_PRODUCT Data (continued)

ID NAMESHORT_DESCLONGTEXT_ID
---------------------------------------------
IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS
----------------------------------------
50273Chapman HelmetBatting helmet780
122322.89

50417Griffey GloveOutfielder’s glove924


1367 80

50418Alomar GloveInfielder’s glove925


1368 75

50419Steinbach GloveCatcher’s glove926


1369 80

50530Cabrera BatThirty inch bat1037


1480 45

50532Puckett BatThirty-two inch bat1039


1482 47

50536Winfield BatThirty-six inch bat1043


1486 50

33 rows selected.

Note: The above display has been formatted.

.....................................................................................................................................................
Oracle Developer: Build Forms II B-21
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

S_REGION Description and Data


Column NameNull?Datatype
----------------------------------------------
ID NOT NULLNUMBER(7)
NAMENOT NULLVARCHAR2(50)

SQL> SELECT * FROM s_region;

IDNAME
--- --------------------------
1North America
2South America
3Africa / Middle East
4Asia
5Europe

.....................................................................................................................................................
B-22 Oracle Developer: Build Forms II
S_TITLE Description and Data
.....................................................................................................................................................

S_TITLE Description and Data


Column NameNull?Datatype
--------------------------------------------------
TITLENOT NULLVARCHAR2(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 Developer: Build Forms II B-23
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

Oracle8 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 Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

tables

oo_emp_Table_ObjCol
Name Null? Type
-------------------------------------------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAMEVARCHAR2(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_NAMEFIRST_NAME USERID
--------- --------------------- --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
-----------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1VelasquezCarmencvelasqu
03-MAR-90President
DEPT_TYPE(50, ’Administration’, 1)
2500

2NgaoLaDorislngao
08-MAR-901 VP Operations
DEPT_TYPE(41, ’Operations’, 1)
1450

3NagayamaMidorimnagayam
17-JUN-91 1 VP Sales
DEPT_TYPE(31, ’Sales’, 1)
1400

.....................................................................................................................................................
Oracle Developer: Build Forms II B-25
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
4 Quick-To-See Markmquickto
07-APR-901 VP Finance
DEPT_TYPE(10, ’Finance’, 1)
1450

5RopeburnAudryaropebur
04-MAR-901 VP Administration
DEPT_TYPE(50, ’Administration’, 1)
1550

6 Urguhart Mollymurguhar
18-JAN-91 2 Warehouse Manager
DEPT_TYPE(41, ’Operations’, 1)
1200

7 MenchuRobertarmenchu
14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, ’Operations’, 2)
1250

8 Biri Benbbiri
07-APR-902 Warehouse Manager
DEPT_TYPE(43, ’Operations’, 3)
1100

9 CatchpoleAntoinetteacatchpo
09-FEB-922 Warehouse Manager
DEPT_TYPE(44, ’Operations’, 4)
1300

.....................................................................................................................................................
B-26 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
10 HavelMartamhavel
27-FEB-912 Warehouse Manager
DEPT_TYPE(45, ’Operations’, 5)
1307

11 MageeColincmagee
14-MAY-903 Sales Representative
DEPT_TYPE(31, ’Sales’, 1)
140010

12 GiljumHenryhgiljum
18-JAN-92 3 Sales Representative
DEPT_TYPE(32, ’Sales’, 2)
149013

13 SedeghiYasminysedeghi
18-FEB-913 Sales Representative
DEPT_TYPE(33, ’Sales’, 3)
1515 10

14 NguyenMaimnguyen
22-JAN-923 Sales Representative
DEPT_TYPE(34, ’Sales’, 4)
1525 15

15 DumasAndreadumas
09-OCT-913 Sales Representative
DEPT_TYPE(35, ’Sales’, 5)
145018

.....................................................................................................................................................
Oracle Developer: Build Forms II B-27
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
16 MaduroElenaemaduro
07-FEB-926 Stock Clerk
DEPT_TYPE(41, ’Operations’, 1)
1400

17SmithGeorgegsmith
08-MAR-906 Stock Clerk
DEPT_TYPE(41, ’Operations’, 1)
940

18 NozakiAkiraanozaki
09-FEB-91 7 Stock Clerk
DEPT_TYPE(42, ’Operations’, 2)
1200

19PatelVikramvpatel
06-AUG-91 7 Stock Clerk
DEPT_TYPE(42, ’Operations’, 2)
795

20 NewmanChadcnewman
21-JUL-918 Stock Clerk
DEPT_TYPE(43, ’Operations’, 3)
750

21 MarkarianAlexanderamarkari
26-MAY-91 8 Stock Clerk
DEPT_TYPE(43, ’Operations’, 3)
850

.....................................................................................................................................................
B-28 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
22 ChangEddieechang
30-NOV-90 9 Stock Clerk
DEPT_TYPE(44, ’Operations’, 4)
800

23 PatelRadharpatel
17-OCT-909 Stock Clerk
DEPT_TYPE(34, ’Sales’, 4)
795

24 Dancs Belabdancs
17-MAR-9110 Stock Clerk
DEPT_TYPE(45, ’Operations’, 5)
860

25 SchwartzSylviesschwart
09-MAY-9110 Stock Clerk
DEPT_TYPE(45, ’Operations’, 5)
1100

oo_emp_Table_RefCol
Name Null? Type
-------------------------------------------------
ID NUMBER(7)
LAST_NAMEVARCHAR2(25)
FIRST_NAMEVARCHAR2(25)
USERIDVARCHAR2(8)
START_DATEDATE
MANAGER_IDNUMBER(7)
TITLE VARCHAR2(25)
DEPT_IDREF OF DEPT_TYPE
SALARYNUMBER(11,2)
COMMISSION_PCTNUMBER(4,2)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-29
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 Velasquez Carmencvelasqu
03-MAR-90President
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
2500

2NgaoLaDorislngao
08-MAR-90 1 VP Operations
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450

3 NagayamaMidorimnagayam
17-JUN-91 1 VP Sales
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400

4 Quick-To-SeeMarkmquickto
07-APR-90 1 VP Finance
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450

5 Ropeburn Audryaropebur
04-MAR-90 1 VP Administration
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1550

.....................................................................................................................................................
B-30 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
6 UrguhartMollymurguhar
18-JAN-912 Warehouse Manager
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1200

9 CatchpoleAntoinetteacatchpo
09-FEB-922 Warehouse Manager
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1300

10 Havel Martamhavel
27-FEB-91 2 Warehouse Manager
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1307

11 Magee Colincmagee
14-MAY-90 3 Sales Representative
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400 10

13 SedeghiYasminysedeghi
18-FEB-91 3 Sales Representative
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1515 10

.....................................................................................................................................................
Oracle Developer: Build Forms II B-31
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
14 NguyenMaimnguyen
22-JAN-92 3 Sales Representative
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1525 15

15 DumasAndreadumas
09-OCT-913 Sales Representative
0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450 18

16 MaduroElenaemaduro
07-FEB-92 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400

17 SmithGeorgegsmith
08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
940

18 NozakiAkiraanozaki
09-FEB-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1200

.....................................................................................................................................................
B-32 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
19 PatelVikramvpatel
06-AUG-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
795

20 NewmanChadcnewman
21-JUL-918 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
750

21 MarkarianAlexanderamarkari
26-MAY-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
850

22 ChangEddieechang
30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
800

23 PatelRadharpatel
17-OCT-90 9 Stock Clerk
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
795

.....................................................................................................................................................
Oracle Developer: Build Forms II B-33
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
24 DancsBelabdancs
17-MAR-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
860

25 SchwartzSylviesschwart
09-MAY-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1100

oo_dept_table
Name Null? Type
-------------------------------------------------
ID NUMBER
NAME VARCHAR2(25)
REGION_IDNUMBER(7)

ID NAME REGION_ID
-------------------------------------------------
10 Finance1
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

.....................................................................................................................................................
B-34 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

rel_emp_Table_Objcol
Name Null? Type
-------------------------------------------------
ID NUMBER(7)
LAST_NAMEVARCHAR2(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_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 VelasquezCarmencvelasqu
03-MAR-90President
DEPT_TYPE(50, ’Administration’, 1)
2500

2 NgaoLaDorislngao
08-MAR-90 1 VP Operations
DEPT_TYPE(41, ’Operations’, 1)
1450

3 NagayamaMidorimnagayam
17-JUN-91 1 VP Sales
DEPT_TYPE(31, ’Sales’, 1)
1400

.....................................................................................................................................................
Oracle Developer: Build Forms II B-35
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
4 Quick-To-SeeMarkmquickto
07-APR-90 1 VP Finance
DEPT_TYPE(10, ’Finance’, 1)
1450

5 RopeburnAudryaropebur
04-MAR-90 1 VP Administration
DEPT_TYPE(50, ’Administration’, 1)
1550

6 Urguhart Mollymurguhar
18-JAN-91 2 Warehouse Manager
DEPT_TYPE(41, ’Operations’, 1)
1200

7 Menchu Robertarmenchu
14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, ’Operations’, 2)
1250

8 Biri Benbbiri
07-APR-90 2 Warehouse Manager
DEPT_TYPE(43, ’Operations’, 3)
1100

9 CatchpoleAntoinetteacatchpo
09-FEB-92 2 Warehouse Manager
DEPT_TYPE(44, ’Operations’, 4)
1300

.....................................................................................................................................................
B-36 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
10 HavelMartamhavel
27-FEB-91 2 Warehouse Manager
DEPT_TYPE(45, ’Operations’, 5)
1307

11 MageeColincmagee
14-MAY-90 3 Sales Representative
DEPT_TYPE(31, ’Sales’, 1)
1400 10

12 GiljumHenryhgiljum
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 NguyenMaimnguyen
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 Developer: Build Forms II B-37
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
16 MaduroElenaemaduro
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 PatelVikramvpatel
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 Alexanderamarkari
26-MAY-91 8 Stock Clerk
DEPT_TYPE(43, ’Operations’, 3)
850

.....................................................................................................................................................
B-38 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
22 ChangEddieechang
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)
DEPT_ID REF OF DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)

.....................................................................................................................................................
Oracle Developer: Build Forms II B-39
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
1 Velasquez Carmen cvelasqu
03-MAR-90 President
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
2500

2 Ngao LaDoris lngao


08-MAR-90 1 VP Operations
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450

3 Nagayama Midori mnagayam


17-JUN-91 1 VP Sales
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400

4 Quick-To-See Mark mquickto


07-APR-90 1 VP Finance
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450

5 Ropeburn Audry aropebur


04-MAR-90 1 VP Administration
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1550

.....................................................................................................................................................
B-40 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
6 Urguhart Molly murguhar
18-JAN-91 2 Warehouse Manager
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1200

9 Catchpole Antoinette acatchpo


09-FEB-92 2 Warehouse Manager
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1300

10 Havel Marta mhavel


27-FEB-91 2 Warehouse Manager
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1307

11 Magee Colin cmagee


14-MAY-90 3 Sales Representative
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400 10

13 Sedeghi Yasmin ysedeghi


18-FEB-91 3 Sales Representative
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1515 10

.....................................................................................................................................................
Oracle Developer: Build Forms II B-41
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
14 Nguyen Mai mnguyen
22-JAN-92 3 Sales Representative
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1525 15

15 Dumas Andre adumas


09-OCT-91 3 Sales Representative
0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1450 18

16 Maduro Elena emaduro


07-FEB-92 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1400

17 Smith George gsmith


08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
940

18 Nozaki Akira anozaki


09-FEB-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1200

.....................................................................................................................................................
B-42 Oracle Developer: Build Forms II
Oracle8 objects: types, tables
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
19 Patel Vikram vpatel
06-AUG-91 7 Stock Clerk
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
795

20 Newman Chad cnewman


21-JUL-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
750

21 Markarian Alexander amarkari


26-MAY-91 8 Stock Clerk
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
850

22 Chang Eddie echang


30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
800

23 Patel Radha rpatel


17-OCT-90 9 Stock Clerk
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
795

.....................................................................................................................................................
Oracle Developer: Build Forms II B-43
Appendix B: Table Descriptions and Data
.....................................................................................................................................................

ID LAST_NAMEFIRST_NAMEUSERID
---------- --------------------------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
SALARY COMMISSION_PCT
---------- --------------
24 Dancs Bela bdancs
17-MAR-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
860

25 Schwartz Sylvie sschwart


09-MAY-91 10 Stock Clerk
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE0340800
2072C15B
1100

.....................................................................................................................................................
B-44 Oracle Developer: Build Forms II
C
................................

Project Builder
Addendum
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Objectives
After completing this addendum, you
should be able to do the following:
• Implement team development with
Project Builder
– Provide a Global Registry of common
types
– Import and export projects
– Print and distribute project reports

Copyright  Oracle Corporation, 1999. All rights reserved.

Objectives
• Customize Project Builder
– Create module types
– Create actions
– Create macros
– Customize the launcher
• Describe inheritance in Project Builder

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-2 Oracle Developer: Build Forms II
Introduction
.....................................................................................................................................................

Introduction
Overview
You have already seen how to use Project Builder. This appendix explains how to use
Oracle Developer Project Builder in a team environment, so that many developers can
be working together on the many files that make up a project. The appendix also
explains how to customize Oracle Developer Project Builder to the specific
requirements of your team, and how inheritance can be used to simplify
customization.

Objectives
After completing this appendix, you should be able to do the following:
• Team development with Project Builder.
– Provide a Global Registry of common types.
– Import/Export projects.
– Print and distribute project reports.
• Customize the Project Builder environment.
– Create module types
– Create actopms
– Create macros
– Add tools to the toolbar
• Describe inheritance in Project Builder.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-3
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Team Development with Project


Builder

Team Project
members administrator

Copyright  Oracle Corporation, 1999. All rights reserved.

Technical Note
In some cases, the project administrator may decide to share a project and allow more
than one user to update it. If a developer attempts to change a project, adding an entry
for example, Project Builder first checks whether the project has changed since it was
last read; if it has changed, Project Builder notifies the developer that the changes
cannot be saved, and rereads the latest version of the project. The developer can then
attempt to make the changes again. Project Builder never overwrites one developer’s
changes with another’s, thus avoiding “last write wins” problems.

.....................................................................................................................................................
C-4 Oracle Developer: Build Forms II
Team Development with Project Builder
.....................................................................................................................................................

Team Development with Project Builder


In a team environment, if one developer modifies a library that another depends on,
you can use Project Builder’s dependency management to track that dependency, just
as it would for a single user.

The Project Administrator


A project administrator is charged with creating projects and making them available to
developers or team members. The project administrator maintains the Global Registry
and modifies it as necessary, exporting the changes to the developers on the team.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-5
Appendix C: Project Builder Addendum
.....................................................................................................................................................

The Role of the Global Registry

• Shared by all developers


• Placed on a shared network drive
• Modified by the project administrator
• Saved to
ORACLE_HOME\PJ60\typesnn.upd,
where nn indicates the national
language

Copyright  Oracle Corporation, 1999. All rights reserved.

The Role of the User Registry

• Private to each user


• Placed on a local drive or on a network
drive
• Used to add private types
• Used to override the definitions of types
in the Global Registry

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-6 Oracle Developer: Build Forms II
Team Development with Project Builder
.....................................................................................................................................................

The Role of the Global Registry


Commonly, the Global Registry is shared by all developers. It contains the type
definitions that are shared across the team. To make it accessible to everybody, the
project administrator may place the Global Registry on a shared network drive.
Because this registry is shared by the whole team, to avoid conflicting changes only
the project administrator should make changes to it.
The recommended way to ensure this is to use the network file system’s file
permissions and access control to ensure that, although the whole team can read this
file, only the project administrator can modify it. Protecting the Global Registry in this
way also prevents accidental damage, such as a user’s inadvertently moving, deleting,
or overwriting the registry file.
The Global Registry file name is typesnn.upd where nn indicates the national
language. By default, this file is installed to ORACLE_HOME\PJ60.
This file may be globally writable on your platform by default.

The Role of the User Registry


As its name suggests, the User Registry is private to each individual user, and it is
normally placed either on a local drive on each user’s PC or on a private directory on a
network drive. (Under UNIX it is placed under the user’s home directory).
Because all users have their own User Registry, they can edit it freely, for example to
add private types or to override the definitions of types in the Global Registry.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-7
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Importing and Exporting


Projects
1. Select File—>Export or Import Project.
2. Enter details.

The project is saved to


ORACLE_HOME\PJ60\pjusernn.upd,
where nn indicates the national language.
Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-8 Oracle Developer: Build Forms II
Team Development with Project Builder
.....................................................................................................................................................

Importing and Exporting Projects


Projects are each stored each in their own project file. Projects may be private to an
individual developer or shared among several developers.
If a project is shared, the project administrator may decide to provide each developer
with a private copy of the project file, or developers may share a single copy on a
shared network drive. The best choice depends on whether every or only one
developer is allowed to modify the project.
If only one developer is allowed to modify a particular project, the simplest approach
is to place the project file on a file server, and protect the file against update in the
same way that the Global Registry is protected.
If more than one user is allowed to modify a project, the recommended way to share
these changes is for the project administrator to provide each user with a private copy
of the project. The user’s individual changes can then be shared by using Project
Builder’s export and import commands.

How to Export Projects


1 Select File—>Export Project.
2 Enter Details.
3 Click the Export button.
The project is exported to a file named
ORACLE_HOME\PJ60\pjusernn.upd, where nn indicates the national
language.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-9
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Generating and Printing


Project Reports

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-10 Oracle Developer: Build Forms II
Generating and Printing Project Reports
.....................................................................................................................................................

Generating and Printing Project Reports


With Project Builder, you can automatically print project reports showing information
about the projects under development. Project information can include information
about types you have defined, as well as actions and macros that work on them, and
information about the tools included in the launcher. You may also restrict the
information displayed in a report by selecting a filter. Choose File—>Print Project
Info. This displays the Print Project Info dialog box.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-11
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Defining New Module Types

Copyright  Oracle Corporation, 1999. All rights reserved.

Instructor Note
Demonstration:
1 Expand the User Registry.
2 Delete the ICO File type.
3 Select File––>New––>Type.
4 Explain the wizard and the properties.
5 Click the “Choose file for model ...” button.
6 From the lab directory, select the abort.ico file.
7 Choose an appropriate icon to represent the new ICO File type.

.....................................................................................................................................................
C-12 Oracle Developer: Build Forms II
Defining New Module Types
.....................................................................................................................................................

Defining New Module Types


Most common file types are predefined in Project Builder. However, your application
may need file types, or “module types,” that are not predefined. For example, you may
use a specific type of graphics editor whose file format is not predefined. Procedure
Builder can be expanded to support the new module type.
To define a new file type, select File––>New––>Type. The Module Type Wizard
welcome screen appears. To avoid seeing the welcome screen each time the wizard is
invoked, clear the check box.
You can also use the Module Type Wizard to edit existing module types. Simply
highlight the module type name in the Project Navigator, and select Tools––>Module
Type Wizard.
Click the Next button to continue.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-13
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Identifying New Module Types

Copyright  Oracle Corporation, 1999. All rights reserved.

Instructor Note
Demonstration:
1 Expand the User Registry.
2 Delete the ICO File type.
3 Select File––>New––>Type.
4 Explain the wizard and the properties.
5 Click the “Choose file for model ...” button.
6 From the lab directory, select the abort.ico file.
7 Choose an appropriate icon to represent the new ICO File type.

.....................................................................................................................................................
C-14 Oracle Developer: Build Forms II
Identifying New Module Types
.....................................................................................................................................................

Identifying New Module Types


The next panel of the Module Type Wizard enables you to choose a name and location
for the new module type.
If you have access to a file of the new type, click “Choose file for model” and select
the file from the Derive Type dialog box. Based on the file you select, the Module
Type Wizard populates several fields throughout the wizard with the appropriate
information.
Enter an internal name for the type in the Internal Name field. In most cases, this is
simply the file’s unique extension (for example, FM for FrameMaker files).
Enter a description for the type in the Description field. The name you enter appears
under the Global Types or User Types node.
Select the Global Registry option button if you want the type to be accessible to all
users, or the User Registry option button if you alone require access to the new type.
Click the Next button to continue.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-15
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Describing New Module Types

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-16 Oracle Developer: Build Forms II
Describing New Module Types
.....................................................................................................................................................

Describing New Module Types


The next panel of the Module Type Wizard enables you to define the format and
content of the new module type.
In the Filename format box, select the option button that describes how you want
Project Builder to recognize this type of file: by extension (enter the file extension) or
by pattern. A pattern is any literal string, or combination of a literal string and one of
the following built-in macros: b, d, f, or n.
Note: Macros are introduced later in this appendix.
In the File content box, select the option button that describes the content of the file:
Binary (for executables), Textual (for nonexecutables), or Non-file (for URLs,
database tables, or other entities not managed as files).
In the Options box, select the check boxes that describe other attributes for the type:
• Click “Version control files of this type” to automatically set the Version Control
file property to Yes for all files of this type. This also enables the Check In/Check
Out actions under File––>Administration.
• Click “Deliver files of this type” to automatically set the Deliver File property to
Yes for all files of this type.
• If files of this type become another type as a result of the Build action (as .fmb
files become .fmx files), select the target type from the “Build files of this type
into” drop-down list. If you don’t see the file you want, make sure the target type
has been defined. You may have to finish defining this type, define the target type,
then go back to the original type and select the target type from this drop-down list.
Click the Next button to continue.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-17
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Actions for New Object Types

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-18 Oracle Developer: Build Forms II
Actions for New Module Types
.....................................................................................................................................................

Actions for New Module Types


Use this panel to define and modify the actions associated with this type.
• To add an action to the type, click Add. The New Action dialog box is displayed.
• To change an action’s name, description, or default setting, select the action and
click Edit. The Edit Action dialog box is displayed.
• To remove an action from the type definition, select the action and click Remove.
• To make an action the type’s default, select the action and click Make Default. This
is the action that is invoked when you double-click an item of this type on the
Project Navigator. The action also appears at the top of the right-click menu for all
items of this type.
Note: Later in this appendix, you will learn how to create and edit actions.
If desired, click on the Name, Description, or Default headers to sort the list by these
respective columns. You can also resize the columns by placing the cursor on a column
until the arrow appears and dragging the arrows to increase or decrease the size. The
first column, which is unlabeled, contains the icons for the actions: inherited,
overridden, and default.
Click the Next button to continue.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-19
Appendix C: Project Builder Addendum
.....................................................................................................................................................

An Icon for New Object Types

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-20 Oracle Developer: Build Forms II
An Icon for New Module Types
.....................................................................................................................................................

An Icon for New Module Types


The last panel of the Module Type Wizard enables you to select an icon to represent
your type by using one of these methods:
• Select the From File check box, then use the Browse button to select a file. If you
selected “Choose file for model” on the second panel of this wizard, the
appropriate icon should be selected for you. If you need to select a file, try to
choose an executable or library file, both of which usually have icons associated
with them. If you choose a file that does not have an associated icon, an alert is
displayed.
• If you do not have access to a file with an appropriate icon, you can choose one
from the list of predefined icons. Making sure that the From file check box is
cleared, click the icon that you want to associate with this type.
Click Finish to complete your creation or modification of this type.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-21
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Modifying Types Using Actions

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

Copyright  Oracle Corporation, 1999. All rights reserved.

Technical Note
If you add an action to a type in the user registry, all objects of that type that reference
the user registry inherit the new action. If you add an action to an object, the action
applies only to that object, unless that object is a project or subproject. Then the action
applies to the child objects of the project if the action affects the type of the child
objects.

Instructor Note
Demonstration:
1 Expand the User Registry.
2 Select the SQL File type, and edit the properties.
3 Select the Run Script action and edit this action.
4 Explain the properties.
You can also delete this action and re-create it.

.....................................................................................................................................................
C-22 Oracle Developer: Build Forms II
Modifying Types Using Actions
.....................................................................................................................................................

Modifying Types Using Actions


You can change or add new actions:
1 In the Project Navigator, select the type or object that you want to modify.
2 From the pop-up menu, select New Action to display the Add Action dialog box.
3 Specify the following properties in the Add Action dialog box.
Property Description
Name Name for the action
Description Description of the action. If you add this action to the pop-up menu, the
description furnishes the menu item. If you choose not to enter a description,
the name of the action appears in the pop-up menu instead. If you want to use
keyboard mnemonics, mark the key you want to use by placing an ampersand
(&) in front of it; for example if you specify &Print as the description, the P
will furnish the mnemonic. If you want to include a nonmnemonic ampersand
in the command, use two ampersands (&&).
Pop-up Select the “Add to pop-up menu” check box if you want to include the action
menu in the pop-up menu associated with the type or object. If you choose not to
include the action in the pop-up menu, it will be inaccessible; you can hide
actions in this fashion without deleting them.
Select the Default check box if you want to make the action the default
(invoked by double-clicking).
Definition Specify the command string issued to invoke the action.
Insert Specify the application you want to use to perform the action from the
Application resulting Select an Application dialog box.
Insert Specify a macro that is expanded when the action is invoked.
Macro
Insert Input Insert Input Item is available only for global actions (Build, Deliver, or the
Item source control actions) and remains grayed out for other types of actions.
However, if you add an action that overwrites one of the global actions, Insert
Input Item becomes active and you can click it to select the type of input item
required (for example, .fmb, or files of the type Forms Document, are
required to build .fmx files). The input item you select either replaces any
selected text in the Action Definition text box or is inserted at the cursor
position.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-23
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Customizing Actions
by Using Macros

Simple macros: myprinter =


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

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-24 Oracle Developer: Build Forms II
Customizing Actions by Using Macros
.....................................................................................................................................................

Customizing Actions by Using Macros


If an action needs to include special parameters, you can customize the action with a
macro. Project Builder provides several macros for you to choose from, or you can
create your own.

Simple Macros
Simple macros are macros that equate to simple strings. When you reference such a
macro from an action or another macro, the macro will be replaced by that string. If
you want to reference a simple macro, insert the macro name, enclosed by braces,
within the action or macro at the point in the command where such a string would be
executed.

Built-in Macros
Built-in macros are macros provided by Project Builder for use with actions. These
macros have one character name and you cannot redefine the value.
Note: For a complete list of the built-in macros, see the Project Builder online Help.

Predefined Macros
These macros are customizable macros that are provided by Project Builder and
assigned preliminary values.
The values assigned to predefined macros are preliminary and easily customized to
suit your preferences. Possible values depend on the tools available on your platform.

Example
For Windows platforms, the macro D2KEDITOR is defined as
{EDITOR ? {EDITOR} : notepad}, which means that your default editor will be
Notepad unless you define a macro named EDITOR and equate it to another word-
processing program available in Windows.
In Motif, D2KEDITOR is defined as {EDITOR ? {EDITOR} : vi}, which means that
your default editor will be vi unless you define a macro named EDITOR and equate it
to another word-processing program available in Motif.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-25
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Defining and Using Macros

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

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-26 Oracle Developer: Build Forms II
Customizing Actions by Using Macros
.....................................................................................................................................................

Defining and Using a Macro


To define a macro, use the Add Macro dialog box to name your macro and equate it to
the string you want to execute when you use the macro.
To use a macro, insert the macro name, enclosed by braces, in the string comprising an
action or another macro definition.
Note: Placement of the macro reference is dictated by its value and how that relates to
the command you are modifying. In other words, put the macro where you would
normally enter the string to which the macro is equated.

Conditionalizing Macros
You can set the value of a macro depending on a condition. To do so, use the following
expression:
{macroname?expression1:expression2}
{EDITOR ? {EDITOR} : vi}

Label Description
macroname The name of the macro
expression1 The expression to which the macro is evaluated if the macro has been
defined and has an assigned value
expression2 The expression to which the macro is evaluated if the macro either has not
(Optional) been previously defined or has been defined but has no assigned value

Nesting Macros
You can nest a macro within another macro by inserting its name, enclosed by braces,
in the string to which the outer macro is equated.
The innermost macros is expanded first, followed by the next level, and then the next,
until the action containing the nested macros is evaluated and executed.
In addition, macros are recursively expanded. For example, if the value of a macro
named bar is set to the already-defined macro {foo}, when bar is referenced from
within an action or another macro, the value substituted for bar is the value of foo.

Preview Actions Mode


Preview Actions mode allows you to test actions and see what values will be used for
various parameters and macros without actually executing the action. When you
invoke an action in Preview Actions mode, the fully expanded action is displayed to
the screen. You can toggle Preview Actions mode on and off by selecting
Project—>Preview Actions from the main menu.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-27
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Customizing the Launcher

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-28 Oracle Developer: Build Forms II
Customizing the Launcher
.....................................................................................................................................................

Customizing the Launcher


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

Adding Launcher Icons


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

Editing Launcher Icons


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

.....................................................................................................................................................
Oracle Developer: Build Forms II C-29
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Inheritance in Project Builder


• Actions and macros can be defined for
types, projects, and components.
• Type action and macro definitions can
be overridden by the project or the
component.
• Every component also Type
Type
inherits from the
<Any File> type. Project
Project
• In Windows 95 and NT, file
type definitions are also Component
Component
automatically inherited.
Copyright  Oracle Corporation, 1999. All rights reserved.

Technical Note
In Windows 95, Windows 98 and Windows NT, actions defined in the registry for a
particular file type, such as Open, Edit, and Print, are automatically available in
Project Builder using a special notation. For example, [open {name}] means do
whatever Windows 95 defines as the Open action for this filename.

.....................................................................................................................................................
C-30 Oracle Developer: Build Forms II
Inheritance in Project Builder
.....................................................................................................................................................

Inheritance in Project Builder


Inheritance Overview
The Property Palette shows not only the properties, actions, and macros, but also
whether they are inherited or overridden.
An entry inherits from its type the properties, actions, and macros associated with that
type. These include properties such as whether the file is text or binary and the actions
to edit or build an entry of that type.
An entry also inherits properties, actions, and macros from the project. Properties
inherited from the project include the author of an entry. If actions or macros are added
to the project, they are inherited by all entries in the project.
Note: Some properties, actions and macros can be inherited from both the project and
the type. In this case, setting the value at the project level overrides the value set at the
type level.

Generic Types
Each type description applies to a single file type, with the exception of three
predefined types that provide generic definitions for text files (Text File type), the files
in which project information is stored
(Project type), and links to files within projects (Project Link type).
To view these type definitions, go to the Global Registry in the Project Navigator,
select one of the types, and select either Edit Type or Property Palette from the pop-up
menu.
Two generic types allow a property (such as Version Control File) or an action (such as
Edit) to be easily set across types without your having to define it individually for each
type.
Type Description
<Any File> Properties, actions, and macros are inherited by every type and
therefore every entry.
<Text File> Properties, actions, and macros are inherited by every type whose File
Contents property is set to Text rather than Binary.

.....................................................................................................................................................
Oracle Developer: Build Forms II C-31
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Actions
The three types of actions are:
• Predefined: Shipped with Project Builder
• User-defined: Custom actions, defined by
the developer
• Global:
– Included with Project Builder
– Implemented across projects and files

Copyright  Oracle Corporation, 1999. All rights reserved.

Technical Note
The command strings for predefined actions are platform-dependent and either are
based on tools commonly available on the platforms, or take advantage of commands
already registered by the operating system for the different types.
If your platform already recognizes commands associated with file types, you can take
advantage of these in your actions.
For example, if you want to create a Play action for video files on Windows and the
Windows Explorer has already associated a command with video files, you can use the
Windows command by enclosing it in brackets in your action definition; for example,
[play {n}], where {n} is the built-in macro that evaluates to the name of the item you
selected in the Project Navigator.

.....................................................................................................................................................
C-32 Oracle Developer: Build Forms II
Actions
.....................................................................................................................................................

Actions
Project Builder has three types of actions:
• Predefined actions
• User-defined actions
• Global actions

Predefined Actions
Predefined actions are shipped with Project Builder and are automatically available
through menu items or the toolbar.
Predefined actions vary from file type to file type. To determine which
predefined actions are available for a specific type:
1 Select that type in the Project Navigator.
2 Display the Property Palette.
3 View the entries under the Actions node.
Note: Predefined actions are completely customizable. Customization of predefined
actions is covered in detail in Appendix C, “Project Builder Addendum.”

User-Defined Actions
User-defined actions are custom actions and you define them explicitly. User defined
actions are covered in detail in Appendix C, “Project Builder Addendum.”

Global Actions
Global actions are included with Project Builder and work across projects and files,
adapting themselves to varied file types. The global actions are a subset of the
predefined actions and include the following:
• Build actions (Build Selection, Build Incremental, Build All)
• Packaging action (Deliver)
• Source control (Check In, Check Out, Get RCS Information, Lock File in RCS)

.....................................................................................................................................................
Oracle Developer: Build Forms II C-33
Appendix C: Project Builder Addendum
.....................................................................................................................................................

Summary
This addendum covers the following
topics:
• Team development with Project Builder
• Customize Project Builder
• Inheritance in Project Builder

Copyright  Oracle Corporation, 1999. All rights reserved.

.....................................................................................................................................................
C-34 Oracle Developer: Build Forms II
Summary
.....................................................................................................................................................

Summary
Team Development with Project Builder
• Provide a Global Registry of common types
• Import and export projects
• Print and distribute project reports

Customizing the Project Builder Environment


• Create connections
• Create actions
• Create macros
• Add tools to the toolbar

.....................................................................................................................................................
Oracle Developer: Build Forms II C-35
Appendix C: Project Builder Addendum
.....................................................................................................................................................

.....................................................................................................................................................
C-36 Oracle Developer: Build Forms II
D
................................

Introduction to
Oracle8 Object Features
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Objectives
After completing this appendix, you should
be able to:
• Describe the new Oracle8 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, 1999. All rights reserved.

......................................................................................................................................................
D-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................

Introduction
In this appendix you will review certain object features of Oracle8. This appendix also
explains how these objects are displayed in the Object Navigator.

......................................................................................................................................................
Oracle Developer: Build Forms II D-3
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

New Oracle8 Scalar Data Types

• NCHAR
• NVARCHAR2
• FLOAT
• NLS types

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-4 Oracle Developer: Build Forms II
New Oracle8 Data Types
......................................................................................................................................................

New Oracle8 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 Developer. The
new data types are automatically converted to existing Oracle Developer item data
types.

NLS Types
Oracle8 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
server in their native languages. NLS is discussed in Oracle8 Server Reference
Manual.

......................................................................................................................................................
Oracle Developer: Build Forms II D-5
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Types

Attributes

ORDER
po_no
custinfo
line_items
amount

Methods
Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-6 Oracle Developer: Build Forms 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 Developer: Build Forms II D-7
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Types

Ship
ORDER

Cancel
Check
status

Hold

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-8 Oracle Developer: Build Forms 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. And 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. 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.
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 Developer: Build Forms II D-9
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Tables

Object table based on object type

Copyright  Oracle Corporation, 1999. All rights reserved.

Instructor Note
At this point, review the fact that object types are not themselves objects. They are
only blueprints for objects.
The term object can be confusing because Oracle uses the term to refer to constructs
within the database; for example, tables, views, procedures, and so on. These objects
are not related to object types. Make certain your students are aware of the distinction
between these terms.

......................................................................................................................................................
D-10 Oracle Developer: Build Forms II
Creating Oracle8 Objects
......................................................................................................................................................

Creating Oracle8 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 Developer: Build Forms II D-11
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Columns

Object column based on object type

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-12 Oracle Developer: Build Forms II
Object Columns
......................................................................................................................................................

Object Columns
Another construct that can be based 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 Developer: Build Forms II D-13
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Views

Object
Object-oriented Relational
view
application table

Object views based on object types

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-14 Oracle Developer: Build Forms 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 Developer: Build Forms II D-15
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

INSTEAD-OF Triggers

DECLARE

BEGIN

EXCEPTION

END;

Nonupdatable view INSTEAD-OF trigger

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-16 Oracle Developer: Build Forms 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 INSTEAD-OF triggers can be used with any view, they are typically
needed with object views.

......................................................................................................................................................
Oracle Developer: Build Forms II D-17
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

References to Objects
OID

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-18 Oracle Developer: Build Forms 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 Developer: Build Forms II D-19
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Types in
Object Navigator

Copyright  Oracle Corporation, 1999. All rights reserved.

Object Type Wizard

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-20 Oracle Developer: Build Forms II
Displaying Oracle8 Objects in the Object Navigator
......................................................................................................................................................

Displaying Oracle8 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
Developer.

Oracle8 Type Wizard


You can create object types by using the Oracle8 Type Wizard, which enables you to
define attributes and methods.

......................................................................................................................................................
Oracle Developer: Build Forms II D-21
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Tables
in Object Navigator

Copyright  Oracle Corporation, 1999. All rights reserved.

Object Columns
in Object Navigator

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-22 Oracle Developer: Build Forms II
Displaying Oracle8 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 Developer: Build Forms II D-23
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object Views
in Object Navigator

Copyright  Oracle Corporation, 1999. All rights reserved.

INSTEAD-OF Trigger Dialog Box

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-24 Oracle Developer: Build Forms II
Displaying Oracle8 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:


• Oracle8 Server SQL Reference Manual
• Oracle8 Concepts Manual

......................................................................................................................................................
Oracle Developer: Build Forms II D-25
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Object REFs
in Object Navigator

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
D-26 Oracle Developer: Build Forms II
Displaying Oracle8 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 Developer: Build Forms II D-27
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

Summary
This appendix covers the following
topics:
• Oracle8 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, 1999. All rights reserved.

Summary
• 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, 1999. All rights reserved.

......................................................................................................................................................
D-28 Oracle Developer: Build Forms II
Summary
......................................................................................................................................................

Summary
New Oracle8 Data Types
Oracle8 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.

Oracle8 Objects In the Object Navigator


The Object Navigator can display certain types of objects.

......................................................................................................................................................
Oracle Developer: Build Forms II D-29
Appendix D: Introduction to Oracle8 Object Features
......................................................................................................................................................

......................................................................................................................................................
D-30 Oracle Developer: Build Forms II
E
................................

Menu Run-Time
Parameters
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Objectives

After completing this appendix, you


should be able to customize menu
modules by using substitution
parameters.

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
E-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................

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

Objectives
After completing this lesson, you should be able to customize menu modules
by using substitution parameters.

......................................................................................................................................................
Oracle Developer: Build Forms 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, 1999. All rights reserved.

User-Named Substitution
Parameters

Design time Run time


Copyright  Oracle Corporation, 1999. All rights reserved.

Instructor Note
Demonstration: Open the Customized Menu demonstration (menu.mmb)
and select the print option. Show the code and the use of the UN and PW
substitution parameters.

......................................................................................................................................................
E-4 Oracle Developer: Build Forms II
Substitution Parameters
......................................................................................................................................................

Substitution Parameters
What Is a Substitution Parameter?
A substitution parameter is a two-character variable of type CHAR that is
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 Developer: Build Forms II E-5
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Parameter Properties

--Name
Name
--Label
Label --Maximum
MaximumLength
Length
--Case
CaseRestriction
Restriction --Menu
MenuParameter
Parameter
--Conceal
ConcealData
Data Initial
Initial Value
Value
--Associated
AssociatedMenus
Menus --Required
Required
--Hint
Hint
Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
E-6 Oracle Developer: Build Forms II
Defining a User-Named Substitution Parameter
......................................................................................................................................................

Defining a User-Named Substitution Parameter


Creating a User-Named Substitution Parameter
You can create a user-named substitution parameter from the Object
Navigator:
1 Select the Parameters node.
2 Create a new parameter by clicking the Create icon.
Forms displays a new parameter.
3 Set the desired properties for the parameter.

Property Description
Name The two-letter parameter name
Label The text prompt for the parameter value that is displayed in
the Enter Parameter Values dialog box
Case Restriction The property that converts the case of the user’s input to
either uppercase, lowercase, or none
Conceal Data The property that determines whether the user’s 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 Developer: Build Forms II E-7
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Substitution Parameter
Built-ins

• QUERY_PARAMETER
• APPLICATION_PARAMETER

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

Instructor Note
You can prompt for several menu parameters by using the following syntax:
Query_Parameter(’&p1 &p2 &p3’);

......................................................................................................................................................
E-8 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
E-10 Oracle Developer: Build Forms 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 Developer: Build Forms II E-11
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

Summary

This appendix covered substitution


parameters.

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
E-12 Oracle Developer: Build Forms 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 Developer: Build Forms II E-13
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................

......................................................................................................................................................
E-14 Oracle Developer: Build Forms II
F
................................

Handling Server-Side
Errors
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

Objectives
After completing this appendix, you
should be able to:
• Handle server-side database errors
• Obtain the cause of declarative-
constraint violations

Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
F-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................

Introduction
Overview
This lesson covers the use of Oracle server features in Form Builder
applications. You will learn about 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 Developer: Build Forms II F-3
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

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, 1999. All rights reserved.

Instructor Note
Demonstration: Use the Handling of Server Errors (errh.fmb) file to
show the code for the STRIP_CONSTRAINT_NAME function. This
function forms part of the HANDLE_SERVER_ERROR procedure. Do not
talk through all of the code, because the HANDLE_SERVER_ERROR
procedure is covered later in this lesson.
Demonstration for next page pair: Use the Message (msg.fmb) file to
show how you can use your own message table to hold constraint messages.
Run the form and point out that two messages appear for foreign key
constraints.
Use the Handling of Server Errors (errh.fmb) file to show the code for
the STRIP_APPLICATION_ERROR function. This function is the form
part of the HANDLE_SERVER_ERROR procedure. Do not talk through all
the code, because the HANDLE_SERVER_ERROR procedure is covered
later in this lesson.

......................................................................................................................................................
F-4 Oracle Developer: Build Forms 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) violated—parent
key not found
ORA-02292: integrity constraint (schema.constraint) violated—child
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 Developer: Build Forms II F-5
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

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, 1999. 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, 1999. 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 Developer: Build Forms 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 Developer: Build Forms II F-7
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

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, 1999. 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, 1999. All rights reserved.

Instructor Note
Demonstration: Use the Handling of Server Errors (errh.fmb) file to
show the code for the HANDLE_SERVER_ERROR procedure. This
procedure contains both functions already discussed.

......................................................................................................................................................
F-8 Oracle Developer: Build Forms 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 Developer: Build Forms II F-9
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

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 PUs:
EXCEPTION
EXCEPTION
WHEN
WHEN OTHERS
OTHERS THEN
THEN
handle_server_error(SQLCODE,
handle_server_error(SQLCODE, SQLERRM);
SQLERRM);

Copyright  Oracle Corporation, 1999. All rights reserved.

Technical Note
Error code 40508 is insert failed. Error code 40509 is update failed. Error
code 40510 is delete failed.

Instructor Note
Demonstration: Use the Handling of Server Errors (errh.fmb)
demonstration file to show the code for the HANDLE_FRM_ERROR
procedure. This procedure is called from the On-Error trigger.
Explanation for the next page pair: Remind students that all DDL operations
issue an implicit commit and end the current transaction. Form Builder is not
allowed to process any pending changes.
Stress that FORMS_DDL itself does not issue an implicit commit, but any
DDL statement can.

......................................................................................................................................................
F-10 Oracle Developer: Build Forms 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 Developer: Build Forms II F-11
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

Summary

This appendix covered 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, 1999. All rights reserved.

......................................................................................................................................................
F-12 Oracle Developer: Build Forms 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 Developer: Build Forms II F-13
Appendix F: Handling Server-Side Errors
......................................................................................................................................................

......................................................................................................................................................
F-14 Oracle Developer: Build Forms II
G
................................

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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms 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 Developer: Build Forms II G-9
Appendix G: EMP_PKG Package
......................................................................................................................................................

......................................................................................................................................................
G-10 Oracle Developer: Build Forms II
H
................................

Working with ActiveX


Controls
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

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
event packages
• Customize event handling
Copyright  Oracle Corporation, 1999. All rights reserved.

......................................................................................................................................................
H-2 Oracle Developer: Build Forms II
Introduction
......................................................................................................................................................

Introduction
Overview
In this lesson, you will learn how to include and use ActiveX controls in
your Oracle 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
H-4 Oracle Developer: Build Forms II
What Are VBX, OCX, and ActiveX Controls?
......................................................................................................................................................

What Are VBX, OCX, and ActiveX Controls?


VBX, OCX, and ActiveX controls provide encapsulated functionality that
can be embedded 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 Microsoft’s
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 Microsoft’s third generation of control architecture, the first
being VBX controls and the second OCX controls.

......................................................................................................................................................
Oracle Developer: Build Forms 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, 1999. All rights reserved.

Instructor Note
ActiveX will work on the Web, but not with Forms for the Web.

......................................................................................................................................................
H-6 Oracle Developer: Build Forms 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.
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 Developer: Build Forms 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, 1999. All rights reserved.

Instructor Note
The following ActiveX controls are included with demonstrations:
• Image: Display and image files in a variety of formats. Similar to the
Form Builder image item.
• Sound: Play and record sound clips. Similar to the Form Builder sound
item.
• Spreadtable: Spreadtable, or grid, control.
• Tabsheet: Tab controls. Provides more presentation options than the
Form Builder tab canvas but is more complex to implement.
• Video: Play video (AVI) files.
Each of these controls has its own help file describing its properties,
methods, and events. These help files are located in the
ORACLE_HOME\TOOLS\DOC60 directory. You can also view them from within
Form Builder.
These controls are provided for demonstration purposes only. They are not
supported by Oracle Corporation.

......................................................................................................................................................
H-8 Oracle Developer: Build Forms 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 can be embedded 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 control’s 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 Developer: Build Forms 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, 1999. All rights reserved.

Creating an ActiveX
Control Item

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

......................................................................................................................................................
H-10 Oracle Developer: Build Forms 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 code—calling property accessors,
invoking methods, or responding to events—to 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 Developer: Build Forms 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, 1999. 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, 1999. 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 Developer: Build Forms 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 may 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
H-14 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. 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, 1999. All rights reserved.

......................................................................................................................................................
H-16 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. 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, 1999. All rights reserved.

......................................................................................................................................................
H-18 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
H-20 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. 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, 1999. All rights reserved.

......................................................................................................................................................
H-22 Oracle Developer: Build Forms 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 control’s native initialization events.

......................................................................................................................................................
Oracle Developer: Build Forms II H-23
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

Handling Exceptions

• When a failure occurs, the


FORMS_OLE_FAILURE is raised.
• Use the 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, 1999. All rights reserved.

Technical Note
The LAST_OLE_EXCEPTION built-in takes variables, not constants.

......................................................................................................................................................
H-24 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
H-26 Oracle Developer: Build Forms 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 Developer: Build Forms II H-27
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
.

Summary

• VBX, OCX, and ActiveX controls


• Differences among 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, 1999. All rights reserved.

......................................................................................................................................................
H-28 Oracle Developer: Build Forms 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 Developer: Build Forms II H-29
Appendix H: Working with ActiveX Controls
......................................................................................................................................................

......................................................................................................................................................
H-30 Oracle Developer: Build Forms II
I
................................

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, 1999. All rights reserved.

......................................................................................................................................................
I-2 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
I-4 Oracle Developer: Build Forms 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 Developer: Build Forms 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, 1999. All rights reserved.

......................................................................................................................................................
I-6 Oracle Developer: Build Forms 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
user’s 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 Developer: Build Forms II I-7
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................

......................................................................................................................................................
I-8 Oracle Developer: Build Forms II
J
................................

Instructor Note
Appendix J: Instructor Note
......................................................................................................................................................

Introduction
Project Builder is presented in Lesson 1. To help the students get familiar
with this tool, use it throughout the course.
A project named Oracle Developer: Build Forms II is provided, so that you can launch
all course demonstrations, PowerPoint slides, practice files, practice solutions, and the
final Summit application from Project Builder.

......................................................................................................................................................
J-2 Oracle Developer: Build Forms II
How the Project Is Organized
......................................................................................................................................................

How the Project Is Organized


Oracle Developer: Build Forms II contains the following subprojects and
subsubprojects:

Subproject Description
Instructor Contains all the demonstrations of the course. (Those
Demonstrations demonstrations are classified by lesson. Each lesson correspond to
a subsubproject.)
Instructor Slides Contains all the powerpoint slides of the course.
Practice Solutions Contains all the .fmb, .mmb files for the practice solutions
Start Forms Contains all the files (.tif, .ico, .fmb, ...) to start the practices
(Those files are similar to the one the students have.)
Summit Application Contains all the files (.tif, .ico, .fmb, ...) for the Summit
application (This application is similar to the one the students will
have after completing the Oracle Developer: Build Forms I and II
courses.)

......................................................................................................................................................
Oracle Developer: Build Forms II J-3
Appendix J: Instructor Note
......................................................................................................................................................

Project Setup
Importing the User Registry
1 Launch Project Builder.
The Welcome dialog box is displayed. Click the Cancel button.
2 Expand the User Registry node.
3 Delete all the entries (if any exist).
4 Select File––>Import Project.
The Import Options dialog box is displayed.
5 Click the Import types check box.
6 Click the Override existing types check box.
7 Click the Import button.
The Select File to Import dialog box is displayed.
8 From your course home directory, select the reg.upx file.
9 Click the Close button.
10 Expand the User Registry node and verify that the following types have
been imported:
- ICO File
- OLB File
- PPT File
- SQL File
- TIF File

......................................................................................................................................................
J-4 Oracle Developer: Build Forms II
Project Setup
......................................................................................................................................................

Loading the Project


1 Verify that no projects are loaded. If a project is loaded, select
File—>Close Project to close it.
2 Select File—>Open Project.
The Open Project dialog box is displayed.
3 From your course home directory, select the form2.upd file.
4 Expand the Oracle Developer: Build Forms II project node and verify
that the following subprojects exist:
- Instructor Demonstrations
- Instructor Slides
- Practice Solutions
- Start Forms
- Summit Application

Assigning a Connect String to the Project


1 Select File––>New––>Connection.
The Add Connection dialog box is displayed.
2 Enter SUMMIT in the Title field.
3 Enter your instructor user name in the Username field.
4 Enter your instructor password in the Password field.
5 Enter the database connect string corresponding to your instructor
account in the Database field.
6 Click the OK button.
7 Expand the Connections node and select the SUMMIT connection.
8 Drag the SUMMIT connection to the Oracle Developer: Build Forms II
project node.
All the files in the project have inherited this connection.

......................................................................................................................................................
Oracle Developer: Build Forms II J-5
Appendix J: Instructor Note
......................................................................................................................................................

Changing the Project Directory Paths


For each project, subproject, and subsubproject you will have to set the
Project Directory property. This property indicates to Project Builder in
which directory the project, subproject, and subsubproject files are located.
You must define this property.
If your course home directory is C:\Forms2, your demonstration directory is
C:\Forms2\Demos, your slides directory is C:\Forms2\Slides , your labs directory
is C:\Forms2\Labs, your lab solutions directory is C:\Forms2\Lab_Sol, and your
Summit application directory is C:\Forms2\Summit, you should enter the following
values in the Project Directory property:

Value for the Project


Project-Subproject-SubSubproject Directory property
Oracle Developer: Build Forms II Project C:\Forms2

Instructor Demos Subproject C:\Forms2\Demos

Lesson 02 and 03: Menus Subsubproject C:\Forms2\Demos

Lesson 04: Programming Function Keys Subsubproject C:\Forms2\Demos

Lesson 05: Responding to Mouse Events Subsubproject C:\Forms2\Demos

Lesson 06: Controlling Windows and Canvases Programmat- C:\Forms2\Demos


ically Subsubproject
Lesson 07: Controlling Data Block Relationships Subsub- C:\Forms2\Demos
project
Lesson 08: Building Multiple Form Applications Subsub- C:\Forms2\Demos
project
Lesson 09: Defining Data Sources Subsubproject C:\Forms2\Demos

Lesson 10: Working with Record Groups Subsubproject C:\Forms2\Demos

Lesson 11: Including Charts and Reports Subsubproject C:\Forms2\Demos

Lesson 12: Applying Timers Subsubproject C:\Forms2\Demos

Lesson 13: Reusable Components Subsubproject C:\Forms2\Demos

Lesson 14: Using Server Features in Form Builder Subsub- C:\Forms2\Demos


project
Appendix H: Working With ActiveX Controls Subsubproject C:\Forms2\Demos

......................................................................................................................................................
J-6 Oracle Developer: Build Forms II
Project Setup
......................................................................................................................................................

Value for the Project


Project-Subproject-SubSubproject Directory property
Instructor Slides Subproject C:\Forms2\Slides

Practice Solutions Subproject C:\Forms2\Labs

Start Forms Subproject C:\Forms2\Lab_Sol

Summit Application Subproject C:\Forms2\Summit

To set this property, do the following:


1 Select Tools—>Property Palette.
2 Select the Project Directory property.
3 Click the button next to the Project Directory property.
The Property Editor dialog box is displayed.
4 Select the appropriate directory for the current project, subproject, or
subsubproject.

......................................................................................................................................................
Oracle Developer: Build Forms II J-7
Appendix J: Instructor Note
......................................................................................................................................................

Launching the Files


Launching a Powerpoint Slide
1 Expand the Instructor Slides subproject node.
2 Expand the PPT file node.
3 Double-click on the lesson you want to displayed.

Launching a Demonstration File


Be aware that the demonstration files have not been compiled. In other
words, it means that no fmx and mmx files are available. You have to
compile them before you can run a demonstration.
We strongly recommend that before you start to teach the course you
compile all the files.
Also, because the Compile Selection option in Project Builder do not work
properly, we recommend that you launch Form Builder, open each .fmb and
.mmb files, and compile them.
1 Expand the Instructor Demonstrations subproject node.
2 Expand the subsubproject node corresponding to the current lesson.
3 Expand the Forms Builder executable node.
4 Select the demonstration you want to show.
5 Click on the right mouse button.
A pop-up menu is displayed.
6 Select the Run option.

Running a SQL Script


1 Select the SQL script.
2 Click on the right mouse button.
3 Select the Run Script option.

Important Note
Whenever this book asks you to run a demonstration, it refers to the name of
the demonstration in Project Builder. By default, the demonstration will be
located in the subsubproject corresponding to the current lesson.
Enjoy your teaching!

......................................................................................................................................................
J-8 Oracle Developer: Build Forms II

S-ar putea să vă placă și