Top Banner
....................................................................................... 44112GC10 Production 1.0 May 1999 M08752 Oracle Developer: Build Forms II Volume 2 • Instructor Guide
264

Build Forms II - Volume 2 _ Instructor Guide

Apr 10, 2015

Download

Documents

api-3833282
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Build Forms II - Volume 2 _ Instructor Guide

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

44112GC10

Production 1.0

May 1999

M08752

Oracle Developer: Build Forms II

Volume 2 • Instructor Guide

Page 2: Build Forms II - Volume 2 _ Instructor Guide

Author

Mark Sullivan

Technical Contributors and Reviewers

Louise Barnfield

Gunnar Boehrs

Jacquelyn Bruce

Phyllis Chan

Bulent Cinarkaya

Laurent Dereac

Mark Doran

Gillian Elias

Tushar Gadhia

Stephen Gramann

Nancy Greenberg

Ursula Hovy

Uwe Jentzsch

Leta A. Johnson

Jan Keuben

Steve Lirette

Jayne Marlow

Rita Morin

Daphne Nougier

Christin Nowakowski

Bryan Roberts

Bert Salyga

Helene Schwann

Hiroyuki Sugiyama

Pal Tarcsay

Bart Van der Laar

Jack Walsh

Publisher

Kelly Lee

Sherry Polm

Copyright Oracle Corporation, 1999. All rights reserved.

This documentation contains proprietary information of Oracle Corporation. It isprovided under a license agreement containing restrictions on use and disclosureand is also protected by copyright law. Reverse engineering of the software isprohibited. If this documentation is delivered to a U.S. Government Agency of theDepartment of Defense, then it is delivered with Restricted Rights and thefollowing legend is applicable:

Restricted Rights LegendUse, duplication or disclosure by the Government is subject to restrictions forcommercial computer software and shall be deemed to be Restricted Rightssoftware under Federal law, as set forth in subparagraph (c) (1) (ii) of DFARS252.227-7013, Rights in Technical Data and Computer Software (October 1988).

This material or any portion of it may not be copied in any form or by any meanswithout the express prior written permission of the Worldwide Education Servicesgroup of Oracle Corporation. Any other copying is a violation of copyright law andmay result in civil and/or criminal penalties.

If this documentation is delivered to a U.S. Government Agency not within theDepartment of Defense, then it is delivered with “Restricted Rights,” as defined inFAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).

The information in this document is subject to change without notice. If you findany problems in the documentation, please report them in writing to EducationProducts, Oracle Corporation, 500 Oracle Parkway, Box 659806, RedwoodShores, CA 94065. Oracle Corporation does not warrant that this document iserror-free.

Oracle Developer, Oracle Server, and PL/SQL are trademarks or registeredtrademarks of Oracle Corporation.

All other products or company names are used for identification purposes only,and may be trademarks of their respective owners.

Page 3: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Contents

PrefaceProfile xv

Related Publications xvi

Typographic Conventions xvii

Lesson 1: Managing Projects with Project BuilderIntroduction 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 ModuleIntroduction 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

Page 4: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 5: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Contents

Lesson 5: Responding to Mouse EventsIntroduction 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 ProgrammaticallyIntroduction 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 SourcesIntroduction 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 Tableof Records 7-17

Page 6: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 7: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 8: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................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 ReportsIntroduction 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 TimersIntroduction 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 BuilderIntroduction 14-3

Using Oracle Server Functionality in Forms 14-5

Dealing with PL/SQL Code 14-7

Page 9: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 10: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Contents

Practice 13 Solutions A-45

Practice 14 Solutions A-49

Practice 15 Solutions A-55

Appendix B: Table Descriptions and DataSummit 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 AddendumIntroduction 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

Page 11: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Contents

Summary C-35

Appendix D: Introduction to Oracle8 Object FeaturesIntroduction 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 ParametersIntroduction 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 ErrorsIntroduction 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 PackagePackage Specification G-2

Package Body G-4

Appendix H: Working with ActiveX ControlsIntroduction H-3

Page 12: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................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 TimeUsing Oracle Server Roles at Run Time I-3

Procedures for Managing Roles I-7

Appendix J: Instructor NoteIntroduction J-2

How the Project Is Organized J-3

Project Setup J-4

Launching the Files J-8

Page 13: Build Forms II - Volume 2 _ Instructor Guide

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

A

Practice Solutions

Page 14: Build Forms II - Volume 2 _ Instructor Guide

A-2 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 1 Solutions1 Create a connection to the database.

a Create a new connection.

File––>New––>Connectionb 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 Wizardb 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

Page 15: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-3......................................................................................................................................................

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

Page 16: Build Forms II - Volume 2 _ Instructor Guide

A-4 Developer/2000: Build Forms II......................................................................................................................................................

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

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

Page 17: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-5......................................................................................................................................................

......................................................................................................................................................Practice 2 Solutions

Practice 2 Solutions1 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:

Page 18: Build Forms II - Volume 2 _ Instructor Guide

A-6 Developer/2000: Build Forms II......................................................................................................................................................

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

• File Menu

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

Label

Menu Item Type

Command Type

Menu Item Code

Visible in Menu

Visible in Horiz. Menu Toolbar

Icon Filename

Save Plain PL/SQL DO_KEY(’COMMIT_FORM’);

Yes Yes Save

Clear Plain PL/SQL DO_KEY(’CLEAR_FORM’);

Yes Yes Abort

Null1 Separator Null Yes Yes

Exit Plain PL/SQL DO_KEY(’EXIT_FORM’);

Yes Yes Exit

Null2 Separator Null No Yes

LabelMenu Item Type

Magic Item

Command Type

Visible in Menu

Visible in Horiz. Menu Toolbar

Icon Filename

Cut Magic Cut Null Yes Yes Cut

Copy Magic Copy Null Yes Yes Copy

Page 19: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-7......................................................................................................................................................

......................................................................................................................................................Practice 2 Solutions

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

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:

Paste Magic Paste Null Yes Yes Paste

Null3 Separator Null No Yes

Menu Label

Menu Item Type

Menu Item Radio Group

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

LabelMenu Item Type

Magic Item

Command Type

Visible in Menu

Visible in Horiz. Menu Toolbar

Icon Filename

Page 20: Build Forms II - Volume 2 _ Instructor Guide

A-8 Developer/2000: Build Forms II......................................................................................................................................................

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

• Query Menu

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

LabelMenu Item Type

Command Type Menu Item Code

Visible in Horiz. Menu Toolbar

Icon Filename

Enter Query

Plain PL/SQL DO_KEY(’ENTER_QUERY’);

Yes query

eXe-cute Query

Plain PL/SQL DO_KEY(’EXECUTE_QUERY’);

Yes execute

Page 21: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-9......................................................................................................................................................

......................................................................................................................................................Practice 3 Solutions

Practice 3 Solutions1 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:

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;

Menu Label Menu Item Type Command Type

Image Activate Check PL/SQL

Page 22: Build Forms II - Volume 2 _ Instructor Guide

A-10 Developer/2000: Build Forms II......................................................................................................................................................

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

END;

d Save and compile the menu module.

e Run and test the ORDERS form.

2 Synchronize the menu module with the form.

a Write startup code for the M_SUMMIT menu module that synchronizes the Image Activate menu item with the Image button. You can import the pr3_2a.txt file.

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;

b Save and compile your module.

3 The menu items Sort By and Image are not relevant to the CUSTOMERS form and therefore should have no effect.

a Attach the menu module to the CUSTOMERS form.

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'

Page 23: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-11......................................................................................................................................................

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

Page 24: Build Forms II - Volume 2 _ Instructor Guide

A-12 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 4 Solutions1 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 LevelCREATE_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...

Page 25: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-13......................................................................................................................................................

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

Key-Entqry on the S_ORD BlockENTER_QUERY;

Key-CreRec on the S_ORD BlockCREATE_RECORD;

Key-ClrBlk on the S_ORD BlockCLEAR_BLOCK;

Key-Up on the S_ORD BlockUP;

Key-Down on the S_ORD BlockDOWN;

Key-Others on the S_ORD BlockMESSAGE(’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.

Page 26: Build Forms II - Volume 2 _ Instructor Guide

A-14 Developer/2000: Build Forms II......................................................................................................................................................

......................................................................................................................................................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 LevelSET_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 ItemRemove the existing code and replace with the following code.

DO_KEY(’exit_form’);

Page 27: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-15......................................................................................................................................................

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

Page 28: Build Forms II - Volume 2 _ Instructor Guide

A-16 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 5 SolutionsIn 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.commentsEDIT_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 LevelIF :SYSTEM.MOUSE_CANVAS = ’CV_ORDER’THEN :control.show_help_button := ’?’;END IF;

Page 29: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-17......................................................................................................................................................

......................................................................................................................................................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_buttonSHOW_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_buttonHIDE_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_buttonHIDE_VIEW(’cv_help’);

GO_ITEM(:GLOBAL.save_item_name);

Page 30: Build Forms II - Volume 2 _ Instructor Guide

A-18 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 6 Solutions1 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 LevelIF :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> andGLOBAL.HEIGHT_<window_name>

Page 31: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-19......................................................................................................................................................

......................................................................................................................................................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 LevelEXECUTE_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 Levelcheck_window_size( :SYSTEM.EVENT_WINDOW );

Page 32: Build Forms II - Volume 2 _ Instructor Guide

A-20 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 33: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-21......................................................................................................................................................

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

Page 34: Build Forms II - Volume 2 _ Instructor Guide

A-22 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 35: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-23......................................................................................................................................................

......................................................................................................................................................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, NumberNAME, 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:

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.

Argument Type Type Name Mode Value

Resultset RefCursor (No Value) In Out (No Value)

P_View Varchar2 (No Value) In :Choose.View_Type

Page 36: Build Forms II - Volume 2 _ Instructor Guide

A-24 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 37: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-25......................................................................................................................................................

......................................................................................................................................................Practice 8 Solutions

Practice 8 Solutions1 Create a block based on a relational table.

a Create a new form called OO_DEPT.

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.

Page 38: Build Forms II - Volume 2 _ Instructor Guide

A-26 Developer/2000: Build Forms II......................................................................................................................................................

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

b Create a block by using the Data Block Wizard. Base the block on the relational table REL_EMP_TABLE_OBJCOL. Select the columns ID, FIRST_NAME, and LAST_NAME. Expand the object column DEPT_ID and select the attributes ID and NAME. Note the name that is given to the new item. Do not enforce data integrity.

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.

Page 39: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-27......................................................................................................................................................

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

Page 40: Build Forms II - Volume 2 _ Instructor Guide

A-28 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 41: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-29......................................................................................................................................................

......................................................................................................................................................Practice 9 Solutions

Practice 9 Solutions1 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:

b Use the Layout Editor to position the checkboxes appropriately in the Toolbar canvas.

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 Other Value

CHECKED UNCHECKED

Keyboard Navigable No No

Mouse Navigate No No

Data Type CHAR CHAR

Initial Value Y Y

DataBase Item No No

Canvas TOOLBAR TOOLBAR

Page 42: Build Forms II - Volume 2 _ Instructor Guide

A-30 Developer/2000: Build Forms II......................................................................................................................................................

......................................................................................................................................................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.IMMEDIATEIF 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_quer y’, ENABLED, PROPERTY_TRUE );

ELSE

SET_RELATION_PROPERTY(’s_ord_s_item’, DEFERRED_COORDINATION, PROPERTY_FALSE);

SET_ITEM_PROPERTY(’control.auto_quer y’, 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_QUERYIF GET_RELATION_PROPERTY(’s_ord_s_item’, AUTOQUERY ) = ’FALSE’

THEN

SET_RELATION_PROPERTY(’s_ord_s_item’, AUTOQUERY, PROPERTY_TRUE );

ELSE

SET_RELATION_PROPERTY(’s_ord_s_item’, AUTOQUERY, PROPERTY_FALSE);

END IF;

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

Page 43: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-31......................................................................................................................................................

......................................................................................................................................................Practice 9 Solutions

b Create a new block by using the Data Block Wizard. Base the block 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

Page 44: Build Forms II - Volume 2 _ Instructor Guide

A-32 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 45: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-33......................................................................................................................................................

......................................................................................................................................................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 Blockcheck_del_cus(:s_customer.id);

DELETE_RECORD;

d Save, compile, and run the module.

Page 46: Build Forms II - Volume 2 _ Instructor Guide

A-34 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 10 Solutions1 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 ItemDECLARE

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

Page 47: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-35......................................................................................................................................................

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

Page 48: Build Forms II - Volume 2 _ Instructor Guide

A-36 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 11 Solutions1 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;

Page 49: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-37......................................................................................................................................................

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

Page 50: Build Forms II - Volume 2 _ Instructor Guide

A-38 Developer/2000: Build Forms II......................................................................................................................................................

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

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;

Page 51: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-39......................................................................................................................................................

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

Page 52: Build Forms II - Volume 2 _ Instructor Guide

A-40 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 53: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-41......................................................................................................................................................

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

Page 54: Build Forms II - Volume 2 _ Instructor Guide

A-42 Developer/2000: Build Forms II......................................................................................................................................................

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

Practice 12 Solutions1 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.

Page 55: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-43......................................................................................................................................................

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

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.

Page 56: Build Forms II - Volume 2 _ Instructor Guide

A-44 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 57: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-45......................................................................................................................................................

......................................................................................................................................................Practice 13 Solutions

Practice 13 Solutions1 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;

Page 58: Build Forms II - Volume 2 _ Instructor Guide

A-46 Developer/2000: Build Forms II......................................................................................................................................................

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

When-Timer-Expired Trigger at Form LevelIF 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 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 LevelDECLARE

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;

When-Timer-Expired Trigger at Form LevelIF GET_APPLICATION_PROPERTY( TIMER_NAME ) = ’ABOUT’

THEN

GO_ITEM( ’s_customer.id’);

END IF;

If you have time...

1 Automatically ask the users if they want to commit after a set period of time.

a Open the CUSTOMERS form module.

b At the startup of the form, create a global variable called GLOBAL.LOCKS_PENDING, which indicates at all times whether rows of the S_CUSTOMER table are locked. Append the new code to the end of the existing code.

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 LevelDECLARE

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;

Page 59: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-47......................................................................................................................................................

......................................................................................................................................................Practice 13 Solutions

d Write a When-Timer-Expired trigger to display an alert if locks are still pending after a certain period of time elapses. This alert should ask the user to commit or roll back the changes. You can replace the existing code with the code from the pr13_2d.txt file.

Note: You need to create an alert called ASK_SAVE.

Define an alert (called ASK_SAVE) of style Caution with a Yes and a No button. Define an appropriate message.

When-Timer-Expired Trigger at Form LevelIF 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;

Page 60: Build Forms II - Volume 2 _ Instructor Guide

A-48 Developer/2000: Build Forms II......................................................................................................................................................

......................................................................................................................................................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 LevelISSUE_ROLLBACK( GET_APPLICATION_PROPERTY( savepoint_name ) );

IF FORM_SUCCESS

THEN

:GLOBAL.locks_pending := NULL;

END IF;

Page 61: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-49......................................................................................................................................................

......................................................................................................................................................Practice 14 Solutions

Practice 14 Solutions 1 Handle errors caused by declarative constraints violations.

a Open 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);

Page 62: Build Forms II - Volume 2 _ Instructor Guide

A-50 Developer/2000: Build Forms II......................................................................................................................................................

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

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;

Page 63: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-51......................................................................................................................................................

......................................................................................................................................................Practice 14 Solutions

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

Page 64: Build Forms II - Volume 2 _ Instructor Guide

A-52 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 65: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-53......................................................................................................................................................

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

: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

Page 66: Build Forms II - Volume 2 _ Instructor Guide

A-54 Developer/2000: Build Forms II......................................................................................................................................................

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

Page 67: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-55......................................................................................................................................................

......................................................................................................................................................Practice 15 Solutions

Practice 15 Solutions1 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;

Page 68: Build Forms II - Volume 2 _ Instructor Guide

A-56 Developer/2000: Build Forms II......................................................................................................................................................

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

. . .

j Save, 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

Page 69: Build Forms II - Volume 2 _ Instructor Guide

Developer/2000: Build Forms II A-57......................................................................................................................................................

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

Page 70: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 71: Build Forms II - Volume 2 _ Instructor Guide

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

B

Table Descriptions andData

Page 72: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-2 Oracle Developer: Build Forms II

.....................................................................................................................................................Appendix B: Table Descriptions and Data

Summit Sporting Goods Database Diagram

*Unique occurrences are identified by PRODUCT_ID and WAREHOUSE_ID.

S_ITEM

S_INVENTORY

S_ORD

S_CUSTOMER

S_EMP

S_DEPT

S_IMAGE

S_PRODUCT

ORD_IDID

SALES_REP_ID

PRODUCT_ID

CUSTOMER_ID

SALES_REP_ID

DEPT_ID

IMAGE_ID

PRODUCT_ID

ID

ID

ID

IDID

ID

*

ID

Page 73: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-3

.....................................................................................................................................................S_CUSTOMER Description

S_CUSTOMER DescriptionColumn 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)

Page 74: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-4 Oracle Developer: Build Forms II

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

Page 75: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-5

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

Page 76: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 77: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-7

.....................................................................................................................................................S_CUSTOMER Data

S_CUSTOMER Data (continued)

Note: The above display has been formatted.

IdName Phone Address

------ ------------------ ------------ -----------

City State Country

------------------ ---------------- -----------

Zip_code Credit_ra Sales_rep_id Region_id

---------- --------- ------------ ---------

Comments

--------------------------------------------------

212Hamada Sport 20-1209211 57A CornicheAlexandria 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.

Page 78: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_DEPT Description and DataColumn NameNull?Datatype-------------------------------------------------ID NOT NULLNUMBER(7)NAMENOT NULLVARCHAR2(25)REGION_IDNUMBER(7)

SQL> SELECT * FROM s_dept;

IDNAMEREGION_ID

------ ---------------------------------

10Finance1

31Sales132Sales233Sales334Sales435Sales541Operations142Operations243Operations344Operations445Operations550Administration1

12 rows selected.

Page 79: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-9

.....................................................................................................................................................S_EMP Description

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

Page 80: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-10 Oracle Developer: Build Forms II

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

Page 81: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-11

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

Page 82: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_EMP Data (continued)

Note: The above display has been formatted.

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.

Page 83: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-13

.....................................................................................................................................................S_ITEM Description

S_ITEM DescriptionColumn NameNull?Datatype

-------------------------------------------------ORD_IDNOT NULLNUMBER(7)ITEM_IDNOT NULLNUMBER(7)PRODUCT_IDNOT NULLNUMBER(7)PRICE NUMBER(11,2)QUANTITY NUMBER(9)QUANTITY_SHIPPEDNUMBER(9)

Page 84: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_ITEM Data

SQL> SELECT * FROM s_item;

ORD_IDITEM_IDPRODUCT_IDPRICEQUANTITYQUANTITY_SHIPPED

-------------- ----------- ------ -------- -----------------

1001100111355005001002100133804004001003100211450050010053032658260060010074101082502501006304332045045010041002336400400101130421161515101341010820201015501694.2940401016504178027271017505304550501014411004535351012404225030301021201082810010010222020112345451031304332015151032327797111110412051097 7104430421163535104220512812121043303211669191910515027322.81616105350532472828105250419801313

Page 85: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-15

.....................................................................................................................................................S_ITEM Data

S_ITEM Data (continued)

Note: The above display has been formatted.

ORD_IDITEM_IDPRODUCT_IDPRICEQUANTITYQUANTITY_SHIPPED

-------------- ----------- ------ -------- -----------------

10612010828464610645027322.89757510655041875989810665041980272710622020112321211063501694.291251251071201061150501073202011151301301075304211655551074303211669757510722010828222210812051099910864108035505010874110045424210853286160575710822051281818108432779760601083303211669858510911001114015015010953042618.255005001097504187543431096328616050501094303265821500150010921001217560060010931002221.9530030011015027322.891717110250536502323111140421652727111241080352929971201069100010009723032115005050981404218577991205109181899220512825259935041780535399450530456969112120106115050

62 rows selected.

Page 86: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_ORD Description and DataColumn NameNull?Datatype

---------------------------------------------------ID NOT NULLNUMBER(7)CUSTOMER_IDNOT NULL NUMBER(7)DATE_ORDEREDDATEDATE_SHIPPEDDATESALES_REP_IDNUMBER(7)TOTAL NUMBER(11,2)PAYMENT_TYPEVARCHAR2(6)ORDER_FILLEDVARCHAR2(1)

SQL> SELECT * FROM s_ord;

IDCUSTOMER_IDDATE_ORDEDATE_SHIPSALES_REP_IDTOTALPAYMENORDER_F

--- -------------------------------------------------------------

100 204 31-AUG9210-SEP-9211601100CREDITY101 205 31-AUG-9215-SEP-92148056.6CREDITY102 206 01-SEP-9208-SEP-92158335CREDITY103 208 02-SEP-9222-SEP-9215377CASHY104 208 03-SEP-9223-SEP-921532430CREDITY105 209 04-SEP-92 18-SEP-92112722.24CREDITY106 210 07-SEP-92 15-SEP-921215634CREDITY107 211 07-SEP-9221-SEP-9215142171CREDITY108 212 07-SEP-9210-SEP-9213149570CREDITY109 213 08-SEP-92 28-SEP-92111020935CREDITY110 214 09-SEP-92 21-SEP-92111539.13CASHY111 204 09-SEP-92 21-SEP-92112770CASHY97 201 28-AUG-92 17-SEP-921284000 CREDITY98 202 31-AUG-92 10-SEP-9214595CASHY99 203 31-AUG-92 18-SEP-92147707CREDITY112 210 31-AUG-92 10-SEP-9212550CREDITY

16 rows selected.

Page 87: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-17

.....................................................................................................................................................S_PRODUCT Description

S_PRODUCT DescriptionColumn 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)

Page 88: Build Forms II - Volume 2 _ Instructor Guide

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

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

10012Ace Ski BootIntermediate ski boot5191002200

10013Pro Ski BootAdvanced ski boot5201003410

10021Bunny Ski PoleBeginner’s ski pole528101116.25

10022Ace Ski PoleIntermediate ski pole529101221.95

10023Pro Ski PoleAdvanced ski pole530101340.95

20106Junior Soccer BallJunior soccer ball61311

20108World Cup Soccer BallWorld cup soccer ball61528

20201World Cup NetWorld cup net708123

Page 89: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-19

.....................................................................................................................................................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, pair1019Elbow Pads8

30321Grand Prix Bicycle Road bicycle828 12911669

30326Himalaya BicycleMountain bicycle8331296582

30421Grand PrixRoad bicycle tires927Bicycle Tires16

30426Himalaya TiresMountain bicycle tires93318.25

30433New Air PumpTire pump94020

32779Slaker Water Water bottle1286Bottle7

32861Safe-T HelmetBicycle helmet13681829 60

40421Alexeyer ProStraight bar928Lifting Bar

138165

40422Pro Curling BarCurling bar929138250

Page 90: Build Forms II - Volume 2 _ Instructor Guide

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

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_PRODUCT Data (continued)

ID NAMESHORT_DESCLONGTEXT_ID-------------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS----------------------------------------40421Alexeyer ProStraight bar928

Lifting Bar138165

40422Pro Curling BarCurling bar929138250

41010Prostar 10 Ten pound weight517Pound Weight 8

41020Prostar 20Twenty pound weight527Pound Weight12

41050Prostar 50 Fifty pound weight557Pound Weight25

41080Prostar 80 Eighty pound weight587Pound Weight35

41100Prostar 100 One hundred pound 607Pound Weightweight45

50169Major League Baseball676Baseball

11194.29

Page 91: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-21

.....................................................................................................................................................S_PRODUCT Data

S_PRODUCT Data (continued)

Note: The above display has been formatted.

ID NAMESHORT_DESCLONGTEXT_ID---------------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS----------------------------------------

50273Chapman HelmetBatting helmet780122322.89

50417Griffey GloveOutfielder’s glove9241367 80

50418Alomar GloveInfielder’s glove9251368 75

50419Steinbach GloveCatcher’s glove9261369 80

50530Cabrera BatThirty inch bat10371480 45

50532Puckett BatThirty-two inch bat10391482 47

50536Winfield BatThirty-six inch bat10431486 50

33 rows selected.

Page 92: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-22 Oracle Developer: Build Forms II

.....................................................................................................................................................Appendix B: Table Descriptions and Data

S_REGION Description and DataColumn NameNull?Datatype----------------------------------------------ID NOT NULLNUMBER(7)NAMENOT NULLVARCHAR2(50)

SQL> SELECT * FROM s_region;

IDNAME--- --------------------------1North America2South America3Africa / Middle East4Asia5Europe

Page 93: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-23

.....................................................................................................................................................S_TITLE Description and Data

S_TITLE Description and DataColumn NameNull?Datatype--------------------------------------------------TITLENOT NULLVARCHAR2(25)

SQL> SELECT * FROM s_title;

TITLE------------------------PresidentSales RepresentativeStock ClerkVP, AdministrationVP, FinanceVP, OperationsVP, SalesWarehouse Manager

8 rows selected.

Page 94: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-24 Oracle Developer: Build Forms II

.....................................................................................................................................................Appendix B: Table Descriptions and Data

Oracle8 objects: types, tables

emp_type_ObjColName 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_RefColName 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)

Page 95: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-25

.....................................................................................................................................................Oracle8 objects: types, tables

tables

oo_emp_Table_ObjColName 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

Page 96: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-26 Oracle Developer: Build Forms II

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

Page 97: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-27

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

Page 98: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-28 Oracle Developer: Build Forms II

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

Page 99: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-29

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

Page 100: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-30 Oracle Developer: Build Forms II

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

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

2500

2NgaoLaDorislngao

08-MAR-90 1 VP Operations

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

3 NagayamaMidorimnagayam

17-JUN-91 1 VP Sales

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

4 Quick-To-SeeMarkmquickto

07-APR-90 1 VP Finance

0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

5 Ropeburn Audryaropebur

04-MAR-90 1 VP Administration

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1550

Page 101: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-31

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

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

9 CatchpoleAntoinetteacatchpo

09-FEB-922 Warehouse Manager

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1300

10 Havel Martamhavel

27-FEB-91 2 Warehouse Manager

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1307

11 Magee Colincmagee

14-MAY-90 3 Sales Representative

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400 10

13 SedeghiYasminysedeghi

18-FEB-91 3 Sales Representative

0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1515 10

Page 102: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-32 Oracle Developer: Build Forms II

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

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1525 15

15 DumasAndreadumas

09-OCT-913 Sales Representative

0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450 18

16 MaduroElenaemaduro

07-FEB-92 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

17 SmithGeorgegsmith

08-MAR-90 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

940

18 NozakiAkiraanozaki

09-FEB-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

Page 103: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-33

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

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

20 NewmanChadcnewman

21-JUL-918 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

750

21 MarkarianAlexanderamarkari

26-MAY-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

850

22 ChangEddieechang

30-NOV-90 9 Stock Clerk

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

800

23 PatelRadharpatel

17-OCT-90 9 Stock Clerk

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

Page 104: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-34 Oracle Developer: Build Forms II

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

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 SchwartzSylviesschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

oo_dept_tableName 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

Page 105: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-35

.....................................................................................................................................................Oracle8 objects: types, tables

rel_emp_Table_ObjcolName 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

Page 106: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-36 Oracle Developer: Build Forms II

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

Page 107: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-37

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

Page 108: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-38 Oracle Developer: Build Forms II

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

Page 109: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-39

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

Page 110: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-40 Oracle Developer: Build Forms II

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

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

2500

2 Ngao LaDoris lngao

08-MAR-90 1 VP Operations

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

3 Nagayama Midori mnagayam

17-JUN-91 1 VP Sales

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1550

Page 111: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-41

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

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1300

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400 10

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1515 10

Page 112: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................B-42 Oracle Developer: Build Forms II

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

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1450 18

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408002072C15B

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1200

Page 113: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II B-43

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

0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408002072C15B

850

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408002072C15B

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408002072C15B

795

Page 114: Build Forms II - Volume 2 _ Instructor Guide

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

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

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

Page 115: Build Forms II - Volume 2 _ Instructor Guide

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

C

Project BuilderAddendum

Page 116: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

After completing this addendum, youshould be able to do the following:

• Implement team development withProject Builder

– Provide a Global Registry of commontypes

– 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

Page 117: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-3

.....................................................................................................................................................Introduction

Introduction

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

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

Page 118: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-4 Oracle Developer: Build Forms II

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Team Development with ProjectBuilder

Projectadministrator

Teammembers

Page 119: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-5

.....................................................................................................................................................Team Development with Project Builder

Team Development with Project BuilderIn 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 AdministratorA 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.

Page 120: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-6 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

The Role of the Global Registry

• Shared by all developers

• Placed on a shared network drive

• Modified by the project administrator

• Saved toORACLE_HOME\PJ60\typesnn.upd,where nn indicates the nationallanguage

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 networkdrive

• Used to add private types

• Used to override the definitions of typesin the Global Registry

Page 121: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-7

.....................................................................................................................................................Team Development with Project Builder

The Role of the Global RegistryCommonly, 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 RegistryAs 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.

Page 122: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Importing and ExportingProjects

1. Select File—>Export or Import Project.

2. Enter details.

The project is saved toORACLE_HOME\PJ60\pjusernn.upd,where nn indicates the national language.

Page 123: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-9

.....................................................................................................................................................Team Development with Project Builder

Importing and Exporting ProjectsProjects 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 Projects1 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.

Page 124: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-10 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Generating and PrintingProject Reports

Page 125: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-11

.....................................................................................................................................................Generating and Printing Project Reports

Generating and Printing Project ReportsWith 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.

Page 126: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-12 Oracle Developer: Build Forms II

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

Instructor NoteDemonstration:

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.

Copyright Oracle Corporation, 1999. All rights reserved.

Defining New Module Types

Page 127: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-13

.....................................................................................................................................................Defining New Module Types

Defining New Module TypesMost 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.

Page 128: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-14 Oracle Developer: Build Forms II

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

Instructor NoteDemonstration:

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.

Copyright Oracle Corporation, 1999. All rights reserved.

Identifying New Module Types

Page 129: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-15

.....................................................................................................................................................Identifying New Module Types

Identifying New Module TypesThe 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.

Page 130: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-16 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Describing New Module Types

Page 131: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-17

.....................................................................................................................................................Describing New Module Types

Describing New Module TypesThe 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.

Page 132: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-18 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Actions for New Object Types

Page 133: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-19

.....................................................................................................................................................Actions for New Module Types

Actions for New Module TypesUse 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.

Page 134: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-20 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

An Icon for New Object Types

Page 135: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-21

.....................................................................................................................................................An Icon for New Module Types

An Icon for New Module TypesThe 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.

Page 136: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-22 Oracle Developer: Build Forms II

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

Technical NoteIf 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 NoteDemonstration:

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.

Copyright Oracle Corporation, 1999. All rights reserved.

Modifying Types Using Actions

• Actions can bedefined for a type,project, orcomponents throughthe Property Palette.

• Action definitionsoften use macros.

Page 137: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-23

.....................................................................................................................................................Modifying Types Using Actions

Modifying Types Using ActionsYou 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 menu

Select the “Add to pop-up menu” check box if you want to include the action 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 Application

Specify the application you want to use to perform the action from the resulting Select an Application dialog box.

Insert Macro

Specify a macro that is expanded when the action is invoked.

Insert Input Item

Insert Input Item is available only for global actions (Build, Deliver, or the 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.

Page 138: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-24 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Customizing Actionsby Using Macros

Simple macros: myprinter =“HPLASER_01”

Built-in macros: n = Full filename

Predefined macros: D2KEDITOR ={EDITOR ? {EDITOR} : notepad}

Page 139: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-25

.....................................................................................................................................................Customizing Actions by Using Macros

Customizing Actions by Using MacrosIf 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 MacrosSimple 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 MacrosBuilt-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 MacrosThese 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.

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

Page 140: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-26 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Defining and Using Macros

Macros can:

• Be defined for eachobject through theProperty Palette

• Be conditional

• Reference other macros

Page 141: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-27

.....................................................................................................................................................Customizing Actions by Using Macros

Defining and Using a MacroTo 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 MacrosYou can set the value of a macro depending on a condition. To do so, use the following expression:

{macroname?expression1:expression2}

{EDITOR ? {EDITOR} : vi}

Nesting MacrosYou 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 ModePreview 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.

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(Optional)

The expression to which the macro is evaluated if the macro either has not been previously defined or has been defined but has no assigned value

Page 142: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-28 Oracle Developer: Build Forms II

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

Copyright Oracle Corporation, 1999. All rights reserved.

Customizing the Launcher

Page 143: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-29

.....................................................................................................................................................Customizing the Launcher

Customizing the LauncherYou 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 Icons1 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 Icons1 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.

Page 144: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................C-30 Oracle Developer: Build Forms II

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Inheritance in Project Builder

• Actions and macros can be defined fortypes, projects, and components.

• Type action and macro definitions canbe overridden by the project or thecomponent.

• Every component alsoinherits from the<Any File> type.

• In Windows 95 and NT, filetype definitions are alsoautomatically inherited.

Type

Project

Component

Type

Project

Component

Page 145: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-31

.....................................................................................................................................................Inheritance in Project Builder

Inheritance in Project Builder

Inheritance OverviewThe 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 TypesEach 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.

Page 146: Build Forms II - Volume 2 _ Instructor Guide

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

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

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

Page 147: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-33

.....................................................................................................................................................Actions

ActionsProject Builder has three types of actions:

• Predefined actions

• User-defined actions

• Global actions

Predefined ActionsPredefined 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 ActionsUser-defined actions are custom actions and you define them explicitly. User defined actions are covered in detail in Appendix C, “Project Builder Addendum.”

Global ActionsGlobal 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)

Page 148: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

This addendum covers the followingtopics:

• Team development with Project Builder

• Customize Project Builder

• Inheritance in Project Builder

Page 149: Build Forms II - Volume 2 _ Instructor Guide

.....................................................................................................................................................Oracle Developer: Build Forms II C-35

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

Page 150: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 151: Build Forms II - Volume 2 _ Instructor Guide

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

D

Introduction toOracle8 Object Features

Page 152: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

After completing this appendix, you shouldbe 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

Page 153: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-3......................................................................................................................................................

......................................................................................................................................................Introduction

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

Page 154: Build Forms II - Volume 2 _ Instructor Guide

D-4 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

New Oracle8 Scalar Data Types

• NCHAR

• NVARCHAR2

• FLOAT

• NLS types

Page 155: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-5......................................................................................................................................................

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

Page 156: Build Forms II - Volume 2 _ Instructor Guide

D-6 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types

Attributes

po_nocustinfo

line_itemsamount

Methods

ORDER

Page 157: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-7......................................................................................................................................................

......................................................................................................................................................Object Types

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

Page 158: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types

Ship

Cancel

Hold

Checkstatus

ORDER

Page 159: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-9......................................................................................................................................................

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

RETURN (dept_id); END;

END;

Page 160: Build Forms II - Volume 2 _ Instructor Guide

D-10 Oracle Developer: Build Forms II......................................................................................................................................................

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Tables

Object table based on object type

Page 161: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-11......................................................................................................................................................

......................................................................................................................................................Creating Oracle8 Objects

Creating Oracle8 Objects

IntroductionAfter you have declared an object type, you can create objects based on the type.

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

Page 162: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Columns

Object column based on object type

Page 163: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-13......................................................................................................................................................

......................................................................................................................................................Object Columns

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

Page 164: Build Forms II - Volume 2 _ Instructor Guide

D-14 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Views

Object views based on object types

Object viewObject-oriented

applicationRelational

table

Page 165: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-15......................................................................................................................................................

......................................................................................................................................................Object Views

Object ViewsOften 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_typeWITH OBJECT OID (eno) AS SELECT e.empno, e.ename, e.sal, e.jobFROM emp e;

Page 166: Build Forms II - Volume 2 _ Instructor Guide

D-16 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

INSTEAD-OF Triggers

INSTEAD-OF triggerNonupdatable view

DECLARE

BEGIN

EXCEPTION

END;

Page 167: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-17......................................................................................................................................................

......................................................................................................................................................INSTEAD-OF Triggers

INSTEAD-OF TriggersINSTEAD-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.

Page 168: Build Forms II - Volume 2 _ Instructor Guide

D-18 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

References to Objects

OID

Page 169: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-19......................................................................................................................................................

......................................................................................................................................................Referencing Objects

Referencing Objects

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

Page 170: Build Forms II - Volume 2 _ Instructor Guide

D-20 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Types inObject Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

Object Type Wizard

Page 171: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-21......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Displaying Oracle8 Objects in the Object NavigatorIn the Database Objects section, the Object Navigator lists declared types, along with tables, views, and other Oracle objects.

Object TypesBoth 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 WizardYou can create object types by using the Oracle8 Type Wizard, which enables you to define attributes and methods.

Page 172: Build Forms II - Volume 2 _ Instructor Guide

D-22 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Tablesin Object Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

Object Columnsin Object Navigator

Page 173: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-23......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Object TablesObject 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 ColumnsObject 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.

Page 174: Build Forms II - Volume 2 _ Instructor Guide

D-24 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object Viewsin Object Navigator

Copyright Oracle Corporation, 1999. All rights reserved.

INSTEAD-OF Trigger Dialog Box

Page 175: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-25......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

Object ViewsObject 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 TriggersYou 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

Page 176: Build Forms II - Volume 2 _ Instructor Guide

D-26 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Object REFsin Object Navigator

Page 177: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-27......................................................................................................................................................

......................................................................................................................................................Displaying Oracle8 Objects in the Object Navigator

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

Page 178: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

This appendix covers the followingtopics:

• Oracle8 introduced three new scalardatatypes.

• Objects and object types allowrepresentation 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 onobject views.

• Object REFs store the object identifierof certain types of objects.

• The Object Navigator can displaycertain types of objects.

Page 179: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II D-29......................................................................................................................................................

......................................................................................................................................................Summary

Summary

New Oracle8 Data TypesOracle8 introduced three new scalar data types and new composite data types such as object types.

ObjectsThree 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 NavigatorThe Object Navigator can display certain types of objects.

Page 180: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 181: Build Forms II - Volume 2 _ Instructor Guide

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

E

Menu Run-TimeParameters

Page 182: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

After completing this appendix, youshould be able to customize menumodules by using substitutionparameters.

Page 183: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-3......................................................................................................................................................

......................................................................................................................................................Introduction

Introduction

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

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

Page 184: Build Forms II - Volume 2 _ Instructor Guide

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

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

Instructor NoteDemonstration: 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.

Copyright Oracle Corporation, 1999. All rights reserved.

Built-in Substitution Parameters

UN

PW

AD

SO

TT

LN

Current username

Current password

Directory name

Current menu name

Terminal type

Language used

Copyright Oracle Corporation, 1999. All rights reserved.

User-Named SubstitutionParameters

Design time Run time

Page 185: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-5......................................................................................................................................................

......................................................................................................................................................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 ParametersYou can use six predefined (built-in) substitution parameters. Form Builder automatically processes them at run time.

User-Named Substitution ParametersUser-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.

Parameter DescriptionUN Current username

PW Current passwordAD Directory name containing the current menu module run-time fileSO Current menu name (selected option)TT Terminal type used at connectionLN Language used (NLS_LANG parameter)

Page 186: Build Forms II - Volume 2 _ Instructor Guide

E-6 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Parameter Properties

- Name- Label- Case Restriction- Conceal Data- Associated Menus

- Name- Label- Case Restriction- Conceal Data- Associated Menus

- Maximum Length- Menu Parameter Initial Value- Required- Hint

- Maximum Length- Menu Parameter Initial Value- Required- Hint

Page 187: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-7......................................................................................................................................................

......................................................................................................................................................Defining a User-Named Substitution Parameter

Defining a User-Named Substitution Parameter

Creating a User-Named Substitution ParameterYou 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 DescriptionName The two-letter parameter nameLabel The text prompt for the parameter value that is displayed in

the Enter Parameter Values dialog boxCase Restriction The property that converts the case of the user’s input to

either uppercase, lowercase, or noneConceal Data The property that determines whether the user’s input is ech-

oed on the screenAssociated Menus All menu names where the parameter can be used (full-screen

menus only)Maximum Length Value maximum length

Menu Parameter Initial ValueThe 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

Page 188: Build Forms II - Volume 2 _ Instructor Guide

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

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

Instructor NoteYou can prompt for several menu parameters by using the following syntax:

Query_Parameter(’&p1 &p2 &p3’);

Copyright Oracle Corporation, 1999. All rights reserved.

Substitution ParameterBuilt-ins

• QUERY_PARAMETER

• APPLICATION_PARAMETER

Copyright Oracle Corporation, 1999. All rights reserved.

Referencing and ApplyingMenu Parameters

• In a menu item command: prefix theparameter 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 editorExample: :param_name

Page 189: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-9......................................................................................................................................................

......................................................................................................................................................Substitution Parameter Built-ins

Substitution Parameter Built-ins

Prompting for Substitution Parameter Values

Syntax for Referencing Substitution ParametersThe 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 CommandPrefix the parameter name with an ampersand (&).

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

PLUS80W &UN/&PW @&CF

Referencing a Parameter in a PL/SQL RoutinePrefix 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.

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

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

Page 190: Build Forms II - Volume 2 _ Instructor Guide

E-10 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Validating SubstitutionParameter Values

MENU_SUCCESS function:

• Returns TRUE if the user does notcancel the Enter Parameter Valuesdialog box

• Is used in a WHILE loop

Page 191: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-11......................................................................................................................................................

......................................................................................................................................................Validating a Substitution Parameter Value

Validating a Substitution Parameter ValueYou 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.

DECLAREStatus BOOLEAN:= TRUE;

BEGINWHILE StatusLOOP

QUERY_PARAMETER(’&p1’);IF MENU_SUCCESSTHEN

IF TO_NUMBER(:p1) not between 100 and 5000THEN

MESSAGE(’Qty must be in the range 100..5000’);BELL;

ELSEStatus := FALSE;

END IF;END IF;

END LOOP;END;

Page 192: Build Forms II - Volume 2 _ Instructor Guide

E-12 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

This appendix covered substitutionparameters.

Page 193: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II E-13......................................................................................................................................................

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

Page 194: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 195: Build Forms II - Volume 2 _ Instructor Guide

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

F

Handling Server-SideErrors

Page 196: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

After completing this appendix, youshould be able to:• Handle server-side database errors• Obtain the cause of declarative-

constraint violations

Page 197: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-3......................................................................................................................................................

......................................................................................................................................................Introduction

Introduction

OverviewThis lesson covers the use of Oracle server features in Form Builder applications. You will learn about handling Oracle server errors, including declarative-constraint violations.

ObjectivesAt the end of this lesson, you should be able to:

• Handle errors raised by the Oracle server

• Obtain the cause of declarative-constraint violations

Page 198: Build Forms II - Volume 2 _ Instructor Guide

F-4 Oracle Developer: Build Forms II......................................................................................................................................................

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

Instructor NoteDemonstration: 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.

Copyright Oracle Corporation, 1999. All rights reserved.

Obtaining the Cause ofDeclarative-Constraint Violation• Predefined error messages for

declarative constraints:

– Primary/unique key; foreign key;check

– ORA-02291: integrity constraint(schema.constraint) violatedparentkey not found

• Obtaining the name of violatedconstraint: FunctionSTRIP_CONSTRAINT_NAME

Page 199: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-5......................................................................................................................................................

......................................................................................................................................................Obtaining the Cause of Declarative-Constraint Violations

Obtaining the Cause of Declarative-Constraint ViolationsTo 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

Obtaining the Name of the Violated ConstraintYou 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 VARCHAR2IS

v_start_pos NUMBER(4);v_end_pos NUMBER(4);

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

Constraint Error MessagePrimary Key ORA-00001: unique constraint (schema.constraint) violated

Unique KeyForeign Key ORA-02291: integrity constraint (schema.constraint) violated—parent

key not foundORA-02292: integrity constraint (schema.constraint) violated—child record found

Check ORA-02290: check constraint (schema.constraint) violated

Page 200: Build Forms II - Volume 2 _ Instructor Guide

F-6 Oracle Developer: Build Forms II......................................................................................................................................................

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Customizing Oracle Server ErrorMessages

• Replacing declarative-constraint errormessages:

– Strip the constraint name fromDBMS_ERROR_TEXT or SQLERRM

– Retrieve the customized messagefrom the messages table

Copyright Oracle Corporation, 1999. All rights reserved.

Customizing Oracle Server ErrorMessages

• Replacing database-trigger errormessages:– Strip the application error messages

from DBMS_ERROR_TEXT orSQLERRM

– FunctionSTRIP_APPLICATION_ERROR

• Replacing stored-program-unit errormessages: Same as for databasetriggers, except SQLERRM only

Page 201: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-7......................................................................................................................................................

......................................................................................................................................................Customizing Oracle Server Error Messages

Customizing Oracle Server Error Messages

Replacing Error Messages Caused by Declarative-Constraint ViolationsThe 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 TriggersThe 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 VARCHAR2IS

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 UnitsThe error is reported in SQLERRM only. The customized message is obtained in the same way as for database triggers.

Page 202: Build Forms II - Volume 2 _ Instructor Guide

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

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

Instructor NoteDemonstration: 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.

Copyright Oracle Corporation, 1999. All rights reserved.

Example Procedure for HandlingOracle Server Errors

• If the Oracle server error is adeclarative-constraint error:

– Strip the constraint name from theOracle server error text.

– Adjust the name of the foreign-keyconstraints.

– Retrieve the message from themessages table.

Copyright Oracle Corporation, 1999. All rights reserved.

Example Procedure for HandlingOracle Server Errors

• If the Oracle server error is anapplication error: strip the applicationerror from the Oracle server error text.

• Raise FORM_TRIGGER_FAILURE.

Page 203: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-9......................................................................................................................................................

......................................................................................................................................................Example Procedure for Handling Oracle Server Errors

Example Procedure for Handling Oracle Server ErrorsPROCEDURE 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.

Page 204: Build Forms II - Volume 2 _ Instructor Guide

F-10 Oracle Developer: Build Forms II......................................................................................................................................................

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

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

Instructor NoteDemonstration: 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.

Copyright Oracle Corporation, 1999. All rights reserved.

Handle errors caused by implicit DMLOn-Error trigger on form:

Handle errors caused by explicit DML orstored PUs:

EXCEPTIONWHEN OTHERS THEN

handle_server_error(SQLCODE, SQLERRM);

EXCEPTIONWHEN OTHERS THEN

handle_server_error(SQLCODE, SQLERRM);

Example Procedure for HandlingOracle Server Errors

IF ERROR_TYPE = ′FRM’ ANDERROR_CODE IN (40508, 40509, 40510) THENhandle_server_error(DBMS_ERROR_CODE,

DBMS_ERROR_TEXT);END IF;

Page 205: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-11......................................................................................................................................................

......................................................................................................................................................Example Procedure for Handling Oracle Server Errors

Handling Oracle Server Errors Caused by Implicit DMLAlways define an On-Error trigger to handle Oracle server errors caused by base table DML.

On-Error Trigger at Form LevelBEGIN

IF ERROR_TYPE = ’FRM’ AND ERROR_CODE IN (40508, 40509, 40510) THENhandle_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 THENhandle_server_error(SQLCODE, SQLERRM);

END;

Page 206: Build Forms II - Volume 2 _ Instructor Guide

F-12 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Summary

This appendix covered replacing Oracleserver error messages with customizedmessages.

• Constraint: strip constraint name andretrieve message

• DB triggers and stored program units:strip application error

Page 207: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II F-13......................................................................................................................................................

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

Page 208: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 209: Build Forms II - Volume 2 _ Instructor Guide

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

G

EMP_PKG Package

Page 210: Build Forms II - Volume 2 _ Instructor Guide

G-2 Oracle Developer: Build Forms II......................................................................................................................................................

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

Page 211: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II G-3......................................................................................................................................................

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

Page 212: Build Forms II - Volume 2 _ Instructor Guide

G-4 Oracle Developer: Build Forms II......................................................................................................................................................

......................................................................................................................................................Appendix G: EMP_PKG Package

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

. . .

Page 213: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II G-5......................................................................................................................................................

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

. . .

Page 214: Build Forms II - Volume 2 _ Instructor Guide

G-6 Oracle Developer: Build Forms II......................................................................................................................................................

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

. . .

Page 215: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II G-7......................................................................................................................................................

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

Page 216: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 217: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II G-9......................................................................................................................................................

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

Page 218: Build Forms II - Volume 2 _ Instructor Guide

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

......................................................................................................................................................Appendix G: EMP_PKG Package

Page 219: Build Forms II - Volume 2 _ Instructor Guide

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

H

Working with ActiveXControls

Page 220: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Objectives

After completing this lesson, you shouldbe able to do the following:

• Explain the differences between VBX,OCX, and ActiveX controls

• Access ActiveX properties at designtime and run time

• Import ActiveX control methods andevent packages

• Customize event handling

Page 221: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-3......................................................................................................................................................

......................................................................................................................................................Introduction

Introduction

OverviewIn this lesson, you will learn how to include and use ActiveX controls in your Oracle Developer application.

ObjectivesAfter 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

Page 222: Build Forms II - Volume 2 _ Instructor Guide

H-4 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

What Are VBX, OCX, andActiveX Controls?

VBX• Custom interface object• Special dynamic-link library

OCX• Independent program module• Run in any Windows application that is

OLE-enabledActiveX• Third version of OCX• Provide integrated controls in Browsers

Page 223: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-5......................................................................................................................................................

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

Page 224: Build Forms II - Volume 2 _ Instructor Guide

H-6 Oracle Developer: Build Forms II......................................................................................................................................................

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

VBX, OCX, and ActiveX ControlsComparison

Operating“platform”

Candidateapplications

Codinginterface

Web-enabled

VBXControls

OCXControls

16-bit applicationsonly

Only those writtenwith a specific

interface to VBXs

Proprietary

No No Yes

ActiveXControls

Both 16- and 32-bitplatforms

Any application with anOLE container type

Standard OLE2

Page 225: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-7......................................................................................................................................................

......................................................................................................................................................Comparison of VBX, OCX, and ActiveX Controls

Comparison of VBX, OCX, and ActiveX ControlsA 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

Operating platform

16-bit applications only

Both 16- and 32-bit platforms

Both 16- and 32-bit platforms

Candidate applications

Only those written with a specific interface to VBXs

Any application with an OLE container type

Any application with an OLE container type

Coding interface

Proprietary Standard OLE2 Standard OLE2

Web-enabled No No Yes

Page 226: Build Forms II - Volume 2 _ Instructor Guide

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

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

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

Page 227: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-9......................................................................................................................................................

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

Page 228: Build Forms II - Volume 2 _ Instructor Guide

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Implementing an ActiveXControl 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.

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

Creating an ActiveXControl Item

Page 229: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-11......................................................................................................................................................

......................................................................................................................................................Implementing an ActiveX Control

Implementing an ActiveX Control

Using an ActiveX Control in Form BuilderTo 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 ItemYou 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.

Page 230: Build Forms II - Volume 2 _ Instructor Guide

H-12 Oracle Developer: Build Forms II......................................................................................................................................................

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

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

Copyright Oracle Corporation, 1999. All rights reserved.

Inserting an ActiveX Control

In the Layout Editor:

1. Select the ActiveX control item.

2. Click the right mouse button.

3. Select InsertObject in thepop-up menu.

4. Select a control type.

Copyright Oracle Corporation, 1999. All rights reserved.

ActiveX Control Properties

Set the followingActiveX control properties:

OLE Class

Control Properties

About Control

Control Help

OLE Class

Control Properties

About Control

Control Help

Page 231: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-13......................................................................................................................................................

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

Page 232: Build Forms II - Volume 2 _ Instructor Guide

H-14 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Importing ActiveX Methodsand Events Packages

Select Program OLE Importer1

2

3

4 5

- Program Units + PackageName1 (Spec) + PackageName1 (Body) + . . .

6

Page 233: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-15......................................................................................................................................................

......................................................................................................................................................Importing ActiveX Control Methods and Events Packages

Importing ActiveX Control Methods and Events PackagesActiveX 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 Events1 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.

Page 234: Build Forms II - Volume 2 _ Instructor Guide

H-16 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Interacting with an ActiveXControl

You can interact for:

• Setting and getting ActiveX controlproperties

• Invoking ActiveX control methods

• Responding to ActiveX control events

Copyright Oracle Corporation, 1999. All rights reserved.

Setting and Getting ActiveXControl Properties

Three methods:

• Bind variable

Syntax

Example

:Item(′item_name’).OCX.server_name.property:Item( ′item_name’).OCX.server_name.property

:item( ′ActXitem’).OCX.Spindial.spindialctrl

.1.Needleposition:=:item(’ActXitem’).OCX.

Spindial.spindialctrl.1.Needleposition + 1;

:item( ′ActXitem’).OCX.Spindial.spindialctrl

.1.Needleposition:=:item(’ActXitem’).OCX.

Spindial.spindialctrl.1.Needleposition + 1;

Page 235: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-17......................................................................................................................................................

......................................................................................................................................................Setting and Getting ActiveX Control Properties

Setting and Getting ActiveX Control PropertiesOnce 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 SyntaxYou 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;

Page 236: Build Forms II - Volume 2 _ Instructor Guide

H-18 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Setting and Getting ActiveXControl 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 ActiveXControl Properties

• Control Properties dialog box– Displays ActiveX-specific

properties– See Control

Help propertyordocumentation

Page 237: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-19......................................................................................................................................................

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

Page 238: Build Forms II - Volume 2 _ Instructor Guide

H-20 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Invoking ActiveX ControlMethods

MMVX_DMMVX.PLAY(:item

(′video_ocx.video′).INTERFACE);

MMVX_DMMVX.PLAY(:item

(′video_ocx.video′).INTERFACE);

Page 239: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-21......................................................................................................................................................

......................................................................................................................................................Invoking ActiveX Control Methods

Invoking ActiveX Control MethodsMethods define actions that the ActiveX control can perform.

How to Invoke a MethodYou 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;

Page 240: Build Forms II - Volume 2 _ Instructor Guide

H-22 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Responding to ActiveX ControlEvents

Two ways to deal with events:

• Directly call the appropriate restrictedprocedure.

• Code the On-Dispatch-Event trigger.

PROCEDURE /*Click*/ event4294966696

(interface OleObj);

BEGIN

/* Write your code here */

END;

Copyright Oracle Corporation, 1999. All rights reserved.

Responding to ActiveX ControlEvents

All event procedures are restricted.

• To run in unrestricted mode, use:

Initialization events do not fire.

• Use the When-New-Item-Instance orWhen-New-Record-Instance triggers inplace.

FORMS4W.DISPATCH_EVENT

(RESTRICTED_UNALLOWED);

Page 241: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-23......................................................................................................................................................

......................................................................................................................................................Responding to ActiveX Control Events

Responding to ActiveX Control EventsActiveX 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 ModeAll 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 EventsInitialization 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.

Page 242: Build Forms II - Volume 2 _ Instructor Guide

H-24 Oracle Developer: Build Forms II......................................................................................................................................................

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

Technical NoteThe LAST_OLE_EXCEPTION built-in takes variables, not constants.

Copyright Oracle Corporation, 1999. All rights reserved.

Handling Exceptions

• When a failure occurs, theFORMS_OLE_FAILURE is raised.

• Use the LAST_OLE_EXCEPTION built-into get more detailed information.

. . .

WHEN FORMS_OLE_FAILURE THEN

ExceptNum :=LAST_OLE_EXCEPTION(errScr,

errDescription, errHelpfile,

errHelpContext);

. . .

Page 243: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-25......................................................................................................................................................

......................................................................................................................................................Handling Exceptions

Handling Exceptions

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

Page 244: Build Forms II - Volume 2 _ Instructor Guide

H-26 Oracle Developer: Build Forms II......................................................................................................................................................

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

Copyright Oracle Corporation, 1999. All rights reserved.

Registering an ActiveX Control

Two methods to register:

• Implicitly register using the installationprogram.

• Use regsvr32.exe explicitly.

ActiveX controls require supporting DLLMust be in \Windows\System or searchpath

Reregister the ActiveX control if you moveit or rename its directory.

Page 245: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-27......................................................................................................................................................

......................................................................................................................................................Registering an ActiveX Control

Registering an ActiveX ControlYou 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 FilesMost 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 FilesAt 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.

Page 246: Build Forms II - Volume 2 _ Instructor Guide

H-28 Oracle Developer: Build Forms II......................................................................................................................................................

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

.

Copyright Oracle Corporation, 1999. All rights reserved.

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

Page 247: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II H-29......................................................................................................................................................

......................................................................................................................................................Summary

SummaryIn 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

Page 248: Build Forms II - Volume 2 _ Instructor Guide

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

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

Page 249: Build Forms II - Volume 2 _ Instructor Guide

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

I

Using Oracle Server Rolesat Run Time

Page 250: Build Forms II - Volume 2 _ Instructor Guide

I-2 Oracle Developer: Build Forms II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 1999. All rights reserved.

Oracle Server Views for Roles

• SESSION_ROLES

• ROLE_ROLE_PRIVS

• ROLE_SYS_PRIVS

• ROLE_TAB_PRIVS

Page 251: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II I-3......................................................................................................................................................

......................................................................................................................................................Using Oracle Server Roles at Run Time

Using Oracle Server Roles at Run Time

OverviewYou 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 ViewRoles that the user currently has enabled

ROLE_ROLE_PRIVS ViewInformation about roles granted to other roles

ROLE_SYS_PRIVS ViewInformation about system privileges granted to roles

Column DescriptionROLE Name of the role

Column DescriptionROLE Name of the roleGRANTED_ROLE Role that was grantedADMIN_OPTION Subprogram that signifies that the role was granted with the ADMIN

option

Column DescriptionROLE Name of the rolePRIVILEGES System privileges granted to the roleADMIN_OPTION Column that signifies the grant was with the ADMIN option

Page 252: Build Forms II - Volume 2 _ Instructor Guide

I-4 Oracle Developer: Build Forms II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 1999. All rights reserved.

Oracle Server Views for Roles

• SESSION_ROLES

• ROLE_ROLE_PRIVS

• ROLE_SYS_PRIVS

• ROLE_TAB_PRIVS

Page 253: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II I-5......................................................................................................................................................

......................................................................................................................................................Using Oracle Server Roles at Run Time

ROLE_TAB_PRIVS ViewInformation about table privileges granted to roles.

Column DescriptionROLE Name of the roleOWNER Owner of the objectTABLE_NAME Name of the objectCOLUMN_NAME Name of the column, if applicablePRIVILEGE Object privilege granted to the roleGRANTABLE YES if the role was granted with the ADMIN option, otherwise NO

Page 254: Build Forms II - Volume 2 _ Instructor Guide

I-6 Oracle Developer: Build Forms II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 1999. All rights reserved.

Procedures for Managing Roles

• DBMS_SESSION.SET_ROLE

• DBMS_SESSION.IS_ROLE_ENABLED

Page 255: Build Forms II - Volume 2 _ Instructor Guide

Oracle Developer: Build Forms II I-7......................................................................................................................................................

......................................................................................................................................................Procedures for Managing Roles

Procedures for Managing Roles

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

THENMESSAGE(’You are not authorized to run this application’);PAUSE;RAISE form_trigger_failure;

END IF;

Package DescriptionDBMS_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’)

Page 256: Build Forms II - Volume 2 _ Instructor Guide

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

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Page 257: Build Forms II - Volume 2 _ Instructor Guide

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

J

Instructor Note

Page 258: Build Forms II - Volume 2 _ Instructor Guide

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

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

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

Page 259: Build Forms II - Volume 2 _ Instructor Guide

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

......................................................................................................................................................How the Project Is Organized

How the Project Is OrganizedOracle Developer: Build Forms II contains the following subprojects and subsubprojects:

Subproject Description

Instructor Demonstrations

Contains all the demonstrations of the course. (Those 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.)

Page 260: Build Forms II - Volume 2 _ Instructor Guide

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

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

Project Setup

Importing the User Registry1 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

Page 261: Build Forms II - Volume 2 _ Instructor Guide

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

......................................................................................................................................................Project Setup

Loading the Project1 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 Project1 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.

Page 262: Build Forms II - Volume 2 _ Instructor Guide

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

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

Changing the Project Directory PathsFor 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:

Project-Subproject-SubSubprojectValue for the Project 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-ically Subsubproject

C:\Forms2\Demos

Lesson 07: Controlling Data Block Relationships Subsub-project

C:\Forms2\Demos

Lesson 08: Building Multiple Form Applications Subsub-project

C:\Forms2\Demos

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

C:\Forms2\Demos

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

Page 263: Build Forms II - Volume 2 _ Instructor Guide

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

......................................................................................................................................................Project Setup

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.

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

Project-Subproject-SubSubprojectValue for the Project Directory property

Page 264: Build Forms II - Volume 2 _ Instructor Guide

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

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

Launching the Files

Launching a Powerpoint Slide1 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 FileBe 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 Script1 Select the SQL script.

2 Click on the right mouse button.

3 Select the Run Script option.

Important NoteWhenever 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!