formsii (vol2)

278
....................................................................................... 40034GC10 Production 1.0 May 2000 M011399 Oracle Forms Developer: Build Internet Applications II Volume 2 • Instructor Guide

Upload: lvaldeir

Post on 11-Nov-2014

81 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: FormsII (Vol2)

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

40034GC10

Production 1.0

May 2000

M011399

Oracle Forms Developer: Build Internet Applications II

Volume 2 • Instructor Guide

Page 2: FormsII (Vol2)

Author

Ian Purvis

Technical Contributors and Reviewers

Cem Ayberkin

Gunnar Bohrs

Brian Boxx

Libor Danek

Laurent Dereac

Brian Fry

Pam Gamer

Pascal Gibert

Thierry Guibert

Ellen Gravina

Norris Gray

Anthony Hargreaves

Barry Hiern

Ursula Hovy

Sarah Jones

Jan Keuben

Aija Lehtonen

Regis Louis

Kenji Makita

Sergiy Pecherskyy

Milos Randak

Jonas Rheborg

Bryan Roberts

Candace Stover

Hiroyuki Sugiyama

Laura Tejero

Jack Walsh

Publisher

Nita Brozowski

Copyright Oracle Corporation, 2000. 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: FormsII (Vol2)

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

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

Contents

PrefaceProfile xv

Related Publications xvi

Typographic Conventions xvii

Introduction Introduction I-2

Course Content I-3

Lesson 1: Creating a Menu Module Introduction 1-3

Components of the Menu Module 1-5

The Default Menu 1-7

The Menu Editor 1-9

Creating a Menu Module 1-11

Module Properties 1-13

Menu Properties 1-15

Menu Item Properties 1-17

Menu Item Types 1-19

Menu Item Command Types 1-21

Implementing Menu Toolbars 1-23

Storing the Menu Module 1-25

Attaching the Menu Module 1-27

Pop-up Menus 1-29

Summary 1-31

Practice Overview: Lesson 1 1-33

Practice 1 1-34

Lesson 2: Managing Menu Modules Introduction 2-3

Using PL/SQL in Menu Item Code 2-5

Useful Built-in Menu Subprograms 2-7

Page 4: FormsII (Vol2)

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

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

Showing and Hiding the Current Menu 2-9

Managing Menu Security 2-11

Defining Security Roles 2-13

Assigning Access to Menu Items 2-15

Summary 2-17

Practice Overview: Lesson 2 2-19

Practice 2 2-20

Lesson 3: Programming Function Keys Introduction 3-3

Key Triggers 3-5

Defining Key Triggers 3-7

Characteristics of Key Triggers 3-9

Classification of Key Triggers 3-11

Using Key Triggers 3-15

Association with Other Interface Controls 3-17

Summary 3-19

Practice Overview: Lesson 3 3-21

Practice 3 3-22

Lesson 4: Responding to Mouse Events Introduction 4-3

What Are Mouse Events? 4-5

Responding to Mouse Movement 4-7

Responding to Mouse Button Actions 4-11

Summary 4-15

Practice Overview: Lesson 4 4-17

Practice 4 4-18

Lesson 5: Controlling Windows and Canvases Programmatically Introduction 5-3

Using Window-Interaction Triggers 5-5

Built-ins for Manipulating Windows 5-7

Built-ins for Manipulating Canvases 5-9

Page 5: FormsII (Vol2)

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

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

Working with Tab-Style Canvases 5-11

Windows and Blocks 5-15

Manipulating Window Properties Programmatically 5-17

Closing Windows 5-19

Manipulating Windows in Web-Deployed Forms 5-21

Sizing Windows for Web-Deployed Forms 5-23

Display Large Data Blocks in a Window 5-25

Managing Images for Web-Deployed Forms 5-27

Summary 5-29

Practice Overview: Lesson 5 5-31

Practice 5 5-32

Lesson 6: Defining Data Sources Introduction 6-3

Data Source Types 6-5

Basing a Data Block on a FROM Clause Query 6-7

Basing a Data Block on a Stored Procedure 6-9

Example of a Query Using a REF Cursor Procedure 6-11

Example of Query Using a Table of Records Procedure 6-13

Example of DML Using a Stored Procedure 6-15

Deciding Whether to Use a REF Cursor or a Table of Records 6-17

Data Block Wizard 6-19

Data Block Properties 6-21

Data Source Guidelines 6-23

Summary 6-27

Practice Overview: Lesson 6 6-29

Practice 6 6-30

Lesson 7: Working with Oracle8i Objects in Form Builder Introduction 7-3

What Are Object Types? 7-5

Review of Objects 7-7

Object REFs 7-9

Supported Oracle8i Features 7-11

Page 6: FormsII (Vol2)

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

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

How Oracle Forms Developer Treats Objects 7-13

Object Type Displays 7-15

Creating Data Blocks Based on Oracle8i Objects 7-17

Selecting Object Table Columns 7-19

Selecting Object Column Attributes 7-21

Blocks with REF Lookups 7-23

The REF Column Value 7-25

LOVs for REFs 7-27

Summary 7-29

Practice Overview: Lesson 7 7-31

Practice 7 7-32

Lesson 8: Controlling Data Block Relationships Introduction 8-3

Creating a Relation 8-5

Block Coordination 8-7

Coordinate Blocks Using REFs 8-9

Characteristics of Relation-Handling Triggers 8-11

Principles of Relation-Handling Code 8-13

Obtaining Relation-Handling Information 8-15

Implementing a Coordination-Type Toggle 8-17

Forcing a Commit Per Master 8-19

Summary 8-21

Practice Overview: Lesson 8 8-23

Practice 8 8-24

Lesson 9: Building Multiple Form Applications Introduction 9-3

OPEN_FORM to Invoke Additional Forms 9-5

Closing Forms 9-7

Navigating Between Forms 9-9

Transaction Processing for Opened Forms 9-11

CALL_FORM to Invoke Additional Forms 9-13

Transaction Processing for Called Forms 9-15

Page 7: FormsII (Vol2)

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

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

NEW_FORM to Invoke Additional Forms 9-19

Controlling Open Forms and Called Forms Together 9-21

Different Ways of Invoking Forms 9-23

Using Form Parameters 9-25

Parameter Lists 9-29

Creating and Manipulating Parameter Lists 9-31

Passing Data Between Forms 9-33

Summary 9-35

Practice Overview: Lesson 9 9-37

Practice 9 9-38

Lesson 10: Working with Record Groups Introduction 10-3

Record Groups 10-5

Using Record Groups 10-7

Defining Record Groups at Design Time 10-9

Built-in Functions for Controlling Record Groups 10-11

Defining Query Record Groups Programmatically 10-17

Defining Nonquery Record Groups Programmatically 10-19

Manipulating Record Group Rows 10-21

Manipulating Selected Record Group Rows 10-23

Defining Global Record Groups 10-25

Manipulating List Items Programmatically 10-27

Implementing Dynamic List Items 10-29

Adding Values to Combo Boxes 10-31

Summary 10-33

Practice Overview: Lesson 10 10-35

Practice 10 10-36

Lesson 11: Using Reusable Components Introduction 11-3

Reusable Components 11-5

Reusable Components List 11-7

The Calendar Class 11-11

Page 8: FormsII (Vol2)

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

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

Calendar Object Group Content 11-13

Built-in for Manipulating the Calendar 11-15

Summary 11-17

Practice Overview: Lesson 11 11-19

Practice 11 11-20

Lesson 12: Using Java with Web-Deployed Forms Introduction 12-3

Java and Oracle Forms Developer 12-5

Java in Web-Deployed Forms 12-7

The Forms Applet 12-9

Defining Fonts for Web-Deployed Forms 12-11

Pluggable Java Components 12-13

What Is a Bean Area? 12-17

Hosting a JavaBean 12-19

How a JavaBean Communicates 12-21

Communicating with the JavaBean 12-23

Exploiting Oracle8i Features 12-25

How to Create JavaBeans 12-27

Summary 12-29

Practice Overview: Lesson 12 12-31

Practice 12 12-32

Lesson 13: Using Server Features in Form Builder Introduction 13-3

Using Oracle Database Server Functionality in Forms 13-5

Dealing with PL/SQL Code 13-7

PL/SQL8 Support 13-9

PL/SQL8 Scalar Data Types 13-11

Unsupported Oracle Forms Developer PL/SQL8 Features 13-13

Handling Errors Raised by the Oracle Database Server 13-15

Performing DDL with FORMS_DDL 13-19

Using FORMS_DDL 13-21

Summary 13-23

Page 9: FormsII (Vol2)

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

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

Practice Overview: Lesson 13 13-25

Practice 13 13-26

Lesson 14: Applying Timers Introduction 14-3

Timers 14-5

Handling Timer Expiration 14-7

Creating a Timer 14-9

Modifying a Timer 14-11

Deleting a Timer 14-13

Summary 14-15

Practice Overview: Lesson 14 14-17

Practice 14 14-18

Lesson 15: Including Charts and Reports Introduction 15-3

Including Charts by Using the Chart Wizard 15-5

Chart Item Properties 15-11

Reporting Within Form Builder 15-13

Report Object Properties 15-15

Working with Reports 15-17

Summary 15-23

Practice Overview: Lesson 15 15-25

Practice 15 15-26

Appendix A: Practice Solutions Practice 1 Solutions A-2

Practice 2 Solutions A-6

Practice 3 Solutions A-8

Practice 4 Solutions A-10

Practice 5 Solutions A-11

Practice 6 Solutions A-13

Practice 7 Solutions A-14

Practice 8 Solutions A-15

Page 10: FormsII (Vol2)

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

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

Practice 9 Solutions A-18

Practice 10 Solutions A-21

Practice 11 Solutions A-24

Practice 12 Solutions A-27

Practice 13 Solutions A-30

Practice 14 Solutions A-32

Practice 15 Solutions A-34

Appendix B: Table Descriptions and Data Summit Sporting Goods Database Diagram B-2

S_CUSTOMER Description B-3

S_CUSTOMER Data B-4

S_DEPT Description and Data B-8

S_EMP Description B-9

S_EMP Data B-10

S_ITEM Description B-13

S_ITEM Data B-14

S_ORD Description and Data B-16

S_PRODUCT Description B-17

S_PRODUCT Data B-18

S_REGION Description and Data B-22

S_TITLE Description and Data B-23

Oracle8i Objects: Types, Tables B-24

Appendix C: Mouse Movement Events Introduction C-2

Drag and Drop C-4

Summary C-6

Appendix D: Introduction to Oracle8i Object Features Introduction D-3

New Oracle8i Data Types D-5

Object Types D-7

Creating Oracle8i Objects D-11

Page 11: FormsII (Vol2)

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

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

Object Columns D-13

Object Views D-15

INSTEAD-OF Triggers D-17

Referencing Objects D-19

Displaying Oracle8i Objects in the Object Navigator D-21

Summary D-29

Appendix E: Menu Run-Time Parameters Introduction E-3

Substitution Parameters E-5

Defining a User-Named Substitution Parameter E-7

Substitution Parameter Built-ins E-9

Validating a Substitution Parameter Value E-11

Summary E-13

Appendix F: Handling Server-Side Errors Introduction F-3

Obtaining the Cause of Declarative-Constraint Violations F-5

Customizing Oracle Server Error Messages F-7

Example Procedure for Handling Oracle Server Errors F-9

Summary F-13

Appendix G: EMP_PKG Package Package Specification G-2

Package Body G-4

Appendix H: Working with ActiveX Controls Introduction H-3

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

Comparison of VBX, OCX, and ActiveX Controls H-7

ActiveX in Form Builder H-9

Implementing an ActiveX Control H-11

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

Page 12: FormsII (Vol2)

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

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

Invoking ActiveX Control Methods H-21

Responding to ActiveX Control Events H-23

Handling Exceptions H-25

Registering an ActiveX Control H-27

Summary H-29

Appendix I: Using Oracle Server Roles at Run Time Using Oracle Server Roles at Run Time I-3

Procedures for Managing Roles I-7

Page 13: FormsII (Vol2)

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

13

Using Server Featuresin Form Builder

Page 14: FormsII (Vol2)

13-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Instructor NoteTopic TimingLecture 25 minutes

Practice 25 minutes

Total 50 minutes

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this lesson, you shouldbe able to do the following:

• Use Oracle server functionalities in forms

• Deal with server-side PL/SQL

• Recognize which PL/SQL8 features are supportedin forms

• Handle Oracle server errors

• Perform DDL commands by using theFORMS_DDL built in subprograms

Page 15: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-3......................................................................................................................................................

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

Introduction

OverviewThis lesson covers the use of Oracle database server features in Form Builder applications. You will learn about storing and calling PL/SQL code, handling Oracle database server errors, and issuing DDL commands from within forms.

ObjectivesAfter completing this lesson, you should be able to do the following:

• Use Oracle database server functionalities in forms

• Deal with server-side PL/SQL

• Recognize which PL/SQL8 features are supported in forms

• Handle Oracle database server errors

• Perform DDL commands by using the FORMS _DDL built-in subprograms

Page 16: FormsII (Vol2)

13-4 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Usin g Oracle Database ServerFunctionalit y in Forms

Useful Oracle server features:

• Declarative constraints

• Stored program units

• Database tri ggers

• DDL

Page 17: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-5......................................................................................................................................................

......................................................................................................................................................Using Oracle Database Server Functionality in Forms

Using Oracle Database Server Functionality in FormsThe Oracle8i database offers several powerful features to implement functionality in the Oracle database server. You can call that functionality in your forms to handle possible errors.

Oracle Database Server Features Useful for FormsThe following useful features are available to application developers:

• Declarative integrity constraints

• Stored program units: procedures, functions, and packages

• Built-in database packages

• Database triggers

• Database roles

• DDL

• SQL Optimizer; shared SQL

• Locking

• Sequences

Some of these features are discussed in more depth later in this lesson.

Page 18: FormsII (Vol2)

13-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Dealin g with PL/SQL Code

• Where to store PL/SQL code:

– On the Oracle server

– In the attached PL/SQL libraries

– In the form itself

• Where to call PL/SQL code:

– From database tri ggers

– From forms tri ggers

• Application partitionin g

Page 19: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-7......................................................................................................................................................

......................................................................................................................................................Dealing with PL/SQL Code

Dealing with PL/SQL CodeYou can store and call your code in two places: the Oracle database server and the Oracle Form Builder application.

Where to Store PL/SQL CodeTo maintain your code, you should not store the code in more locations than necessary. The places to store PL/SQL code, in order of preference, are as follows:

1 The Oracle Database Server2 Attached PL/SQL libraries

3 The form itself

Note: PL/SQL code cannot be stored in the Oracle database server if it contains bind variables or calls to Forms built-ins.

Where to Call PL/SQL CodePL/SQL code is eventually called from triggers. Also, for easier maintenance, the places to call PL/SQL code, in order of preference, are as follows:

1 Database triggers

2 Forms triggers

Note: Database triggers fire only at commit time. If you want to give immediate feedback to the user, you must use forms triggers.

Application PartitioningFor enhanced performance, you may want to call or store PL/SQL code on either the Oracle database server or the Oracle Form Builder application.In Form Builder you can drag and drop PL/SQL program units between the Oracle database server and the application. This is called application partitioning. With Web-deployed forms it is also possible to place code on the client by using JavaBeans. In this way, you can optimally divide application code over the available resources.

Page 20: FormsII (Vol2)

13-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

PL/SQL8 Su pport in Oracle Forms

• Client-side program units cannot su pportOracle8 i ob ject-related functionalit y.

• Stored program units can use PL/SQL8features.

Page 21: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-9......................................................................................................................................................

......................................................................................................................................................PL/SQL8 Support

PL/SQL8 SupportOracle Forms Developer uses PL/SQL8 in the Oracle database server and the Oracle Form Builder application. However, Form Builder module program units currently cannot support Oracle8i object-related functionality.

The Stored Program Unit editor has been extended in Oracle Forms Developer to allow editing of the type body (methods) and type specification (attributes) of Oracle8i user-defined data types.

Object Iron PackagesObject Iron is a set of database packages that helps you to access tables containing instances of Oracle8i object types. The packages generate a table-specific package, which you use to access data from the specified table. After generation, the table-specific package appears under the Stored Program Units node. It contains code that allows you to select, insert, update, delete, and lock records in the specified table.

Instructor Note Oracle Forms Developer is backward-compatible with client-side program units built using PL/SQL Version 2. Client-side program units created with previous releases will run against the PL/SQL8 engine with no modification. Although stored program units created with previous releases will run against PL/SQL8, because of syntax incompatibility between PL/SQL8 and PL/SQL Version 2, these stored program units may compile with errors.

Page 22: FormsII (Vol2)

13-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

PL/SQL8 Scalar T ypes

• NCHAR and NVARCHAR2

• SIGNTYPE

• FLOAT

• NATURALN

• POSITIVEN

• PLS_INTEGER

Page 23: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-11......................................................................................................................................................

......................................................................................................................................................PL/SQL8 Scalar Data Types

PL/SQL8 Scalar Data Types• NCHAR stores fixed-length (blank-padded if necessary) NLS character

data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as US7ASCII or a variable-width encoding such as JA16SJIS.

• NVARCHAR2 stores variable-length NLS character data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as WE8EBCDIC37C or a variable-width encoding such as JA16DBCS.

• SIGNTYPE lets you restrict an integer variable to the values -1, 0, and 1, which is useful in programming tri-state logic.

• FLOAT is a subtype of NUMBER. However, you cannot specify a scale for FLOAT variables. You can specify only a binary precision.

• NATURALN is like subtype NATURAL but prevents the assignment of NULL.

• POSITIVEN is like subtype POSITIVE but prevents the assignment of NULL.

• PLS_INTEGER stores signed integers. Its magnitude range is -2147483647 ... 2147483647. PLS_INTEGER values require less storage than NUMBER values. Also, PLS_INTEGER operations use machine arithmetic, so they are faster than NUMBER and BINARY_INTEGER operations, which use library arithmetic.

Besides the database character set, which is used for identifiers and source code, PL/SQL8 now supports a second character set called the national character set, which is used for NLS data. The PL/SQL data types NCHAR and NVARCHAR2 allow you to store character strings formed from the national character set.

Page 24: FormsII (Vol2)

13-12 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Unsu pported Client-SidePL/SQL8 Features

• Untrusted external procedures

• Object t ypes

• Collection t ypes

• LOB t ypes

• Methods

• Objects as stored procedure parameters

Page 25: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-13......................................................................................................................................................

......................................................................................................................................................Unsupported Oracle Forms Developer PL/SQL8 Features

Unsupported Oracle Forms Developer PL/SQL8 FeaturesThe following features are supported in database server PL/SQL8 but are not currently supported in Form Builder module PL/SQL8:

• Object types

• Collection types

• LOB types

• Methods

• Objects as stored procedure parameters

Because these features are supported in database server PL/SQL8, you can use them by writing stored (server-side) subprograms, and calling the subprograms from Oracle Forms Developer. However, the last restriction requires that you decompose any object data types before returning them to the client side.

Page 26: FormsII (Vol2)

13-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Instructor NoteDemonstration: Use ServerSide.fmb to show the handling of errors originating from a trigger, from a stored procedure, and from the database server. Press the ServerSide forms’s HELP button to get instructions on running the demonstration.

Copyright Oracle Corporation, 2000. All rights reserved.®

Causes of Oracle Server Errors

Base table block

Implicit DML

Trigger/PU

Explicit DML

Stored PU call

Declarativeconstraint

Databasetrigger

Storedprogram unit

Form Oracle Server

Page 27: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-15......................................................................................................................................................

......................................................................................................................................................Handling Errors Raised by the Oracle Database Server

Handling Errors Raised by the Oracle Database ServerOracle server errors can have different causes; for example, a declarative constraint or a stored program unit. You should know how to handle errors that may occur in different situations.

Causes of Oracle Server Errors

Types of DML StatementsDeclarative-constraint violations and firing of database triggers are in turn caused by DML statements. For error-handling purposes, you must distinguish between the following two types of DML statements:

Cause Error MessageDeclarative constraint Causes predefined error messageDatabase trigger Error message specified in RAISE_APPLICATION_ERROR

Stored program unit Error message specified in RAISE_APPLICATION_ERROR

Type DescriptionImplicit DML DML statements that are associated with base table blocks.

Implicit DML is also called base table DML. By default, Forms constructs and issues these DML statements.

Explicit DML DML statements that a developer explicitly codes in triggers or program units.

Page 28: FormsII (Vol2)

13-16 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Instructor NoteStress that the On-Error trigger and the DBMS_ERROR_CODE and DBMS_ERROR_TEXT functions are specifically for handling errors in implicit DML. (Implicit DML consists of the INSERT, UPDATE, and DELETE statements implicitly created when changes to a form are saved.) The PL/SQL functions SQLCODE and SQLERRM are for use with explicit DML. (Explicit DML consists of the INSERT, UPDATE, and DELETE statements explicitly written into PL/SQL blocks in the form.)

Copyright Oracle Corporation, 2000. All rights reserved.®

Trapping Server Errors

Base table block

On-Error:DBMS_ERROR_CODEDBMS_ERROR_TEXT

Explicit DML/PU call

When Others:SQLCODESQLERRM

Constraint

DB trigger

Stored PU

Form Oracle Server

Predefinedmessa ge

RAISE_APPLICATION_

ERROR

RAISE_APPLICATION_

ERROR

Page 29: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-17......................................................................................................................................................

......................................................................................................................................................Handling Errors Raised by the Oracle Database Server

How to Trap Different Types of Oracle Database Server Errors

Note: Declarative-constraint violations and database triggers may be caused by both implicit DML and explicit DML. Stored program units are always called explicitly from a trigger or program unit.

Technical NoteThe values of DBMS_ERROR_CODE and DBMS_ERROR_TEXT are the same as what a user would see after selecting [Display Error]; the values are not automatically reset following successful execution.

Appendix F “Handling Server-Side Errors” covers server-side error handling in more detail.

FRM-Error Messages Caused by Implicit DML Errors If an implicit DML statement causes an Oracle server error, Forms displays one of these FRM-error messages:

• FRM-40508: ORACLE error: unable to INSERT record.

• FRM-40509: ORACLE error: unable to UPDATE record.

• FRM-40510: ORACLE error: unable to DELETE record.

You can use ERROR_CODE to trap these errors in an On-Error trigger and then use DBMS_ERROR_CODE and DBMS_ERROR_TEXT to determine the ORA-error code and message.

FRM-Error Messages with Web Deployed Forms A generic FRM-999999 is the most common error displayed with web forms. Meaningful information can be obtained from the JInitiator Control Panel, or from the DOS window if you run the form from a Java Appletviewer. For further information see Oracle Forms Server: Deploy Internet Applications.

Type Error HandlingImplicit DML Use the Forms built-ins DBMS_ERROR_CODE and

DBMS_ERROR_TEXT in an On-Error trigger.Explicit DML Use the PL/SQL functions SQLCODE and SQLERRM in a

WHEN OTHERS exception handler of the trigger or program unit that issued the DML statements.

Stored program unit Use the PL/SQL functions SQLCODE and SQLERRM in a WHEN OTHERS exception handler of the trigger or program unit that called the stored program unit.

Page 30: FormsII (Vol2)

13-18 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Performin g DDL with FORMS_DDL

• Syntax: FORMS_DDL (statement );

• Parameter (<=32K):PL/SQL block, DMLor DDL statement

• Characteristics:

– Unrestricted; valid in Enter Quer y mode

– Statement must not contain bind-variable references

Copyright Oracle Corporation, 2000. All rights reserved.®

Performin g DDL with FORMS_DDL

• Characteristics:

– Statement cannot return results directl y

– Use FORM_SUCCESS to checksuccess of statement

• Hints:

– Create SQL Quer y record grou pinstead of FORMS_DDL

– Call stored program unit instead ofFORMS_DDL

Page 31: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-19......................................................................................................................................................

......................................................................................................................................................Performing DDL with FORMS_DDL

Performing DDL with FORMS_DDLForms is intended primarily to perform DML operations. However, in some cases you may find it useful to issue DDL statements from a form. You can do this using the FORMS_DDL built-in function.

SyntaxFORMS_DDL(statement);

DescriptionFORMS_DDL issues dynamic SQL statements at run time, including server-side PL/SQL and DDL.

ParameterThe specified statement can be any string expression up to 32K representing a:

• PL/SQL block

• DML statement

• DDL statement

Do not end the PL/SQL block with a slash or the DML or DDL statement with a semicolon.

CharacteristicsFORMS_DDL is an unrestricted procedure that is also valid in Enter Query mode.

• The specified statement must not contain bind-variable references. However, you can concatenate the values of bind variables into the specified string.

• The statement executed using FORMS_DDL cannot return results to Forms directly.

• Use the FORM_SUCCESS built-in to check whether the statement issued using FORMS_DDL executed correctly.

Note: Consider using a query record group with a SELECT statement or calling a stored program unit, instead of executing FORMS_DDL.

Page 32: FormsII (Vol2)

13-20 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Instructor NoteDemonstration: Use ServerSide.fmb to show the creation of a temporary table with FORMS_DDL.

Copyright Oracle Corporation, 2000. All rights reserved.®

• Example: Create temporary table

• Example: Execute procedure with given name

FORMS_DDL (‘BEGIN ‘ || p_proc_name ||‘; END; ‘);IF not FORM_SUCCESS THEN

handle_server_error(DBMS_ERROR_CODE, DBMS_ERROR_TEXT);

END IF;

FORMS_DDL (‘BEGIN ‘ || p_proc_name ||‘; END; ‘);IF not FORM_SUCCESS THEN

handle_server_error(DBMS_ERROR_CODE, DBMS_ERROR_TEXT);

END IF;

Performing DDL with FORMS_DDL

FORMS_DDL (‘CREATE table temp (n_col number)‘);IF not FORM_SUCCESS THEN

MESSAGE (‘Table creation failed.‘);RAISE form_trigger_failure;

END IF;

Page 33: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-21......................................................................................................................................................

......................................................................................................................................................Using FORMS_DDL

Using FORMS_DDLThe following examples show how you can use the FORMS_DDL built-in function.

ExampleCreate a temporary table at the start of a post.

Pre-commit trigger at form level:BEGIN

FORMS_DDL(’CREATE table temp(n_col number)’);IF not FORM_SUCCESS THEN

MESSAGE (’Table creation failed.’);RAISE form_trigger_failure;

END IF;END;

ExampleExecute a procedure with a given name. This is useful if you want to determine dynamically which procedure should be executed in a certain situation.

PROCEDURE exec_proc (p_proc_name IN VARCHAR2)ISBEGIN

FORMS_DDL(’BEGIN ’|| p_proc_name ||’; END;’); IF not FORMS_SUCCESS THEN

handle_server_error(DBMS_ERROR_CODE,DBMS_ERROR_TEXT);END IF;

END;

Note: If the FORMS_DDL built-in fails, Forms sets the DBMS_ERROR_CODE and DBMS_ERROR_TEXT built-ins. Therefore, you can handle Oracle server errors using the HANDLE_SERVER_ERROR procedure discussed earlier.

Always test the SYSTEM.FORM_STATUS before calling the FORMS_DDL built-in.

Page 34: FormsII (Vol2)

13-22 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Summar y

In this lesson, you should have learned how to:

• Identif y Oracle server features usefulfor Form Builder

• Identif y PL/SQL8 su pported features

• Write PL/SQL code to tra p errors raisedby the Oracle server

– Implicit DML

– Explicit DML or stored program units

• Perform DDL with FORMS_DDL

Page 35: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-23......................................................................................................................................................

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

Summary

Oracle Database Server Features Useful for Form Builder• Declarative integrity constraints

• Stored program units

• Database triggers

• DDL

Dealing with PL/SQL Code• Store PL/SQL code in

- Oracle server

- Library

- Form

• Call PL/SQL code from

- Database trigger

- Form trigger

• Application partitioning

Handling Errors Raised by the Oracle Database Server• Causes: Declarative constraints, database triggers, stored program units

• Trap implicit-DML errors by using DBMS_ERROR_CODE and DBMS_ERROR_TEXT in an On-Error trigger

• Trap explicit DML errors and stored program unit errors by using SQLCODE and SQLERRM in a WHEN OTHERS exception handler

Performing DDL with FORMS_DDL Parameter is a string (less than or equal to 32 K) representing a PL/SQL block or DML or DDL statement.

Page 36: FormsII (Vol2)

13-24 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Copyright Oracle Corporation, 2000. All rights reserved.®

Practice 13 Overview

This practice covers the followin g topics:

• Handlin g errors caused b y stored program units

• Handlin g errors caused b y declarativeconstraint violation

Page 37: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 13-25......................................................................................................................................................

......................................................................................................................................................Practice Overview: Lesson 13

Practice Overview: Lesson 13This practice guides you through handling Oracle server errors.

Practice Contents• Handle errors caused by stored program units.

• Handle errors caused by declarative-constraint violations.

Page 38: FormsII (Vol2)

13-26 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 13: Using Server Features in Form Builder

Practice 13 1 Create a stored procedure, and process error messages that it may

generate in the CUSTSERVER form.

a Open the CUSTSERVER form and save as CUSTSERVXX where XX is your student course number. Copy the code in the SELECT_CODE program unit and create a stored procedure called SELECT_CUSTOMER. This procedure takes a user supplied value from :CONTROL.NAME to check whether a customer name already exists. Existing names will generate an error.

b Modify the When-Button-Pressed trigger for the CONTROL block CHECK_CUSTOMER button, to trap any errors generated from the stored procedure SELECT_CUSTOMER. If a customer already exists, display a warning message to the user.

c Save and compile your form module; test.

2 Whenever the user attempts to save a new customer record with an existing primary key, display an appropriate warning message.a Run your CUSTSERVER form. Attempt to insert a record with an

existing primary key. Note the generated error message.

b Define an appropriate trigger to trap the generated error message, and display the database constraint violation message and error code. Ensure that any other generated messages will continue to be displayed.

c Display all messages in an ALERT called ‘errors’.

d Save and compile your form module; test your form.

Page 39: FormsII (Vol2)

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

14

Applying Timers

Page 40: FormsII (Vol2)

14-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Instructor NoteTopic TimingLecture 20 minutes

Practice 25 minutes

Total 45 minutes

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this lesson, you shouldbe able to do the following:

• Describe timers

• Create a timer

• Modify a timer

• Delete a timer

• Handle timer expiration

Page 41: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-3......................................................................................................................................................

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

Introduction

OverviewThis lesson covers time-initiated processing; that is, processing that occurs after a certain amount of time has elapsed. The mechanism you use to do this is called a timer and it is created, modified, and deleted at run time.

ObjectivesAfter completing this lesson, you should be able to do the following:

• Describe timers

• Create a timer

• Modify a timer

• Delete a timer

• Handle timer expiration

Page 42: FormsII (Vol2)

14-4 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Technical NoteTimers are not suitable means of shutting down an application. It is the job of the operating system to recognize idle processes and shut them down.

Copyright Oracle Corporation, 2000. All rights reserved.®

Timers

• What is a timer?

• Built-ins for timers:

– FIND_TIMER

– CREATE_TIMER

– SET_TIMER

– DELETE_TIMER

– GET_APPLICATION_PROPERTY(TIMER_NAME)

Copyright Oracle Corporation, 2000. All rights reserved.®

Timers

• When-Timer-Expired trigger

• Using timers:

– Poll database

– Periodically query, commit, or rollback

– Show “About…” information at startup

Page 43: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-5......................................................................................................................................................

......................................................................................................................................................Timers

TimersForms typically processes events that are user initiated. You can use timers when you want Forms to initiate actions after a specific time period time.

What Is a Timer?A timer is a programmatic construct similar to an “internal alarm clock.” You can create, modify, or delete timers with built-ins. When you create or modify a timer, you can specify the time period for the timer. Using a trigger, you can specify actions to be performed at the end of that period.

Built-in Functions for Timers

When-Timer-Expired TriggerThis trigger fires when the specified time interval of the timer has elapsed.

Uses of Timers• Polling the database to check if a certain event has occurred

• Performing an automatic query at regular intervals

• Showing “About this...” information at form startup

• Performing automatic commits or rollbacks after a specified idle time

Web Design TipYou should restrict the frequency of timers in Web-deployed forms in order to reduce a potential increase in network traffic. Replacing timers with JavaBeans, which provide similar functionality, will benefit users as code would be executed on the Web client without invoking network traffic.

Built-in DescriptionFIND_TIMER Returns the internal timer ID (of data type

TIMER) of a timer with the given name

CREATE_TIMER Creates a timer with a given name, a defined time interval, and whether the timer should repeat on expiration.)

SET_TIMER Changes the settings for the given timer (You can modify the time interval and the repeat behavior.)

DELETE_TIMER Deletes the given timerGET_APPLICATION_PROPERTY The TIMER_NAME property returns the name of

the most recently expired timer.

Page 44: FormsII (Vol2)

14-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Instructor NoteExplain that:

1 Timer A is created, and when it expires, it is placed in the timer queue.

2 If no other processing is taking place, then the When-Timer-Expired trigger fires for Timer A.

3 After Timer A has been serviced from the queue, it can begin its next iteration.

4 Timer B (a nonrepeating timer) is created in the meantime.

5 When Timer B expires, it cannot be immediately serviced by the When-Timer-Expired trigger, because a query is taking place.

6 After the query is complete, the When-Timer-Expired trigger can fire for Timer B.

Explanation: GET_APPLICATION_PROPERTY(timer_name) returns NULL if called from any trigger other than When-Timer-Expired.

Demonstration: Use Customers.fmb to show the “About...” information at startup. Use Autocmit.fmb to show the Auto Commit/Rollback after a period of time.

Copyright Oracle Corporation, 2000. All rights reserved.®

Handling Timer Expiration

Timer Acreated

Timer Bcreated

Start

Timer Aexpired

(R)

A

When-Timer-Expired (A)Query issued

Timer Bexpired B

Timer Aexpired

(R)

B,A

Querycomplete

When-Timer-Expired (B)

When-Timer-Expired (A)

Page 45: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-7......................................................................................................................................................

......................................................................................................................................................Handling Timer Expiration

Handling Timer ExpirationWhen a timer expires, the When-Timer-Expired trigger fires and executes the desired actions. If you define more than one timer, you need to know which timer expired and how expired timers are handled.

Timer QueueWhen a timer expires, it is put in a queue of expired timers. Forms services this timer queue on a first-in-first-out basis, but only while it is waiting for user actions. After an expired timer is handled, it is removed from the queue.

Note: A repeating timer will not begin the next iteration while it is still in the timer queue.

When-Timer-Expired TriggerWhen using the When-Timer-Expired trigger remember that it:

• Fires once for each timer that expires, but only after Form Builder has completed any current processing of triggers and built-in functions

• Fires after the specified time interval, rather than exactly on the moment of expiration

• Must be defined at the form level

• Should include the GET_APPLICATION_PROPERTY built-in function for you to find out which timer has expired

ExampleHandle the expiration of two timers named HOUR_ALARM and ABOUT_STARTUP.

DECLARE v_timer_name VARCHAR2(30);BEGIN

v_timer_name := GET_APPLICATION_PROPERTY(timer_name);IF v_timer_name = ’HOUR_ALARM’ THEN

MESSAGE(’One hour has passed again.’);ELSIF v_timer_name = ’ABOUT_STARTUP’ THEN

DELETE_TIMER(’ABOUT_STARTUP’);END IF;

END;

Page 46: FormsII (Vol2)

14-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Copyright Oracle Corporation, 2000. All rights reserved.®

Creatin g a Timer

• Syntax:

• Example:

CREATE_TIMER (timer_name, milliseconds, iterate)CREATE_TIMER (timer_name, milliseconds, iterate)

v_timer_id := CREATE_TIMER ( ′hour_alarm’, cst_hour);v_timer_id := CREATE_TIMER ( ′hour_alarm’, cst_hour);

Page 47: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-9......................................................................................................................................................

......................................................................................................................................................Creating a Timer

Creating a TimerYou can create a timer by using the CREATE_TIMER built-in function, which returns type TIMER.

Syntax

ExampleAt form startup, create a timer named HOUR_ALARM that expires every hour.

DECLARE cst_hour constant NUMBER(7) := 3600000; --3600000 is one hour in milliseconds v_timer_id TIMER;BEGIN v_timer_id := CREATE_TIMER(’hour_alarm’, cst_hour);END;

CREATE_TIMER(timer_name, milliseconds, iterate)

Parameter Descriptiontimer_name The timer name

milliseconds The duration of the timer in milliseconds (Value must be between 1 and 2147483648, approximately 25 days.)

iterate Specifies whether the timer should repeat upon expiration (Valid values are REPEAT—the default—and NO_REPEAT.)

Page 48: FormsII (Vol2)

14-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Copyright Oracle Corporation, 2000. All rights reserved.®

Modif ying a Timer

• Syntax:

• Example:

SET_TIMER (timer_name, milliseconds, iterate)

SET_TIMER (timer_id, milliseconds, iterate )

SET_TIMER (timer_name, milliseconds, iterate)

SET_TIMER (timer_id, milliseconds, iterate )

SET_TIMER ( ′hour_alarm’, no_change, no_repeat );SET_TIMER ( ′hour_alarm’, no_change, no_repeat );

Page 49: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-11......................................................................................................................................................

......................................................................................................................................................Modifying a Timer

Modifying a TimerYou can modify a timer by using the SET_TIMER built-in procedure.

Syntax

ExampleSet the repeat behavior of a timer named HOUR_ALARM without changing the time interval. The trigger name depends on the situation.

BEGIN SET_TIMER(’hour_alarm’, no_change, no_repeat);END;

SET_TIMER(timer_name, milliseconds, iterate)SET_TIMER(timer_id, milliseconds, iterate)

Parameter Description

timer_name The timer name

timer_id The internal timer ID

millisec-onds

The duration of the timer in milliseconds (Value must be between 1 and 2147483648—approximately 25 days—or must be NO_CHANGE.)

iterate Specifies whether the timer should repeat upon expiration (Valid values are REPEAT (default), NO_REPEAT, and NO_CHANGE.)

Page 50: FormsII (Vol2)

14-12 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Copyright Oracle Corporation, 2000. All rights reserved.®

Deletin g a Timer

• Syntax:

• Example:

DELETE_TIMER (timer_name)

DELETE_TIMER (timer_id)

DELETE_TIMER (timer_name)

DELETE_TIMER (timer_id)

...

IF NOT ID_NULL (FIND_TIMER ( ′hour_alarm ′)) THEN

DELETE_TIMER (’hour_alarm’);

END IF;

...

...

IF NOT ID_NULL (FIND_TIMER ( ′hour_alarm ′)) THEN

DELETE_TIMER (’hour_alarm’);

END IF;

...

Page 51: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-13......................................................................................................................................................

......................................................................................................................................................Deleting a Timer

Deleting a TimerYou can delete a timer by using the DELETE_TIMER built-in procedure.

Syntax

Note: Forms generates an error if you attempt to delete a nonexistent timer.

ExampleDelete a timer named HOUR_ALARM after first checking that it exists. The trigger name depends on the situation.

BEGINIF NOT ID_NULL(FIND_TIMER(’hour_alarm’)) THEN

DELETE_TIMER(’hour_alarm’);END IF;

END;

DELETE_TIMER(timer_name)DELETE_TIMER(timer_id)

Parameter Description

timer_name The timer name

timer_id The internal timer ID

Page 52: FormsII (Vol2)

14-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Copyright Oracle Corporation, 2000. All rights reserved.®

Summar y

In this lesson, you should have learned how to:

• Create and modif y a timer with built-infunctions

– FIND_TIMER

– CREATE_TIMER

– SET_TIMER

– DELETE_TIMER

– GET_APPLICATION_PROPERTY(TIMER_NAME)

Copyright Oracle Corporation, 2000. All rights reserved.®

Summar y

• Handle timer ex piration:

– Timer queue

– When-Timer-Ex pired tri gger

Page 53: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-15......................................................................................................................................................

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

SummaryA timer is a programmatic construct much like an “internal alarm clock.”

Built-ins for Timers• FIND_TIMER

• CREATE_TIMER

• SET_TIMER

• DELETE_TIMER

• GET_APPLICATION_PROPERTY(TIMER_NAME)

Uses of Timers• Polling the database to check if a certain event has occurred

• Performing an automatic query at regular intervals

• Showing “About this...” information at form startup

• Performing an automatic commit or rollback after a specific amount of idle time

Handling Timer Expiration• When a timer expires, it is put in a first-in-first-out timer queue.

• The When-Timer-Expired trigger fires once for each timer that expires, but only after Forms has completed any current processing.

Page 54: FormsII (Vol2)

14-16 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Copyright Oracle Corporation, 2000. All rights reserved.®

Practice 14 Overview

This practice covers the followin g topic:

Periodicall y checkin g to see if there arelocked records and askin g the user tocommit or rollback

Page 55: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 14-17......................................................................................................................................................

......................................................................................................................................................Practice Overview: Lesson 14

Practice Overview: Lesson 14This practice guides you through the implementation of time-initiated processing. You will use the appropriate timer built-ins and triggers to create a timer and handle timer expiration.

Practice Contents• If table rows are locked, display an alert that asks the user to commit or

roll back changes after a set period of time.

Page 56: FormsII (Vol2)

14-18 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 14: Applying Timers

Practice 14 1 Automatically ask the users if they want to commit after a set period of

time.

a Open your CUSTOMERS form module.

b At the startup of the form, create a global variable called GLOBAL.LOCKS_PENDING. This will indicate at all times whether rows of the S_CUSTOMER table are locked. The default value is NULL. Append your new code to existing code.

c Create the On-Lock trigger to implement the default lock processing, update the global variable, and create the timer. You can import the code from the pr14_1.txt file.

d Display an alert if locks are still pending after a certain period of time elapses. This alert should ask the user to commit or roll back the changes. Define an appropriate trigger. You can import the code from the pr14_2.txt file.

e Create a Post-Database-Commit trigger to restore the NULL value to the global variable. You can import the code from the pr14_3.txt file.

f Create the On-Rollback trigger to implement the default rollback processing and restore the NULL value to the global variable. You can import the code from the pr14_4.txt file.

g Save and compile your form to test.

Page 57: FormsII (Vol2)

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

15

Including Chartsand Reports

Page 58: FormsII (Vol2)

15-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteTopic TimingLecture 30 minutes

Practice 30 minutes

Total 60 minutes

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this lesson, you shouldbe able to do the following:

• Include charts in an application

• Include reports in an application

• Integrate other documents withWeb-deployed forms

Page 59: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-3......................................................................................................................................................

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

Introduction

OverviewIn this lesson, you will learn how to include charts and reports in your application. You will also learn how to invoke additional document types with web deployed forms.

ObjectivesAfter completing this lesson, you should be able to do the following:

• Include charts in an application

• Include reports in an application

• Integrate other documents with Web-deployed forms

Page 60: FormsII (Vol2)

15-4 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteDemonstration: Step 1: Open the Employee Form (Emp.fmb) demonstration. Display the CANVAS4 canvas. From the Layout Editor toolbar, change the Block pop-up list from EMP to CONTROL. Using the Chart tool, drag a chart area onto the canvas. (The Employee form is based on the EMP table. If it does not already exist, it can be created by running the utlsample.sql file.

(Instructions for this demonstration continue in the next instructor note.)

Copyright Oracle Corporation, 2000. All rights reserved.®

Including Charts by Usingthe Chart Wizard

To invoke the Chart Wizard:

• Use theChart toolto drag achart areaontothe canvas.

• Select Tools—>Chart Wizard

Page 61: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-5......................................................................................................................................................

......................................................................................................................................................Including Charts by Using the Chart Wizard

Including Charts by Using the Chart WizardYou are able to create charts and reports within Form Builder without launching separate chart or reports engines.

The Chart Wizard leads you step-by-step through the process of creating a chart from within a form or a report.

Once the chart is created, you can modify or enhance the chart by using Graphics Builder.

Invoking the Chart WizardTo invoke the Chart Wizard:

• From the Layout Editor, use the Chart tool to drag a chart area onto the canvas.

• The New Chart Wizard dialog box appears. Click on the OK button to accept the default option, “Use the Chart Wizard.”

Incorporating a ChartThe steps to create a chart are:

1 Specify a chart type and subtype.

2 Specify the data block that contains the data you want to assign to chart columns.

3 Specify the data to appear on the Category (X) axis of the chart.

4 Specify the data to appear on the Value (Y) axis of the chart.

Follow the prompts on each page of the wizard to specify the settings for the chart you want to create.

Reentering the Chart WizardA powerful quality of the Chart Wizard is its ability to operate in reentrant mode. This means you can use the Chart Wizard to modify an existing chart created with the wizard.

To invoke the Chart Wizard in reentrant mode, select the chart object in the Object Navigator, and then select Tools—>Chart Wizard from the menu.

Page 62: FormsII (Vol2)

15-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteStep 2: Select Column for the chart type.

Step 3: Select the EMP block.

Copyright Oracle Corporation, 2000. All rights reserved.®

Including Charts by Usingthe Chart Wizard

Chart type

Copyright Oracle Corporation, 2000. All rights reserved.®

Including Charts by Usingthe Chart Wizard

Arrow indicates thatdata from the blockis represented in thechart.

Page 63: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-7......................................................................................................................................................

......................................................................................................................................................Including Charts by Using the Chart Wizard

Chart TypeSelect the style of chart that you require. The picture on the left of the wizard displays the relevant chart style.

The chart subtype options are context-sensitive; the number and style of options change depending on the chart type that you choose. Select the chart subtype that you require, and then click Next to continue to the next wizard page.

Data SourceThe next step in the Chart Wizard is to select the block that contains the data you want to represent in the chart. The data block you select determines the data that is available for assignment to the Category and Value axes of your chart.

Chart Type Description

Column Data is plotted as columns.

Bar Data is plotted as horizontal bars.

Pie Data is plotted as individual “slices” showing the relationship of parts to the whole.

Line Data is plotted as points along a line.

Mixed Data is charted using multiple chart types, such as bar and line.

Page 64: FormsII (Vol2)

15-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteStep 4: Select ENAME for the Category axis.

Step 5: Select SAL for the Value axis. Save into Disp1.ogd. Run your form.

Copyright Oracle Corporation, 2000. All rights reserved.®

Including Charts by Usingthe Chart Wizard

Arrow points to theCategory axis.

Copyright Oracle Corporation, 2000. All rights reserved.®

Including Charts by Usingthe Chart Wizard

Arrow points tothe Value axis.

Page 65: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-9......................................................................................................................................................

......................................................................................................................................................Including Charts by Using the Chart Wizard

Category AxisTo use the Chart Wizard to map data to your chart’s Category (X) axis:

1 In the Available Fields list, select the field that you want to map to the Category (X) axis of the chart.

2 Transfer the selected field from the Available Fields list to the Category Axis list.

Value AxisTo use the Chart Wizard to map data to your chart’s Value (Y) axis:

1 In the Available Fields list, select the field that you want to map to the Value (Y) axis of the chart.

2 Transfer the selected field from the Available Fields list to the Value Axis list.

You must transfer at least one field from the Available Fields list to the Category Value list before navigating to the next page.

Chart Type Description

Column, Line, Mixed chart Categories appear along the x-axis.

Bar chart Categories appear down the y-axis.

Pie chart Each category represents one segment of the pie.

Chart Type Description

Column, Line, Mixed chart Values are represented by the height of the column against the y-axis.

Bar chart Values are represented by the length of the column against the x-axis.

Pie chart Values are represented by the size of each segment.

Page 66: FormsII (Vol2)

15-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteThe default name of the Query Name property is Genie_Query. The query is created automatically with the structure of the Data Source Data Block.

Copyright Oracle Corporation, 2000. All rights reserved.®

Chart Item Properties

Filename

Execution Mode

Communication Mode

Data Source Data Block

Query Name

Data Source X Axis

Data Source Y Axis

Update on Query

Update on Commit

Page 67: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-11......................................................................................................................................................

......................................................................................................................................................Chart Item Properties

Chart Item PropertiesThe chart item properties are the following:

Property Description

Filename Specifies the name of the file where the chart is stored

Execution Mode Specifies the execution version of Graphics Builder to use: BATCH or RUNTIME

Communication Mode Specifies the communication mode to be used when calling Graphics Builder: SYNCHRONOUS or ASYNCHRONOUS

Data Source Data Block Specifies the block that contains the data to represent in the chart

Query Name Specifies the name of the query used to display the chart

Data Source X Axis Specifies the item name used to map data to the chart Category (X) axis

Data Source Y Axis Specifies the item name used to map data to the chart Value (Y) axis

Update on Query Specifies that the chart is refreshed each time you perform a query

Update on Commit Specifies that the chart is refreshed each time you perform a commit

Page 68: FormsII (Vol2)

15-12 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Technical NotePassing data is applicable only if running against a local server.

Instructor NoteYou cannot run a report based on a block that contains a long column.

Demonstration: Open customers.fmb to demonstrate the creation of a new report object.

Copyright Oracle Corporation, 2000. All rights reserved.®

Reporting Within Form Builder

• Create report objects in Object Navigator

• Run a report against a local or remote server

• Base a report on a data block

Page 69: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-13......................................................................................................................................................

......................................................................................................................................................Reporting Within Form Builder

Reporting Within Form BuilderOracle Forms Developer provides the ability to run a report against a local or a remote server with considerable ease. A report object is available that allows you to specify all the commands necessary for running a report.

Using the Report WizardUsing the Report Wizard within Form Builder, you can:

• Create a new report module based on one data block in your form

• Create a new report module

• Use an existing report module

Note: You can modify or enhance the report module by using Oracle Reports Developer.

Creating a Report Object Based on a Data BlockThe ability to base a report on a data block represents an efficient way of passing data from a form module to a report. Select the Report node in the Object Navigator.

1 Create a new report object by clicking the Create icon.

Form Builder displays the New Report dialog box.2 Specify a filename and a block name.

3 Click OK.

Form Builder runs Report Builder and displays the Report Wizard.

4 Choose the report style that most closely resembles the report you want to create.

5 Select the fields you would like to display in your report.

6 Select the fields you would like to total by choosing from a list of possible calculations. (This step is optional.)

7 Enter labels and widths for your fields and totals. (This step is optional.)

8 Select a template for your report and then click the Finish button.

The Live Previewer is displayed.

Page 70: FormsII (Vol2)

15-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteDemonstration: Set the Execution Mode property to RUNTIME, the Communication Mode to SYNCHRONOUS, and the Report Destination Type to PREVIEW.

Copyright Oracle Corporation, 2000. All rights reserved.®

Report Object Properties

Filename

Execution Mode

Communication Mode

Data Source Data Block

Query Name

Filename

Execution Mode

Communication Mode

Data Source Data Block

Query Name

Oracle Forms Developerintegration properties

Copyright Oracle Corporation, 2000. All rights reserved.®

Report Object Properties

Report Destination Type

Report Destination Name

Report Destination Format

Report Server

Other Report Parameters

Reports properties

Page 71: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-15......................................................................................................................................................

......................................................................................................................................................Report Object Properties

Report Object Properties

Oracle Forms Developer Integration Properties

Reports Properties

Property Name Description

Filename Specifies the name of the report module to be executed by Report Builder

Execution Mode Specifies the execution mode to be used when running Report Builder (Valid numeric constants for this property are BATCH and RUNTIME.)

Communication Mode SYNCHRONOUS specifies that control returns to Form Builder only after Report Builder has been exited. The end user cannot work in the form while Report Builder is running.

ASYNCHRONOUS specifies that control returns to the calling application immediately, even if Report Builder has not completed its display.

Data Source Data Block Block name used by Report Builder as data source

Query Name Query name used by Report Builder to retrieve the data (When the report is based on data from a Form Builder block, the query name property value is the block name.)

Property Name Description

Report Destination Type Specifies the type of device that will receive the report output

Report Destination Name Specifies the name of the file, printer, or Oracle Office username (or distribution list) to which the report output will be sent

Report Destination Format Specifies the format of your report (values are PDF, HTML, HTMLCSS, XML) or the printer driver to be used when DESTYPE is File.)

Report Server Name of the remote server on which the report is run

Other Report Parameters Declares additional parameters

Page 72: FormsII (Vol2)

15-16 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteWith Web-deployed forms RUN_PRODUCT can be used to run and view reports. However it requires specific environment variables to be defined. These are explained in the Oracle Forms Server: Deploy Internet Applications course. It is recommended that RUN-REPORT-OBJECT is used rather than RUN_PRODUCT.

Copyright Oracle Corporation, 2000. All rights reserved.®

Working with Reports

Built-ins for interacting with reports:

• RUN_REPORT_OBJECT

• FIND_REPORT_OBJECT

• GET_REPORT_OBJECT_PROPERTY

• SET_REPORT_OBJECT_PROPERTY

• CANCEL_REPORT_OBJECT

• COPY_REPORT_OUTPUT

• REPORT_OBJECT_STATUS

• RUN_PRODUCT

Page 73: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-17......................................................................................................................................................

......................................................................................................................................................Working with Reports

Working with ReportsYou can control reports in the Report Server dynamically when running a form by including the following built-ins in your trigger code:

Built-in Description

RUN_REPORT_OBJECT Runs a specified report on a specified server

FIND_REPORT_OBJECT Returns the internal ID of a report object

GET_REPORT_OBJECT_PROPERTY Dynamically gets report object properties at run time

SET_REPORT_OBJECT_PROPERTY Dynamically sets report object properties at run time

CANCEL_REPORT_OBJECT Cancels a report in the server queue

COPY_REPORT_OUTPUT Copies the report output back to the client

REPORT_OBJECT_STATUS Returns the current status of a report (The status codes can be FINISHED, RUNNING, CANCELED, OPENING_REPORT, ENQUEUED, INVALID_JOB, TERMINATED_WITH_ERROR, or CRASHED.)

RUN_PRODUCT Invokes one of the supported Oracle tools products and specifies the name of the module or modules to be run

Page 74: FormsII (Vol2)

15-18 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteIf you want to test the report status when you run a report against a remote server, the Communication Mode report object property must be synchronous.

Copyright Oracle Corporation, 2000. All rights reserved.®

Running a Report Againsta Local Server

DECLARE

v_rep VARCHAR2(100);

repid REPORT_OBJECT;

BEGIN

repid := FIND_REPORT_OBJECT('deptrpt');

v_rep := RUN_REPORT_OBJECT(repid);

end;

Copyright Oracle Corporation, 2000. All rights reserved.®

Running a Report Againsta Remote Server

. . .

repid := FIND_REPORT_OBJECT('barcode');

v_rep := RUN_REPORT_OBJECT(repid);

rep_status := REPORT_OBJECT_STATUS(v_rep);

IF rep_status = 'FINISHED' THEN

COPY_REPORT_OBJECT_OUTPUT(v_rep,'c:\local.pdf');

HOST('netscape c:\local.pdf');

END IF;

. . .

Page 75: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-19......................................................................................................................................................

......................................................................................................................................................Working with Reports

Running a Report Against a Local ServerThis example allows the user to run a report against a local server.

DECLARE

v_rep VARCHAR2(100);

repid REPORT_OBJECT;

rep_status VARCHAR2(20);

BEGIN

repid := FIND_REPORT_OBJECT(’deptrpt’);

v_rep := RUN_REPORT_OBJECT(repid);

end;

Running a Report Against a Remote ServerYou can run a report on a remote server by naming the server in the Report Object property, Report Server. RUN_REPORT_OBJECT returns a string that uniquely identifies the report.

In this Client Server example, this string can be used to get the report status and to copy the output.

....

v_rep := RUN_REPORT_OBJECT(repid);

IF REPORT_OBJECT_STATUS(v_rep) = ’FINISHED’ THEN

COPY_REPORT_OBJECT_OUTPUT(v_rep,’c:\local.pdf’);

HOST(’netscape c:\local.pdf’);

ELSE

MESSAGE(’Error when running report.’);

END IF;

Page 76: FormsII (Vol2)

15-20 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Instructor NoteUse show_url.fmb to demonstrate use of WEB.SHOW_DOCUMENT.

You can demonstrate how to download a report, images, and a MS Word document.

Copyright Oracle Corporation, 2000. All rights reserved.®

Built-in for downloading reports:

• WEB.SHOW_DOCUMENT

Example

Running a Report froma Web-Deployed Form

WEB.SHOW_DOCUMENT(’url’, ’target’);WEB.SHOW_DOCUMENT(’url’, ’target’);

my_url := ’http://www.summit.com/repts/emps.pdf’;

WEB.SHOW_DOCUMENT(my_url, ’_SELF’);

my_url := ’http://www.summit.com/repts/emps.pdf’;

WEB.SHOW_DOCUMENT(my_url, ’_SELF’);

Page 77: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-21......................................................................................................................................................

......................................................................................................................................................Working with Reports

Running a Report from a Web-Deployed FormWhen you call RUN_REPORT_OBJECT from a Web-deployed form, the report is created on the Web server. You can specify a directory location for report output, and a Web-deployable report format, with the following Report Object properties:

Viewing Report Output from a Web-Deployed FormYou can view report output with the built-in WEB.SHOW_DOCUMENT. This is supplied with the Oracle Forms Developer WEB built-in package, and you can only use it with Web-deployed forms. The built-in has two parameters:

• URL of the document to be downloaded. The document may, for example, be a report, an image, a form that you wish to run on the Web, or for another Web-site.

• Target window or frame for displaying the report:

‘_BLANK’ specifies that the document can be downloaded in a new HTML window

‘_SELF’ specifies that the document is downloaded to the base HTML page window or frame

‘_TOP’ specifies that the document is downloaded to the base HTML page, replacing any frames.

‘_PARENT’ specifies that the document is downloaded to the parent window of the base HTML page

In this example, WEB.SHOW_DOCUMENT is used to download the emps report which has been formatted in pdf:

WEB.SHOW_DOCUMENT(’http://www.summit.com/repts/emps.pdf’,

‘_blank’);

Property Value

Report Destination Format File

Report Destination Name ‘pathname’ / ‘report filename’

Report Destination Format HTML

HTMLCSS

PDF

XML

Page 78: FormsII (Vol2)

15-22 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Copyright Oracle Corporation, 2000. All rights reserved.®

Summar y

In this lesson, you should have learned how to:

• Invoke the Chart Wizard

• Exploit Re port features in Form Builder

– Create re port ob jects

– Run against local or remote server

– Base re ports on data blocks

• Manage report ob jects with forms built-ins

– GET_REPORT_OBJECT_PROPERTY

– SET_REPORT_OBJECT_PROPERTY

Copyright Oracle Corporation, 2000. All rights reserved.®

Summar y

• Communicate with Re port server

– RUN_REPORT_OBJECT

– FIND_REPORT_OBJECT

– CANCEL_REPORT_OBJECT

– REPORT_OBJECT _STATUS

– COPY_REPORT_OUTPUT

• Communicate with a Web server

– WEB.SHOW_DOCUMENT

Page 79: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-23......................................................................................................................................................

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

SummaryIn this lesson, you should have learned how to include charts and reports in your application. You should have learned how to invoke the Chart Wizard.

Reporting Features in Form Builder• Create report objects

• Base reports on data blocks

• Run against local or remote server

• Run reports from Web-deployed forms

Interacting with Reports• RUN_REPORT_OBJECT

• FIND_REPORT_OBJECT

• CANCEL_REPORT_OBJECT

• REPORT_OBJECT_STATUS

• COPY_REPORT_OUTPUT

• GET_REPORT_OBJECT_PROPERTY

• SET_REPORT_OBJECT_PROPERTY

• WEB.SHOW_DOCUMENT

Page 80: FormsII (Vol2)

15-24 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Copyright Oracle Corporation, 2000. All rights reserved.®

Practice 15 Overview

This practice covers the followin g topics:

• Creatin g a chart to dis play the total ordersfor each customer

• Creatin g a report based on theS_CUSTOMER block

Page 81: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-25......................................................................................................................................................

......................................................................................................................................................Practice Overview: Lesson 15

Practice Overview: Lesson 15This practice guides you in creating and displaying charts and reports within your forms application.

Practice Contents• Create a chart to display the total orders for each customer.

• Create a report based on the S_CUSTOMER block.

Page 82: FormsII (Vol2)

15-26 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Practice 15 1 Create a chart object by using the Chart Wizard. This chart should

display the total orders for each customer.

a Open the ORDCHART form module. Save as ORDCHARTXX where XX is your student course number. This form module contains a S_ORD block. Only one item from this block is visible: TITLE. This item displays a title for your chart.

b In the Layout Editor, use the Chart tool to drag a chart area onto the canvas. Select “Use the Chart Wizard” from the New Chart Object dialog box. Do not specify a title for the chart.

c Select Column as chart type, Plain as chart subtype.

d Specify the S_ORD block as the data block that contains the data you want to assign to chart columns.

e Select CUSTOMER_NAME to appear on the Category (X) axis, and TOTAL to appear on the Value (Y) axis of the chart.

f Click the Finish button.

g Save and compile your form module. Deploy your form to the Web to test. To display the chart, click in the Title item on the Chart tab.

2 Create a report object based on the S_CUSTOMER block. This report displays a customer list using a tabular layout. Display only the ID, NAME, COUNTRY, and REGION_ID fields.

a Open the CUSTREPT form. Save as CUSTREPXX where XX is your student course number.Create a new report object.

b This will invoke 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”.

e Create a button named CUST_REP_BUTTON in the control block. Display this button on the CV_CUSTOMER canvas.

Page 83: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II 15-27......................................................................................................................................................

......................................................................................................................................................Practice 15

f Create a When-Button-Pressed trigger on the CUST_REP_BUTTON button to run the report.

g Change the Query All Record property value to Yes for the S_CUSTOMER block.

h Save and compile your form module. Deploy your form to the Web to test. Query a customer record before calling the report.

Page 84: FormsII (Vol2)

15-28 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Lesson 15: Including Charts and Reports

Page 85: FormsII (Vol2)

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

A

Practice Solutions

Page 86: FormsII (Vol2)

A-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 1 Solutions1 Create a new menu module.

a Using the following screenshot as a guideline, create a new menu module called M_SUMMITXX where XX is your student coursenumber.

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.

Page 87: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-3......................................................................................................................................................

......................................................................................................................................................Practice 1 Solutions

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

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

Page 88: FormsII (Vol2)

A-4 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

For each of the items, set the properties as follows:• Edit Menu

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

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

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

Page 89: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-5......................................................................................................................................................

......................................................................................................................................................Practice 1 Solutions

Create a new menu to the right of Sort By and rename it Query. See the previous solution.Create two new menu items under Query. See the previous solution. Set the properties as follows:

• Query Menu

b Save as M_SUMMIT and compile the menu module.

c Attach the menu module to the ORDERS form.

Open the ORDERS form and set the Menu Module property to M_SUMMIT for the form module.

d Save and compile the form module as ORDGXX where XX is your student course number.

e Run and test your ORDERS form.

2 Add pop-up menus to the CUSTOMERS form.

a Open the CUSTOMERS form module. Save as CUSTGXX where XX is your student course number.

b Copy the EDIT_MENU menu from your M_SUMMIT menu module to your CUSTOMERS form. Attach this pop-up menu to the Comments item.

Select EDIT_MENU from the M_SUMMIT menu module.Click the right mouse button and select Copy.Select the Pop-up Menus node from the CUSTOMERS 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. Deploy your form to the Web to test.

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 90: FormsII (Vol2)

A-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 2 Solutions1 Define a check menu item.

a Open your M_SUMMIT menu module and add a new menu item to the Sort By menu; name it Display_Help.

See previous solution.Set the properties as follows:

b If Display_Help is selected, enable the ORDERS form toolbar HELP button and set the toolbar canvas background color to grey.

If Display_Help is not selected, disable the ORDERS form toolbar HELP button and set the toolbar canvas background color to red.

You can import the code from the pr2_1.txt file.

Import the pr2_1.txt file.If get_menu_item_property( 'sort_by_menu.display_help', checked) = 'TRUE' then

set_canvas_property('toolbar',

visual_attribute,'Toolnormal'); set_item_property('control.showhelp', enabled, property_true);

Else

set_canvas_property('toolbar', visual_attribute,'Toolred');

set_item_property('control.showhelp', enabled, property_false);

End If;

c Save and compile the menu module. Deploy your menu on the Web.

d Deploy your ORDERS form on the Web to test your menu.

2 Synchronize the menu module with the form.

a Write startup code for your M_SUMMIT menu module that synchronizes the Display_Help menu item with the toolbar HELP button. You can import the code from the pr2_2.txt file.

Menu Label Menu Item Type Command Type

Display Help Check PL/SQL

Page 91: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-7......................................................................................................................................................

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

Use the Startup Code menu module property to invoke the PL/SQL Editor.If Get_Item_Property('Control.Showhelp', Enabled) = 'TRUE' Then

Set_Menu_Item_Property( 'Sort_By_Menu.Display_Help', Checked, Property_True );

Else

Set_Menu_Item_Property( 'Sort_By_Menu.Display_Help', Checked, Property_False );

End If;

b Save and compile your menu module. Deploy to the Web.

c Deploy your ORDERS form on the Web to test your menu.

3 Attach your M_SUMMIT menu to your CUSTOMERS form. The menu item Sort_By is not relevant, and should not be visible to the user.

a Attach the menu module to your CUSTOMERS form.

Open the CUSTOMERS form and set the Menu Module property to M_SUMMIT for the form module.

b Modify the startup code of the M_SUMMIT menu module to hide the SORT_BY menu when the CUSTOMERS form is opened. You can import the code from the pr2_3.txt file to replace the existing code. You may need to change the code to conform to the exact names you gave to the Main Menu and its menu items.

Import pr2_3.txt file to add the following code.If :System.current_form = 'CUSTOMERS'then set_menu_item_property( 'main_menu.sort_by', visible, property_false);

End if;

c Save and compile the menu module; deploy your menu to the Web.

d Deploy your CUSTOMERS form to the Web and test your application. Execute a Query and click the Orders button to move to the ORDERS form. Note that the Sort_By menu item is hidden when the CUSTOMERS form is current, and is visible when the ORDERS form is current.

4 With both the ORDERS and CUSTOMERS form modules, restore the default menu, (DEFAULT&SMARTBAR).

Page 92: FormsII (Vol2)

A-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 3 Solutions1 Maintain consistent functionality in your form module by using key triggers.

Define a key trigger in your ORDERS form to give users consistent functionality whenever they exit the form, either using the menu or when the CONTROL.EXIT_BUTTON button is pressed.

a Redefine [Exit Form] in your ORDERS form so that an alert message is displayed to users before allowing them to exit the form.

b Amend the entry in Keyboard Help to “Exit Orders” for the key trigger.

c Save and compile your form. Deploy your form to the Web to test.

Create a form-level KEY-EXIT trigger. Copy the code from the CONTROL.EXIT_BUTTON When-button-pressed trigger. Set_Alert_Property('Exit_Alert', ALERT_MESSAGE_TEXT,

'Do you really want to leave the form?');

If show_alert('EXIT_ALERT') = alert_button1 then

exit_form;

End if;

Change the keyboard help text in the KEY-EXIT trigger property pallette to “Exit Orders”, and set keyboard help display to YES.

d Customize the Alert Text message in your key trigger and ensure that it is displayed whenever the user exits the form using the EXIT_BUTTON on the Control block.

Replace the code in the EXIT_BUTTON When-Button -Pressed trigger with: do_key(' Exit_Form ' );

e Save and compile your form module. Deploy to the Web and test your form.

If you have time

2 Disable [Enter query] in your CUSTOMERS form by creating an appropriate key trigger. Replace [Enter Query] functionality with a call to the customized query form CUSTQUERY. This form allows the user to select a CUSTOMER ID, a CUSTOMER NAME, or a SALES REP ID. The user selections are returned to your CUSTOMER form using global variables.

a Add the following code to your key trigger:call_form('custquery',no_hide);

execute_query;

Page 93: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-9......................................................................................................................................................

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

Create a form-level KEY-ENTQRY trigger. Add the code: call_form('custquery',no_hide);

execute_query;

You may import the code from pr3_1.txt file.b The CUSTQUERY form will return three values, held in global

variables. The contents should be passed to your CUSTOMERS form to allow the user to execute a restricted query. Use the following global variables::global.custid;

:global.custname;

:global.repid;

Pass the values to the S_CUSTOMER block items in a PRE_QUERY trigger::s_customer.id := :global.custid;

:s_customer.name := :global.custname;

:s_customer.sales_rep_id := :global.repid;

c Define the global variables in your CUSTOMERS form to ensure that the user can perform unrestricted queries.

Define the global variables in the When-New-Form-Instance trigger:default_value( '' , ' global.custid ' );

default_value( '' , ' global.custname ' );

default_value( '' , ' global.repid ' );

d Save and compile your CUSTOMER form. Deploy your form to the Web to test.

Page 94: FormsII (Vol2)

A-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

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

1 In your CUSTOMERS form, define a mouse event trigger on S_CUSTOMER.COMMENTS that invokes the item’s editor when the user double-clicks the item.

When-Mouse-Doubleclick on s_customer.comments Edit_TextItem;

2 In your ORDERS form change the mouse cursor symbol to “busy” while the HELP canvas is displayed.

a Ensure that the default symbol is restored whenever the user hides the HELP canvas.

When-Button-Pressed on :control.showhelpSet_Application_Property(cursor_style,'help');

When-Button-Pressed on :control.hidehelp Set_Application_Property(cursor_style,'normal');

b The user can close the HELP canvas without pressing the HIDEHELP button, by navigating to an item in another block. How can you ensure that the mouse cursor is always restored?

Define a Post-Block trigger for the Control Data block. Copy the code to restore the mouse cursor from your :Control.hidehelp button When-Button-Pressed trigger.

c Save and compile your form modules. Deploy your forms to the Web to test.You can call the ORDERS form from your CUSTOMERS form.

Page 95: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-11......................................................................................................................................................

......................................................................................................................................................Practice 5 Solutions

Practice 5 Solutions1 Manipulate a multiple-window form.

a In your ORDERS form module, ensure that the form is exited when a user closes the orders window using the window system menu box. An alert should be displayed to users asking them to confirm that they wish to leave the application.

Define a When-Window-Closed trigger at Form Level.Call the do_key built-in to execute [Exit_Form].

b If a user closes the Inventory window through the system menu box, ensure that the form remains open with the cursor positioned in the Orders window.

In the When-Window-Closed trigger, use :system.event_window to identify the current window:If :system.event_window = 'WIN_ORDER' then

do_key('exit_form');

else

go_block('s_ord');

end if;

c Whenever the user navigates between the order and inventory windows, place the cursor in the first navigable item within the current window.

Define a When-Window-Activated trigger at form level. Use :system.event_window to identify the current window, and use the GO_BLOCK built in to enforce navigation within the appropriate window.

d Save and compile your form. Deploy your form to the Web to test.

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

a Using an appropriate trigger, disable the COMMENTS tab page whenever the COMMENTS item contains no text.

b The trigger should fire whenever the user navigates to another record.

Page 96: FormsII (Vol2)

A-12 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Define a WHEN-NEW-RECORD-INSTANCE trigger. If the item COMMENTS contains no data, use the built-in SET_TAB_PAGE_PROPERTY to disable the COMMENTS page. You may import the code from the pr5_1.txt file.If :S_customer.comments is null then

set_tab_page_property(‘comments’, enabled, property_false);

else

set_tab_page_property(‘comments’, enabled, property_true);

end if;

c Whenever the user moves from one tab page to another, ensure that the mouse cursor is placed in the first navigable field within the page.

Define a WHEN-TAB-PAGE-CHANGED trigger. Identify the current tab page with the :system.tab_new_page system variable. Use the GO_ITEM built-in to place the cursor in the first navigable field.

d Save and compile your form. Deploy your form to the Web to test.

If you have time

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

You can use the ‘NEXT’ and ‘PREVIOUS’ navigation item properties.

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

No specific solution.

Page 97: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-13......................................................................................................................................................

......................................................................................................................................................Practice 6 Solutions

Practice 6 Solutions 1 Create a server-side package containing a procedure to return a REF

cursor.

a Create the Orders_pkg package specification; you can import the code from the pr6_1.txt file.

b Create the Orders_pkg package body; you can import the code from the pr6_2.txt file.

Use the Stored Procedure editor in Forms and import the code from the files.

c Examine the Orders_pkg package body to identify required parameter values.

A value of ‘P’,’C’ or ‘S’ is passed to the REF cursor to determine which query is required. The REF cursor can query on either products, customers, or sales reps.

2 Open the ORDERREFCURSOR.fmb file and save as ORDREFXX where XX is your student course number. This form contains a control block, called CHOOSE, and a group of option buttons which allows the user to specify a parameter value to be passed to the REF cursor.

a Create a data block called SELECTION and base it on the REF cursor procedure that you have just created.

Call the Data Block wizard and select “Stored Procedure” for data block type.Specify full procedure name:‘orders_pkg.query_proc’Press the Refresh button. Available columns will be displayed.Select all as Database Items.

b Pass the name of the radio group as the value for the P_VIEW argument: ‘:choose.view_type’ .

For the P_VIEW argument, set the value to ‘:choose.view_type’

Select Finish to end the wizard.c In the layout editor, customize the canvas layout to ensure that

SELECTION items are displayed to the left of the option buttons group.

d Save and compile your form. Deploy your form to the Web to test.

Page 98: FormsII (Vol2)

A-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 7 Solutions1 Create a data block based on a relational table with an object column.

a Create a form called OBJ_COLXX where XX is your student coursenumber.

b Using the Data Block Wizard, create a block based on the REL_EMP_TABLE_OBJCOL relational table.

c Select the columns ID, FIRST_NAME, and LAST_NAME.

d Expand the object column DEPT_ID and select the attributes ID and NAME. Note the names that are given to the new items.

e In the Layout Wizard, select all available items for display. Change the prompt for item DEPT_ID to Department ID and DEPT_ID_NAME to Department Name. Use a form layout.

f Save, compile, and test your form.

If you have time

2 Create a block based on a relational table with an REF column, and specify an LOV to populate the REF column.

a Create a form called REF_COLXX where XX is your student coursenumber.

b Create a block based on the REL_EMP_TABLE_REFCOL relational table.

c Select the columns ID, FIRST_NAME, and LAST_NAME.

d Select the DEPT_ID attributes ID and NAME.

Note that there are two items called DEPT_ID. The first is expandable and has the term “LOOKUP” in parentheses after the name. The second represents the REF column value itself. The REF item is included automatically when the LOV is created.)

e Create an LOV for the REF item DEPT_ID. Select the check box, and select OO_DEPT_TABLE as the source for the LOV.

f In the Layout Wizard, select all available items for display.

The REF item DEPT_ID is included in the list of items in the Object Navigator but is not included in the list of available items in the Layout Wizard.

g In the Object Navigator, identify the canvas with which item DEPT_ID is associated.

REF item values are normally not displayed, so by default the REF item is assigned to the Null canvas.)

h In the Object Navigator, check that an LOV and associated record group have been created.

i Save, compile, and test the form.

Page 99: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-15......................................................................................................................................................

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

Practice 8 Solutions1 Open your ORDERS form and examine the properties of the relation

called S_ORD_S_ITEM.

a Note the deletion and coordination property values.

b Run the ORDERS form and test the way deletes are handled.2 Implement a query coordination-type toggle.

a Add two check boxes to the control block with the following properties:

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

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

When-Checkbox-Changed on CONTROL.IMMEDIATE

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 100: FormsII (Vol2)

A-16 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

If GET_RELATION_PROPERTY( ’s_ord_s_item’, DEFERRED_COORDINATION ) = ’FALSE’ Then

SET_RELATION_PROPERTY(’s_ord_s_item’, DEFERRED_COORDINATION, PROPERTY_TRUE);

SET_ITEM_PROPERTY(’control.auto_query’, ENABLED,

PROPERTY_TRUE );

Else

SET_RELATION_PROPERTY(’s_ord_s_item’, DEFERRED_COORDINATION, PROPERTY_FALSE);

SET_ITEM_PROPERTY(’control.auto_query’, ENABLED,

PROPERTY_FALSE );

End If;

d Make sure that the second check box enables a user to toggle between automatic query and no automatic query for the detail block. This check box should be disabled if the other check box indicates immediate coordination. You can import the code from the pr8_2.txt file.

When-Checkbox-Changed on CONTROL.AUTO_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 Save, compile, and test your form.

Page 101: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-17......................................................................................................................................................

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

If you have time

3 Synchronize the check boxes at form startup.

a Open your ORDERS form module

b Create a procedure called SYNCHRONIZE_CHECKBOX. This procedure synchronizes the IMMEDIATE and AUTO_QUERY check boxes with the current default value. You can import the code from the pr8_3.txt file.

Procedure synchronize_checkbox IS

Begin

IF GET_RELATION_PROPERTY(’s_ord_s_item’', DEFERRED_COORDINATION) = 'FALSE' Then

:control.immediate := ’Y’;

SET_ITEM_PROPERTY(’control.auto_query’, ENABLED, PROPERTY_FALSE);

Else

:control.immediate := ’N’;

SET_ITEM_PROPERTY(’control.auto_query’, ENABLED, PROPERTY_TRUE );

End If;

If GET_RELATION_PROPERTY(’s_ord_s_item’, AUTOQUERY) = ’TRUE’ Then

:control.auto_query := ’Y’;

Else

:control.auto_query := ’N’;

End If;

End;

c Call this procedure from the When-New-Form-Instance trigger.

d Save, compile, and run the module.

Page 102: FormsII (Vol2)

A-18 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 9 Solutions1 Create a multiple-form application by linking the CUSTOMERS and the

SALESREP forms. The SALESREP form provides a look up facility for :S_CUSTOMER.SALES_REP_ID. It replaces the SALES_REP_LOV list of values. Values are selected by mouse double click.a Open SALESREP form and save as SALESREPXX where XX is

your student course number.

b In your CUSTOMERS form, modify the code in the SALES_LOV_BUTTON When-Button-Pressed trigger to call the SALESREP form.

c Ensure that the user can see, but not navigate to, your CUSTOMERS form, while the SALESREP form is open.

d Update :S_CUSTOMER.SALES_REP_ID with the value selected by the user in the SALESREP form. The selected Sales Rep ID is returned in a GLOBAL variable called “salesrepid”. This variable contains either a valid value or the text “NOT SELECTED”.

Ensure that you call your SALESREP form which is identified by the XX suffix.CALL_FORM(‘SALESREP’,no_hide);If :global.salesrepid <> ‘NOTSELECTED’ then :S_CUSTOMER.SALES_REP_ID := :global.salesrepidEnd if;

e Save and compile your form. Deploy your form to the Web to test.

2 Modify your multiple-form application to enable the SALESREP form to be called in post mode only.

a Hide the CUSTOMERS form when the SALESREP form is displayed.

Change your When-Button-Pressed trigger code for the SALES_LOV_BUTTON in the CUSTOMERS form:CALL_FORM(‘SALESREP’,hide);If :global.salesrepid <> ‘NOTSELECTED’ then :S_CUSTOMER.SALES_REP_ID := :global.salesrepidEnd if;

Page 103: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-19......................................................................................................................................................

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

b In the SALESREP form, ensure that whenever the form has been opened by ‘CALL_FORM’, that a [Commit Form] performs a POST.

In a KEY-COMMIT trigger, define the following code:If get_application_property(calling_form) is not null then

post;

else

commit_form;

end if;

c Ensure that updates in SALESREP are not cleared when the user exits the form.

SALESREP form KEY-EXIT triggerI f get_application_property(calling_form) is not null then

exit_form(do_commit,no_rollback);

else

exit_form;

end if;

d Save and compile your form. Deploy your form to the Web to test.

3 The SALESREP form displays a list of all employees; modify your application to ensure that only Sales Representatives are displayed when the form is called from CUSTOMERS.

a Create a parameter called EVERYONE’ in the SALESREP form. Specify a default value of ‘Y’.

Create a PARAMETER object, called “EVERYONE” in the Object Navigator. Define as character type CHAR, with a default value of “Y”.

b Ensure that the SALESREP form will perform an unrestricted query whenever the parameter value = ‘Y’. If the parameter value = ‘S’, a restricted query should be performed, selecting only Sales Representatives.

Create a PRE-QUERY trigger :If :parameter.everyone = ‘S’ then

:s_emp.title := Sales Representative’;

end if;

Page 104: FormsII (Vol2)

A-20 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

c In the CUSTOMERS form, pass the parameter value “S” to the SALESREP form. Create a parameter list called EMPS. Add the ‘EVERYONE’ parameter to the parameter list. The type of this parameter is TEXT_PARAMETER, and it is initialized with the value “S”.Pass the parameter list to the SALESREP form by using the CALL_FORM built-in.You can import the code from the pr9_1.txt file.

Insert the following code for the SALES_LOV_BUTTON When-Button-Pressed trigger:Declare

vpid PARAMLIST;

Begin

If not Id_Null( Get_Parameter_List( ’EMPS’ ) ) Then

Destroy_Parameter_List(’EMPS’);

End If;

vpid := Create_Parameter_List(’EMPS’);

Add_Parameter( vpid, ’everyone’, TEXT_PARAMETER,’S’);

Call_Form(’SALESREP’, Hide, No_Replace, No_Query_Only, No_Share_Library_Data, ‘EMPS’ );

If :global.salesrepid = ‘NOT SELECTED’ then

message(‘New Sales Rep not selected’);

Else

:s_customer.sales_rep_id := :global.salesrepid;

End if;

End;

d Save and compile your forms. Deploy your form to the Web to test.

Page 105: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-21......................................................................................................................................................

......................................................................................................................................................Practice 10 Solutions

Practice 10 Solutions1 Create a dynamic list item populated from a design-time query record

group. The record group will hold region ID and the name of the departments in the S_DEPT table.

a Open the Employees form. Save as EmpXX where XX is your student course number. In the Object Navigator, create a record group named DEPT_ID based on the query below:SELECT name || ’ in region ’ || TO_CHAR(region_id) Name, TO_CHAR(id) Id

FROM s_dept

ORDER BY 1

b Convert the text item DEPT_ID into a list item, with a Poplist style. Resize the list item in the Layout Editor.

c Create one element in the list item. Specify a label of ‘Dummy’ and a value of ‘0’.

d Create a procedure called POPULATE_DEPT_LIST. This procedure will accept the list item name as an argument and populate the list item dynamically at run time, using the design-time query record group. You can import the code from the pr10_1.txt file.

Procedure Populate_Dept_list p_list_item in varchar2) is

cst_rg_nom constant varchar2( 30 ) :=

Get_Item_Property(p_list_item, Item_Name );

Begin

If Populate_Group( cst_rg_nom ) = 0 then

Populate_List( p_list_item, cst_rg_nom );

End If;

Copy(Get_List_Element_Value( p_list_item,1), p_list_item);

End;

Page 106: FormsII (Vol2)

A-22 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

e Call the procedure each time a new record is created.

When-Create-Record Trigger on the EMP Block:Clear_List(’S_Emp.Dept_Id’);

POPULATE_DEPT_LIST(’S_Emp.Dept_Id’);

f Compile and save your form module. Test.

If you have time

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

a Delete the DEPT_ID record group and remove the code from the When-Create-Record trigger.

b Create a procedure called CREATE_DEPT_LIST which will dynamically create a record group called QDEPT, if it does not already exist. The procedure will also populate the record group by using the query: SELECT name ||TO_CHAR(region_id) Name,

TO_CHAR(id) Id

FROM s_dept

ORDER BY 1

c The procedure will also populate the list item S_EMP.DEPT_ID.

d You can import the procedure code from pr10_2.txt file.

Procedure Create_Dept_List is

v_rg_id recordgroup;

v_error number;

rg_count number;

Begin

v_rg_id := find_group('qdept');

if id_null(v_rg_id) then

v_rg_id := create_group_from_query('qdept',

Page 107: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-23......................................................................................................................................................

......................................................................................................................................................Practice 10 Solutions

'Select name||to_char(region_id), to_char(id) from s-dept

order by 1');

end if;

v_error := populate_group(v_rg_id);

populate_list('s_emp.dept_id',v_rg_id);

Copy(Get_List_Element_Value('s_emp.dept_id',

1),'s_emp.dept_id');

End;

e Call the procedure from the When-Create-Record trigger.

When-Create-Record Trigger on the S_EMP Block.Create_Dept_List;

f Compile and save your form module. Test.

Page 108: FormsII (Vol2)

A-24 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 11 Solutions1 Create a picklist by using the picklist class. This picklist enables the end

user to select order items from a product list, and to place selections in a second list.

a Create a new form module, called PICKXX where XX is your student course number. Open the Form_Builder_II.olb object library. This library contains form objects and code for the picklist.Copy the PICKLIST_BASIC object group to your form module.Copy the PICKLIST object group into your new form module.

b Ensure the CONTROL block is the last defined data block in the object navigator.

c Attach the picklist.pll library. This contains the functions and procedures required for creating the picklist.

d Define a When-New-Form-Instance trigger which will create and populate the picklist. You can import the code from the pr11_1.txt file.

Declare

dummy number;

Begin

Default_Value(‘’,’Global.where_cls’);

pick_list.create_picklist;

dummy := pick_list.populate_list_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

Page 109: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-25......................................................................................................................................................

......................................................................................................................................................Practice 11 Solutions

Create the picklist with the picklist.Create_Picklist procedure.

Call function pick_list.Populate_Picklist_With_Query to populate the List_in object. You must define a query that returns the ID, name and suggested prices from the S_PRODUCT table.

Call pick_list.Set_Picklist_Selection procedure to select the first element in the list.

Display both lists by using the pick_list.Display_Picklist procedure.

Exclude from the query any products already in the current S_ITEM block. You should use the global variable :GLOBAL.where_cls .

e Save and compile your form. Deploy your form to the Web.

f In your ORDERS form, modify the When-Button-Pressed trigger for the CONTROL.PRODUCT_LOV_BUTTON so that it calls your new form module.

Call_Form(’picklist’, No_Hide );

g Save and compile your form. Deploy your form to the Web to test.

If you have time

2 In the ORDERS form, add a calendar on the S_ORD.DATE_ORDERED item and S_ORD.DATE_SHIPPED item.

a From the calendar page of the Form_Builder_II.olb object library, copy the calendar object group.

b Attach the PL/SQL library calendar.pll , which contains the Date_LOV package, to your module.

c Create a Key-Listval trigger on the date ordered item. Add code to display the calendar using the Date_LOV package. You can import the code from the pr11_2.txt file.

date_lov.get_date( sysdate, -- initial date

’s_ord.date_ordered’, -- return block.item

240, -- window x position

60, -- window y position

’Order Date’, -- window title

’OK’, -- ok button label

’Cancel’, -- cancel button label

TRUE, -- highlight weekend days

FALSE, -- autoconfirm selection

FALSE); -- autoskip after selection

Page 110: FormsII (Vol2)

A-26 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

d Create a Key-Listval trigger on the date shipped item. Add code to display the calendar using the Date_LOV package.You can import the code from the pr11_3.txt file.

date_lov.get_date( sysdate + 7, -- initial date

’s_ord.date_shipped’, -- return block.item

240, -- window x position

60, -- window y position

’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 and compile your form module. Deploy your form to the Web to test.

Page 111: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-27......................................................................................................................................................

......................................................................................................................................................Practice 12 Solutions

Practice 12 Solutions1 Provide an alternative user interface for your Web-deployed forms by

including Pluggable Java Components (PJCs).

a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb , where XX is your student course code.

b Change the :EMP.SAL item so that values are displayed as asterisks at run time. Use the PJC ‘PasswordFieldPJC.class’. This class file is held in the folder:FORMS60_JAVADIR /oracle/forms/demos

In the :EMP.SAL property pallette, set the implementation class to ‘oracle.forms.demos.PasswordFieldPJC’.

c Change the :EMP.ENAME item so that the mouse cursor changes to ‘hand’ style whenever the cursor is moved over the item. Use the PJC ‘ModCursor.class’. This class file is held in the folder:FORMS60_JAVADIR /oracle/forms/demos

In the :EMP.ENAME property palette, set the implementation class to ‘oracle.forms.demos.ModCursor’.

d Use the built-in SET_CUSTOM_PROPERTY in an appropriate trigger, to specify the cursor style:SET_CUSTOM_PROPERTY(‘Emp.Ename’,1, ‘DOCURSOR’,‘HAND’);

In the When-New-Form-Instance trigger, include: SET_CUSTOM_PROPERTY(‘EMP.ENAME’,1,‘DOCURSOR’,‘HAND’);

e Save and compile your form. Deploy your form to the Web to test.

2 Create a JavaBean area in the Layout Editor to enable users to specify hyperlinks of their choice.

a Create a new data block called ‘LINK’ in your JAVAEMP form.

b Create a Bean Area called ‘HYPERLINK1’ in the new data block and specify the class file ‘HyperLinkWrapper.class ’.

Page 112: FormsII (Vol2)

A-28 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Create a new data block called ‘LINK’, and define a Bean Area in the Layout editor. In the Bean Area property palette, set the Implementation class to ‘oracle.forms.demos.HyperLinkWrapper’.

c Create an appropriate trigger to identify the user-supplied URL from the JavaBean, and to download his or her Web page. You can import the code from the pr12_1.txt file.

Attach the When-Custom-Item-Event trigger to the Bean Area and include the following code:Declare

eventName varchar2(20) := :system.custom_item_event;

eventValues ParamList;

eventValueType number;

url varchar2(255);

Begin

eventValues := get_parameter_list( :system.custom_item_event_parameters);

if(eventName = 'LINKEVENT') then

get_parameter_attr(eventValues, 'LINKEVENTDATA', eventValueType,url);

web.show_document(url,'_blank');

end if;

End;

d Create two text items, one called ‘URL’ to accept a URL and one called ‘LABEL’ to accept a URL label. These will enable the user to select a different URL. Set the maximum length for the URL text item to 255.

Create two text-items, URL and LABEL, in the Data Block ‘LINK’.

Page 113: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-29......................................................................................................................................................

......................................................................................................................................................Practice 12 Solutions

e Create a push button with an appropriate trigger that will accept values from the URL and LABEL text items, and pass them to the JavaBean. You can import the code from the pr12_2.txt file.

Create a push button and add the following code to the When-Button-Pressed trigger:If(:URL is not null) and (:LABEL is not null) then

set_custom_property('HYPERLINK1',1, 'LINKLABEL', :label);

set_custom_property('HYPERLINK1',1, 'LINKURL', :URL);

set_custom_property('HYPERLINK1',1, 'ACTIVECOLOR', '#8BFC5E');

set_custom_property('HYPERLINK1',1, 'VISITEDCOLOR', '#DF37E1');

set_custom_property('HYPERLINK1',1, 'NORMALCOLOR', '#F3F4AA');

else

set_custom_property('HYPERLINK1',1, 'LINKLABEL', 'Oracle Technet!');

set_custom_property('HYPERLINK1',1, 'LINKURL', 'http://technet.oracle.com');

end if;

f Save and compile your form. Deploy your form to the Web to test.

Page 114: FormsII (Vol2)

A-30 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 13 Solutions1 Create a stored procedure, and process error messages that it may

generate in the CUSTSERVER form.

a Open the CUSTSERVER form and save as CUSTSERVXX where XX is your student course number. Copy the code in the SELECT_CODE program unit and create a stored procedure called SELECT_CUSTOMER. This procedure takes a user supplied value from :CONTROL.NAME to check whether a customer name already exists. Existing names will generate an error.

b Modify the When-Button-Pressed trigger for the CONTROL block CHECK_CUSTOMER button, to trap any errors generated from the stored procedure SELECT_CUSTOMER. If a customer already exists, display a warning message to the user.

Add the following code:exception

when no-data_found then

message(sqlcode||’ ‘||sqlerrm);

raise form_trigger_failure;

c Save and compile your form module; test.

2 Whenever the user attempts to save a new customer record with an existing primary key, display an approprate warning message.

a Run your CUSTSERVER form. Attempt to insert a record with an existing primary key. Note the generated error message.

Form - 40508 error code is generatedb Define an appropriate trigger to trap the generated error message,

and display the database constraint violation message and error code. Ensure that any other generated messages will continue to be displayed.

Page 115: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-31......................................................................................................................................................

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

c Display all messages in an ALERT called ‘errors’.

Define a form level ON-ERROR trigger and include the following code:Declare

nums number;

errmess varchar2(200);

v_constraint_name varchar2(255);

begin

if error_code = 40508 then

errmess := 'Constraint violation ' ||dbms_error_text|| ' ('||dbms_error_code||')';

else

errmess := error_type || to_char( -error_code ) || ': ' || error_text;

end if;

set_alert_property('errors', alert_message_text, errmess);

nums := show_alert('errors');

End;

d Save and compile your form module; test your form.

Page 116: FormsII (Vol2)

A-32 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 14 Solutions1 Automatically ask the users if they want to commit after a set period of

time.

a Open your CUSTOMERS form module.

b At the startup of the form, create a global variable called GLOBAL.LOCKS_PENDING. This will indicate at all times whether rows of the S_CUSTOMER table are locked. The default value is NULL. Append your new code to existing code.

When-New-Form-Instance Trigger at Form Level. . .Default_Value( NULL, ’GLOBAL.locks_pending’);

c Create the On-Lock trigger to implement the default lock processing, update the global variable, and create the timer. You can import the code from the pr14_1.txt file.

On-Lock Trigger at Form 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;

d Display an alert if locks are still pending after a certain period of time elapses. This alert should ask the user to commit or roll back the changes. Define an appropriate trigger. You can import the code from the pr14_2.txt file.

Page 117: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-33......................................................................................................................................................

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

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 ) = ’LOCKS’ then

If :GLOBAL.locks_pending is not NULL then

If SHOW_ALERT( ’ask_save’ ) = ALERT_BUTTON1 then

COMMIT_FORM;

Else

CLEAR_FORM( no_validate );

End If;

If :SYSTEM.FORM_STATUS <> ’CHANGED’ then

DELETE_TIMER(’locks’);

End If;

End If;

End If;

e Create a Post-Database-Commit trigger to restore the NULL value to the global variable. You can import the code from the pr14_3.txt file.

Post-Database-Commit Trigger at Form Level:GLOBAL.locks_pending := NULL;

f Create the On-Rollback trigger to implement the default rollback processing and restore the NULL value to the global variable. You can import the code from the pr14_4.txt file.

On-Rollback Trigger at Form LevelIssue_Rollback( Get_Application_Property( savepoint_name ) );

If Form_Success then

:Global.locks_pending := NULL;

End If;

g Save and compile your form to test.

Page 118: FormsII (Vol2)

A-34 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Practice 15 Solutions1 Create a chart object by using the Chart Wizard. This chart should

display the total orders for each customer.

a Open the ORDCHART form module. Save as ORDCHARTXX where XX is your student course number. This form module contains a S_ORD block. Only one item from this block is visible: TITLE. This item displays a title for your chart.

b In the Layout Editor, use the Chart tool to drag a chart area onto the canvas. Select “Use the Chart Wizard” from the New Chart Object dialog box. Do not specify a title for the chart.

c Select Column as chart type, Plain as chart subtype.

d Specify the S_ORD block as the data block that contains the data you want to assign to chart columns.

e Select CUSTOMER_NAME to appear on the Category (X) axis, and TOTAL to appear on the Value (Y) axis of the chart.

f Click the Finish button.

g Save and compile your form module. Deploy your form to the Web to test. To display the chart, click in the Title item on the Chart tab.

2 Create a report object based on the S_CUSTOMER block. This report displays a customer list using a tabular layout. Display only the ID, NAME, COUNTRY, and REGION_ID fields.

a Open the CUSTREPT form. Save as CUSTREPXX where XX is your student course number.Create a new report object.

Select the Report Object node in the Object Navigator.Click the Create icon.Specify a filename of myreport and a block name.Click OK.

b This will invoke Report Builder. Within the Report Wizard:Choose the report style Tabular.Select the ID, NAME, COUNTRY, and 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.

Page 119: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II A-35......................................................................................................................................................

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

Select Execution Mode and change the value to “RUNTIME”.Select Report Destination Type and change the value to“SCREEN”.

e Create a button named CUST_REP_BUTTON in the control block. Display this button on the 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 and compile your form module. Deploy your form to the Web to test. Query a customer record before calling the report.

Page 120: FormsII (Vol2)

A-36 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Page 121: FormsII (Vol2)

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

Table Descriptionsand Data

B

Page 122: FormsII (Vol2)

B-2 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

.....................................................................................................................................................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 123: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-3......................................................................................................................................................

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

S_CUSTOMER DescriptionColumn Name Null? Datatype-------------- --------- ------------- -----------------

ID NOT NULL NUMBER(7)NAME NOT NULL VARCHAR2(50)PHONE VARCHAR2(25)ADDRESS VARCHAR2(400)CITY VARCHAR2(30)STATE VARCHAR2(20)COUNTRY VARCHAR2(30)ZIP_CODE VARCHAR2(75)CREDIT_RATING VARCHAR2(9)SALES_REP_ID NUMBER(7)REGION_ID NUMBER(7)COMMENTS VARCHAR2(255)

Page 124: FormsII (Vol2)

B-4 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_CUSTOMER Data

SQL> SELECT * FROM s_customer;

Id Name Phone Address

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

City State Country

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

Zip_code Credit_ra Sales_rep_id Region_id

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

Comments

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

201 Unisports 55-2066101 72 Via Bahia

Sao Paolo Brazil

Excellent 12 2

Customer usually orders large amounts and has a high order total. This is okay as long as the credit rating remains excellent.

202 Oj Athletics 81-20101 6741 Takashi Blvd.

Osaka Japan

Poor 14 4

Customer should always pay by cash until his credit rating improves.

203 Delhi Sports 91-10351 11368 Chanakya

New Delhi India

Good 14 4

Customer specializes in baseball equipment and is the largest retailer in India.

Page 125: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-5......................................................................................................................................................

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

S_CUSTOMER Data (continued)

Id Name Phone Address

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

City State Country

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

Zip_code Credit_ra Sales_rep_id Region_id

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

Comments

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

204 Womansport 1-206-104-0103 281 King Street

Seattle Washington USA

98101 EXCELLENT 11 1

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

Hong Kong EXCELLENT 15 4

206 Sportique 33-2257201 172 Rue de Rivoli

Cannes France

EXCELLENT 15 5

Customer specializes in soccer. Likes to order accessories in bright colors.

207 Sweet Rock Sports 234-603620 6 Saint Antoine

Lagos Nigeria

Page 126: FormsII (Vol2)

B-6 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_CUSTOMER Data (continued)

Id Name Phone Address

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

City State Country

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

Zip_code Credit_ra Sales_rep_id Region_id

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

Comments

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

208 Muench Sports 49-527454 435 Gruenestrasse

Stuttgart Germany

GOOD 15 5

Customer usually pays small orders by cash and large orders on credit.

209 Beisbol Si! 809-352689 789 Playa Del Mar

San Pedro de Macon’s Dominican Republic

EXCELLENT 11 1

210 Futbol Sonora 52-404562 3 Via Saguaro Nogales

EXCELLENT 12 2

Customer is difficult to reach by phone. Try mail.

211 Kuhn’s Sports 42-111292 7 Modrany

Prague Czechoslovakia

EXCELLENT 15 5

Page 127: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-7......................................................................................................................................................

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

S_CUSTOMER Data (continued)

Note: This display has been formatted.

Id Name Phone Address

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

City State Country

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

Zip_code Credit_ra Sales_rep_id Region_id

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

Comments

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

212 Hamada Sport 20-1209211 57A CornicheAlexandria Egypt

EXCELLENT 13 3

Customer orders sea and water equipment.

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

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

Buffalo NY USA

14202 POOR 11 1

215 Sporta Russia 7-3892456 6000 Yekatamina

St. Petersburg Russia

POOR 15 5

This customer is very friendly, but has difficulty paying bills. Insist upon cash.

Page 128: FormsII (Vol2)

B-8 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_DEPT Description and DataColumn Name Null? Datatype---------------------- ------------- --------------ID NOT NULL NUMBER(7)NAME NOT NULL VARCHAR2(25)REGION_ID NUMBER(7)

SQL> SELECT * FROM s_dept;

ID NAME REGION_ID

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

10 Finance 1

31 Sales 132 Sales 233 Sales 334 Sales 435 Sales 541 Operations 142 Operations 243 Operations 344 Operations 445 Operations 550 Administration 1

12 rows selected.

Page 129: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-9......................................................................................................................................................

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

S_EMP DescriptionColumn Name Null? Datatype------------------------ -------------- --------------ID NOT NULL NUMBER(7)LAST_NAME NOT NULL VARCHAR2(25)FIRST_NAME VARCHAR2(25)USERID VARCHAR2(8)START_DATE DATECOMMENT VARCHAR2(255)MANAGER_ID NUMBER(7) TITLE VARCHAR2(25)DEPT_ID NUMBER(7)SALARY NUMBER(11,2)COMMISSION_PCT NUMBER(4,2)

Page 130: FormsII (Vol2)

B-10 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_EMP Data

SQL> SELECT * FROM s_emp;

ID LAST_NAME FIRST_NAME USERID START_DAT

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

COMMENTS

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

MANAGER_ID TITLE DEPT_ID SALARY

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

COMMISSION_PCT

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

1 Velasquez Carmen cvelasqu 03-MAR-90

President 50 2500

2 Ngao LaDoris lngao 08-MAR-90

1 VP, Operations 41 1450

3 Nagayama Midori mnagayam 17-JUN-91

1 VP, Sales 31 1400

4 Quick-To-See Mark mquickto 07-APR-90

1 VP, Finance 10 1450

5 Ropeburn Audry aropebur 04-MAR-90

1 VP, Administration 50 1550

6 Urguhart Molly murguhar 18-JAN-91

2 Warehouse Manager 41 1200

7 Menchu Roberta rmenchu 14-MAY-90

2 Warehouse Manager 42 1250

8 Biri Ben bbiri 07-APR-90

2 Warehouse Manager 43 1100

9 Catchpole Antoinette acatchpo 09-FEB-92

2 Warehouse Manager 44 1300

Page 131: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-11......................................................................................................................................................

.....................................................................................................................................................S_EMP Data

S_EMP Data (continued)

ID LAST_NAME FIRST_NAME USERID START_DAT

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

COMMENTS

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

MANAGER_ID TITLE DEPT_ID SALARY

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

COMMISSION_PCT

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

10 Havel Marta mhavel 27-FEB-91

2 Warehouse Manager 45 1307

11 Magee Colin cmagee 14-MAY-90

3 Sales Representative 31 1400

10

12 Giljum Henry hgiljum 18-JAN-92

3 Sales Representative 32 1490

12.5

13 Sedeghi Yasmin ysedeghi 18-FEB-91

3 Sales Representative 33 1515

10

14 Nguyen Mai mnguyen 22-JAN-92

3 Sales Representative 34 1525

15

15 Dumas Andre adumas 09-OCT-91

3 Sales Representative 35 1450

17.5

16 Maduro Elena emaduro 07-FEB-92

6 Stock Clerk 41 1400

Page 132: FormsII (Vol2)

B-12 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_EMP Data (continued)

Note: This display has been formatted.

ID LAST_NAME FIRST_NAME USERID START_DAT

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

COMMENTS

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

MANAGER_ID TITLE DEPT_ID SALARY

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

COMMISSION_PCT

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

17 Smith George gsmith 08-MAR-90

6 Stock Clerk 41 940

18 Nozaki Akira anozaki 09-FEB-91

7 Stock Clerk 42 1200

19 Patel Vikram vpatel 06-AUG-91

7 Stock Clerk 42 795

20 Newman Chad cnewman 21-JUL-91

8 Stock Clerk 43 750

21 Markarian Alexander amarkari 26-MAY-91

8 Stock Clerk 43 850

22 Chang Eddie echang 30-NOV-90

9 Stock Clerk 44 800

23 Patel Radha rpatel 17-OCT-90

9 Stock Clerk 34 795

24 Dancs Bela bdancs 17-MAR-91

10 Stock Clerk 45 860

25 Schwartz Sylvie sschwart 09-MAY-91

10 Stock Clerk 45 1100

Page 133: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-13......................................................................................................................................................

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

S_ITEM DescriptionColumn Name Null? Datatype

------------------------- -------------- ----------ORD_ID NOT NULL NUMBER(7)ITEM_ID NOT NULL NUMBER(7)PRODUCT_ID NOT NULL NUMBER(7)PRICE NUMBER(11,2)QUANTITY NUMBER(9)QUANTITY_SHIPPED NUMBER(9)

Page 134: FormsII (Vol2)

B-14 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_ITEM Data

SQL> SELECT * FROM s_item;

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED

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

100 1 10011 135 500 500100 2 10013 380 400 400100 3 10021 14 500 500100 5 30326 582 600 600100 7 41010 8 250 250100 6 30433 20 450 450100 4 10023 36 400 400101 1 30421 16 15 15101 3 41010 8 20 20101 5 50169 4.29 40 40101 6 50417 80 27 27101 7 50530 45 50 50101 4 41100 45 35 35101 2 40422 50 30 30102 1 20108 28 100 100102 2 202011 23 45 45103 1 30433 20 15 15103 2 32779 7 11 11104 1 20510 9 7 7104 4 30421 16 35 35104 2 20512 8 12 12104 3 30321 1669 19 19105 1 50273 22.8 16 16105 3 50532 47 28 28105 2 50419 80 13 13

Page 135: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-15......................................................................................................................................................

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

S_ITEM Data (continued)

Note: This display has been formatted.

ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED

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

106 1 20108 28 46 46106 4 50273 22.89 75 75106 5 50418 75 98 98106 6 50419 80 27 27106 2 20201 123 21 21106 3 50169 4.29 125 125107 1 20106 11 50 50107 3 20201 115 130 130107 5 30421 16 55 55107 4 30321 1669 75 75107 2 20108 28 22 22108 1 20510 9 9 9108 6 41080 35 50 50108 7 41100 45 42 42108 5 32861 60 57 57108 2 20512 8 18 18108 4 32779 7 60 60108 3 30321 1669 85 85109 1 10011 140 150 150109 5 30426 18.25 500 500109 7 50418 75 43 43109 6 32861 60 50 50109 4 30326 582 1500 1500109 2 10012 175 600 600109 3 10022 21.95 300 300110 1 50273 22.89 17 17110 2 50536 50 23 23111 1 40421 65 27 27111 2 41080 35 29 2997 1 20106 9 1000 100097 2 303211 500 50 5098 1 404218 5 7 799 1 20510 9 18 1899 2 20512 8 25 2599 3 50417 80 53 5399 4 50530 45 69 69

Page 136: FormsII (Vol2)

B-16 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_ORD Description and DataColumn Name Null? Datatype

------------------------ ------ ---------------------ID NOT NULL NUMBER(7)CUSTOMER_ID NOT NULL NUMBER(7)DATE_ORDERED DATEDATE_SHIPPED DATESALES_REP_ID NUMBER(7)TOTAL NUMBER(11,2)PAYMENT_TYPE VARCHAR2(6)ORDER_FILLED VARCHAR2(1)

SQL> SELECT * FROM s_ord;

ID CUSTOMER_ID DATE_ORDE DATE_SHIPSALES_REP_IDTOTAL PAYMEN ORDER_F

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

100 204 31-AUG92 10-SEP-9211 601100 CREDIT Y101 205 31-AUG-92 15-SEP-9214 8056.6 CREDIT Y102 206 01-SEP-92 08-SEP-9215 8335 CREDIT Y103 208 02-SEP-92 22-SEP-9215 377 CASH Y104 208 03-SEP-92 23-SEP-9215 32430 CREDIT Y105 209 04-SEP-92 18-SEP-9211 2722.24 CREDIT Y106 210 07-SEP-92 15-SEP-9212 15634 CREDIT Y107 211 07-SEP-92 21-SEP-9215 142171 CREDIT Y108 212 07-SEP-92 10-SEP-9213 149570 CREDIT Y109 213 08-SEP-92 28-SEP-9211 1020935 CREDIT Y110 214 09-SEP-92 21-SEP-9211 1539.13 CASH Y111 204 09-SEP-92 21-SEP-9211 2770 CASH Y97 201 28-AUG-92 17-SEP-9212 84000 CREDIT Y98 202 31-AUG-92 10-SEP-9214 595 CASH Y99 203 31-AUG-92 18-SEP-9214 7707 CREDIT Y112 210 31-AUG-92 10-SEP-9212 550 CREDIT Y

16 rows selected.

Page 137: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-17......................................................................................................................................................

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

S_PRODUCT DescriptionColumn Name Null? Datatype

---------------------------------- -----------------ID NOT NULL NUMBER(7)NAMENOT NULL VARCHAR2(50)SHORT_DESC VARCHAR2(255)LONGTEXT_ID NUMBER(7)IMAGE_ID NUMBER(7)SUGGESTED_WHLSL_PRICE NUMBER(11,2)WHLSL_UNITS VARCHAR2(25)

Page 138: FormsII (Vol2)

B-18 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_PRODUCT Data

SQL> SELECT * FROM s_product;

ID NAME SHORT_DESC LONGTEXT_ID---- -------------------------- -----------

IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS-------- --------------------------------10011 Boot Beginner’s ski boot 5181001 150

10012 Ace Ski BootIntermediate ski boot5191002 200

10013 Pro Ski BootAdvanced ski boot 5201003 410

10021 Bunny Ski PoleBeginner’s ski pole5281011 16.25

10022 Ace Ski PoleIntermediate ski pole5291012 21.95

10023 Pro Ski PoleAdvanced ski pole 5301013 40.95

20106 Junior Soccer BallJunior soccer ball61311

20108 World Cup Soccer BallWorld cup soccer ball61528

20201 World Cup NetWorld cup net 708123

Page 139: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-19......................................................................................................................................................

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

S_PRODUCT Data (continued)

ID NAME SHORT_DESC LONGTEXT_ID---- ---------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS----------------------------------------20510 Black Hawk Knee pads, pair 1017

Knee Pads 9

20512Black Hawk Elbow pads, pair 1019Elbow Pads 8

30321 Grand Prix Bicycle Road bicycle828 1291 1669

30326 Himalaya BicycleMountain bicycle8331296 582

30421 Grand Prix Road bicycle tires927Bicycle Tires16

30426 Himalaya TiresMountain bicycle tires93318.25

30433New Air PumpTire pump 94020

32779 Slaker Water Water bottle 1286Bottle 7

32861 Safe-T HelmetBicycle helmet 13681829 60

40421 Alexeyer ProStraight bar 928Lifting Bar

1381 65

40422 Pro Curling BarCurling bar 9291382 50

Page 140: FormsII (Vol2)

B-20 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_PRODUCT Data (continued)

ID NAME SHORT_DESC LONGTEXT_ID---- ---------------------------------------IMAGE_ID SUGGESTED_WHLSL_PRICEWHLSL_UNITS-------- --------------------------------40421 Alexeyer ProStraight bar 928

Lifting Bar1381 65

40422 Pro Curling BarCurling bar 9291382 50

41010 Prostar 10 Ten pound weight 517Pound Weight

8

41020 Prostar 20 Twenty pound weight527Pound Weight

12

41050 Prostar 50 Fifty pound weight557Pound Weight

25

41080 Prostar 80 Eighty pound weight587Pound Weight

35

41100 Prostar 100 One hundred pound 607Pound Weightweight

45

50169 Major League Baseball 676Baseball

1119 4.29

Page 141: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-21......................................................................................................................................................

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

S_PRODUCT Data (continued)

Note: This display has been formatted.

ID NAME SHORT_DESC LONGTEXT_ID---- -----------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS---------------------------------------- 50273Chapman HelmetBatting helmet 7801223 22.89

50417 Griffey GloveOutfielder’s glove 9241367 80

50418 Alomar GloveInfielder’s glove 9251368 75

50419 Steinbach GloveCatcher’s glove 9261369 80

50530Cabrera Bat Thirty inch bat 10371480 45

50532 Puckett Bat Thirty-two inch bat 10391482 47

50536 Winfield BatThirty-six inch bat 10431486 50

Page 142: FormsII (Vol2)

B-22 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

S_REGION Description and DataColumn Name Null? Datatype------------------------------ ----------------ID NOT NULL NUMBER(7)NAME NOT NULL VARCHAR2(50)

SQL> SELECT * FROM s_region;

ID NAME--- --------------------------

1 North America2 South America3 Africa / Middle East4 Asia5 Europe

Page 143: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-23......................................................................................................................................................

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

S_TITLE Description and DataColumn Name Null? Datatype---------------------------------- ----------------TITLE NOT NULL VARCHAR2(25)

SQL> SELECT * FROM s_title;

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

8 rows selected.

Page 144: FormsII (Vol2)

B-24 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

Oracle8 i 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 145: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-25......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

Tables

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

1Velasquez Carmencvelasqu

03-MAR-90 President

DEPT_TYPE(50, 'Administration', 1)

2500

2Ngao LaDorislngao

08-MAR-90 1 VP Operations

DEPT_TYPE(41, 'Operations', 1)

1450

3Nagayama Midorimnagayam

17-JUN-91 1 VP Sales

DEPT_TYPE(31, 'Sales', 1)

1400

Page 146: FormsII (Vol2)

B-26 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

DEPT_TYPE(10, 'Finance', 1)

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

DEPT_TYPE(50, 'Administration', 1)

1550

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

DEPT_TYPE(41, 'Operations', 1)

1200

7 Menchu Roberta rmenchu

14-MAY-90 2 Warehouse Manager

DEPT_TYPE(42, 'Operations', 2)

1250

8 Biri Ben bbiri

07-APR-90 2 Warehouse Manager

DEPT_TYPE(43, 'Operations', 3)

1100

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

DEPT_TYPE(44, 'Operations', 4)

1300

Page 147: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-27......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

DEPT_TYPE(45, 'Operations', 5)

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

DEPT_TYPE(31, 'Sales', 1)

1400 10

12 Giljum Henry hgiljum

18-JAN-92 3 Sales Representative

DEPT_TYPE(32, 'Sales', 2)

1490 13

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

DEPT_TYPE(33, 'Sales', 3)

1515 10

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

DEPT_TYPE(34, 'Sales', 4)

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

DEPT_TYPE(35, 'Sales', 5)

145018

Page 148: FormsII (Vol2)

B-28 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

DEPT_TYPE(41, 'Operations', 1)

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

DEPT_TYPE(41, 'Operations', 1)

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

DEPT_TYPE(42, 'Operations', 2)

1200

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

DEPT_TYPE(42, 'Operations', 2)

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

DEPT_TYPE(43, 'Operations', 3)

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

DEPT_TYPE(43, 'Operations', 3)

850

Page 149: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-29......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

DEPT_TYPE(44, 'Operations', 4)

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

DEPT_TYPE(34, 'Sales', 4)

795

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

DEPT_TYPE(45, 'Operations', 5)

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

DEPT_TYPE(45, 'Operations', 5)

1100

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

Page 150: FormsII (Vol2)

B-30 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

DEPT_ID REF OF DEPT_TYPE

SALARY NUMBER(11,2)

COMMISSION_PCTNUMBER(4,2)

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

1 Velasquez Carmen cvelasqu

03-MAR-90 President

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 151: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-31......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

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 152: FormsII (Vol2)

B-32 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

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 153: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-33......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

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 154: FormsII (Vol2)

B-34 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

oo_dept_tableName Null? Type

-------------------- ------------- ----------------ID NUMBER

NAME VARCHAR2(25)

REGION_ID NUMBER(7)

ID NAME REGION_ID

-------------------- ------------- ----------------10 Finance 1

31 Sales 1

32 Sales 2

33 Sales 3

34 Sales 4

35 Sales 5

41 Operations 1

42 Operations 2

43 Operations 3

Page 155: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-35......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

44 Operations 4

45 Operations 5

50 Administration 1

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

1 Velasquez Carmen cvelasqu

03-MAR-90 President

DEPT_TYPE(50, 'Administration', 1)

2500

2 Ngao LaDoris lngao

08-MAR-90 1 VP Operations

DEPT_TYPE(41, 'Operations', 1)

1450

3 Nagayama Midori mnagayam

17-JUN-91 1 VP Sales

DEPT_TYPE(31, 'Sales', 1)

1400

Page 156: FormsII (Vol2)

B-36 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

4 Quick-To-See Mark mquickto

07-APR-90 1 VP Finance

DEPT_TYPE(10, 'Finance', 1)

1450

5 Ropeburn Audry aropebur

04-MAR-90 1 VP Administration

DEPT_TYPE(50, 'Administration', 1)

1550

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

DEPT_TYPE(41, 'Operations', 1)

1200

7 Menchu Roberta rmenchu

14-MAY-90 2 Warehouse Manager

DEPT_TYPE(42, 'Operations', 2)

1250

8 Biri Ben bbiri

07-APR-90 2 Warehouse Manager

DEPT_TYPE(43, 'Operations', 3)

1100

9 Catchpole Antoinette acatchpo

09-FEB-92 2 Warehouse Manager

DEPT_TYPE(44, 'Operations', 4)

1300

Page 157: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-37......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

10 Havel Marta mhavel

27-FEB-91 2 Warehouse Manager

DEPT_TYPE(45, 'Operations', 5)

1307

11 Magee Colin cmagee

14-MAY-90 3 Sales Representative

DEPT_TYPE(31, 'Sales', 1)

1400 10

12 Giljum Henry hgiljum

18-JAN-92 3 Sales Representative

DEPT_TYPE(32, 'Sales', 2)

1490 13

13 Sedeghi Yasmin ysedeghi

18-FEB-91 3 Sales Representative

DEPT_TYPE(33, 'Sales', 3)

1515 10

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

DEPT_TYPE(34, 'Sales', 4)

1525 15

15 Dumas Andre adumas

09-OCT-91 3 Sales Representative

DEPT_TYPE(35, 'Sales', 5)

1450 18

Page 158: FormsII (Vol2)

B-38 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

16 Maduro Elena emaduro

07-FEB-92 6 Stock Clerk

DEPT_TYPE(41, 'Operations', 1)

1400

17 Smith George gsmith

08-MAR-90 6 Stock Clerk

DEPT_TYPE(41, 'Operations', 1)

940

18 Nozaki Akira anozaki

09-FEB-91 7 Stock Clerk

DEPT_TYPE(42, 'Operations', 2)

1200

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

DEPT_TYPE(42, 'Operations', 2)

795

20 Newman Chad cnewman

21-JUL-91 8 Stock Clerk

DEPT_TYPE(43, 'Operations', 3)

750

21 Markarian Alexander amarkari

26-MAY-91 8 Stock Clerk

DEPT_TYPE(43, 'Operations', 3)

850

Page 159: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-39......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

22 Chang Eddie echang

30-NOV-90 9 Stock Clerk

DEPT_TYPE(44, 'Operations', 4)

800

23 Patel Radha rpatel

17-OCT-90 9 Stock Clerk

DEPT_TYPE(34, 'Sales', 4)

795

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

DEPT_TYPE(45, 'Operations', 5)

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

DEPT_TYPE(45, 'Operations', 5)

1100

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

Page 160: FormsII (Vol2)

B-40 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

DEPT_ID REF OF DEPT_TYPE

SALARY NUMBER(11,2)

COMMISSION_PCT NUMBER(4,2)

Page 161: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-41......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

1 Velasquez Carmen cvelasqu

03-MAR-90 President

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 162: FormsII (Vol2)

B-42 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

6 Urguhart Molly murguhar

18-JAN-91 2 Warehouse Manager

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 163: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-43......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

14 Nguyen Mai mnguyen

22-JAN-92 3 Sales Representative

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 164: FormsII (Vol2)

B-44 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

19 Patel Vikram vpatel

06-AUG-91 7 Stock Clerk

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 165: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications I B-45......................................................................................................................................................

.....................................................................................................................................................Oracle8i Objects: Types, Tables

ID LAST_NAME FIRST_NAME USERID

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

START_DAT MANAGER_ID TITLE

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

DEPT_ID(ID, NAME, REGION_ID)

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

SALARY COMMISSION_PCT

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

24 Dancs Bela bdancs

17-MAR-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

860

25 Schwartz Sylvie sschwart

09-MAY-91 10 Stock Clerk

0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408002072C15B

1100

Page 166: FormsII (Vol2)

B-46 Oracle Forms Developer: Build Internet Applications I......................................................................................................................................................

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

Page 167: FormsII (Vol2)

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

Mouse Movement Events

C

Page 168: FormsII (Vol2)

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

.....................................................................................................................................................Appendix C: Mouse Movement Events

Introduction

OverviewYou have already seen how to use mouse action triggers and built-ins. This appendix explains how to develop drag and drop functionality with Client Server forms applications.

ObjectivesAfter completing this appendix, you should be able to implement drag and drop functionality with Client Server forms.

Instructor NoteA library named drag.pll is shipped with the product. Use the following steps as a demonstration:

1 Create a new form module and a new text item manually.

2 Attach the PL/SQL library drag.pll to your form.

3 For this item, create a When-Mouse-Down trigger, a When-Mouse-Move trigger, and a When-Mouse-Up trigger.

In the When-Mouse-Down trigger, include the following statement:

MOUSE.CLICK;

Copyright Oracle Corporation, 2000. All rights reserved.®

Drag and Drop

Items in original positions

Item-A highlighted

Items repositioned

Page 169: FormsII (Vol2)

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

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

You can also include code here to change the cursor to indicate that a drag operation is occurring.

In the When-Mouse-Move trigger, include the following statement:

IF :SYSTEM.MOUSE_BUTTON_PRESSED =’1’ THEN

MOUSE.MOVE;

END IF;

In the When-Mouse-Up trigger, add your application-specific code, which should check where the object has been dropped, and take appropriate action.

Page 170: FormsII (Vol2)

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

.....................................................................................................................................................Appendix C: Mouse Movement Events

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

Implementing Drag and Drop FunctionalityYou can use the mouse button action triggers (When-Mouse-Down and When-Mouse-Up) and the mouse position system variables to implement drag and drop functionality in your form module.

You need to consider the following when implementing drag and drop:

• Changing the appearance of the item you want to drag and drop: Use the SET_ITEM_PROPERTY built-in and a visual attribute.

• Changing the appearance of the cursor during the drag and drop process: Use SET_APPLICATION_PROPERTY(cursor_style, ‘value’).

• Holding the name of the item being dragged and dropped.: Use a global variable to store the initial value of SYSTEM.MOUSE_ITEM.

• Setting the new position, according to the mouse position: Use SET_ITEM_PROPERTY(:global.variablename, position, :SYSTEM.MOUSE_X_POS, :SYSTEM.MOUSE_Y_POS).

• Repositioning other items that may be affected.

Instructor NoteUse dragdrop.fmb to demonstrate an example of drag and drop use. Click an employee number, and drag this employee to a department.

Page 171: FormsII (Vol2)

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

.....................................................................................................................................................Drag and Drop

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

In this appendix, you should have learned how to:

• Drag and Drop Items

Page 172: FormsII (Vol2)

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

.....................................................................................................................................................Appendix C: Mouse Movement Events

SummaryIn this Appendix, you should have learned how to implement drag and drop functionality in your Client Server form applications by using appropriate mouse triggers and system variables.

Mouse Triggers• When_Mouse_Move

• When_Mouse_Up

• When_Mouse_Down

Mouse System Varaiables• :SYSTEM.MOUSE_ITEM

• SYSTEM.MOUSE_X_POS

• :SYSTEM.MOUSE_Y_POS

Page 173: FormsII (Vol2)

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

D

Introduction toOracle8i Object Features

Page 174: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this appendix, you should be ableto do the following:

• Describe the new Oracle8i scalar data types

• Describe object types and objects

• Describe object tables, object columns, andobject views

• Describe the INSTEAD-OF triggers

• Describe object REFs

• Identify the display of objects in Object Navigator

Page 175: FormsII (Vol2)

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

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

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

Page 176: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

New Oracle8i Scalar Data Types

• NCHAR

• NVARCHAR2

• FLOAT

• NLS types

Page 177: FormsII (Vol2)

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

......................................................................................................................................................New Oracle8i Data Types

New Oracle8i Data Types

Scalar Data Types• NCHAR stores fixed-length (blank-padded if necessary) NLS character

data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as US7ASCII or a variable-width encoding such as JA16SJIS.

• NVARCHAR2 stores variable-length NLS character data. How the data is represented internally depends on the national character set, which might use a fixed-width encoding such as WE8EBCDIC37C or a variable-width encoding such as JA16DBCS.

• FLOAT is a subtype of NUMBER. However, you cannot specify a scale for FLOAT variables. You can specify only a binary precision, which is the total number of binary digits.

There is no change to the way scalar data types are displayed in Oracle Forms Developer. The new data types are automatically converted to existing Oracle Forms Developer item data types.

NLS TypesOracle8i offers extended National Language Support (NLS) including national character sets and the data types NCHAR and NVARCHAR2, which store NLS data. With NLS, number and date formats adapt automatically to the language conventions specified for a user session. Thus, users around the world can interact with the Oracle Database Server in their native languages. NLS is discussed in Oracle8i Server Reference Manual.

Page 178: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Types

Attributes

po_nocustinfo

line_itemsamount

Methods

ORDER

Page 179: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 180: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Types

Ship

Cancel

Hold

Checkstatus

ORDER

Page 181: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 182: FormsII (Vol2)

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

......................................................................................................................................................Appendix D: Introduction to Oracle8i 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, 2000. All rights reserved.®

Object Tables

Object table based on object type

Page 183: FormsII (Vol2)

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

......................................................................................................................................................Creating Oracle8i Objects

Creating Oracle8i 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 184: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Columns

Object column based on object type

Page 185: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 186: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Views

Object views based on object types

Object-oriented application

Object view

Relationaltable

Page 187: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 188: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

INSTEAD-OF Triggers

INSTEAD-OF triggerNonupdatable view

DECLARE

BEGIN

EXCEPTION

END;

Page 189: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 190: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

References to Objects

OID

Page 191: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 192: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Types in Object Navigator

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Type Wizard

Page 193: FormsII (Vol2)

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

......................................................................................................................................................Displaying Oracle8i Objects in the Object Navigator

Displaying Oracle8i 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 Forms Developer.

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

Page 194: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Tables in Object Navigator

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Columns in Object Navigator

Page 195: FormsII (Vol2)

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

......................................................................................................................................................Displaying Oracle8i 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 196: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object Views in Object Navigator

Copyright Oracle Corporation, 2000. All rights reserved.®

INSTEAD-OF Trigger Dialog Box

Page 197: FormsII (Vol2)

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

......................................................................................................................................................Displaying Oracle8i 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:

• Oracle8i Server SQL Reference Manual

• Oracle8i Concepts Manual

Page 198: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Object REFs in Object Navigator

Page 199: FormsII (Vol2)

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

......................................................................................................................................................Displaying Oracle8i 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 200: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

In this appendix, you should have learned how to:

• Oracle8i introduced three new scalar datatypes.

• Objects and object types allow representation ofcomplex data.

• Three kinds of objects are object tables,object columns, and object views.

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

In this appendix, you should have learned how to:

• INSTEAD-OF triggers allow DML onobject views.

• Object REFs store the object identifier ofcertain types of objects.

• The Object Navigator can display certaintypes of objects.

Page 201: FormsII (Vol2)

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

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

Summary

New Oracle8i Data TypesOracle8i 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.

Oracle8i Objects In the Object NavigatorThe Object Navigator can display certain types of objects.

Page 202: FormsII (Vol2)

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

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

Page 203: FormsII (Vol2)

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

E

Menu Run-TimeParameters

Page 204: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this appendix, you should be able todo the following:

• Customize menu modules using substitutionparameters

Page 205: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 206: FormsII (Vol2)

E-4 Oracle Forms Developer: Build Internet Applications 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, 2000. 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, 2000. All rights reserved.®

User-Named Substitution Parameters

Design time Run time

Page 207: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 usernamePW 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 208: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Parameter Properties

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

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

Page 209: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 lengthMenu 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 210: FormsII (Vol2)

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

Substitution Parameter Built-ins

• QUERY_PARAMETER

• APPLICATION_PARAMETER

Copyright Oracle Corporation, 2000. All rights reserved.®

Referencing and ApplyingMenu Parameters

• In a menu item command:

– prefix the parameter name with &Example: &param_name

• In a PL/SQL routine:

– Prefix the parameter name with &when entered through a dialog box

– Prefix the parameter name with :when entered in the PL/SQL editor

– Example: :param_name

Page 211: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 212: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Validating SubstitutionParameter Values

MENU_SUCCESS function:

• Returns TRUE if the user does not cancelthe Enter Parameter Values dialog box

• Is used in a WHILE loop

Page 213: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 214: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

In this lesson, you should have learned how to:

• Substitution parameters

Page 215: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 216: FormsII (Vol2)

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

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

Page 217: FormsII (Vol2)

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

F

Handling Server-SideErrors

Page 218: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this appendix, you should beshould be able to do the following:

• Handle server-side database errors

• Obtain the cause of declarative-constraintviolations

Page 219: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 220: FormsII (Vol2)

F-4 Oracle Forms Developer: Build Internet Applications 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, 2000. All rights reserved.®

Obtaining the Cause of Declarative-Constraint Violation

• Predefined error messages fordeclarative constraints:

– Primary/unique key; foreign key; check

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

• Obtaining the name of violated constraint:

– Function STRIP_CONSTRAINT_NAME

Page 221: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 222: FormsII (Vol2)

F-6 Oracle Forms Developer: Build Internet Applications 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, 2000. All rights reserved.®

Customizing Oracle ServerError Messages

• Replacing declarative-constraint error messages:

– Strip the constraint name fromDBMS_ERROR_TEXT or SQLERRM

– Retrieve the customized message fromthe messages table

Copyright Oracle Corporation, 2000. All rights reserved.®

Customizing Oracle ServerError Messages

• Replacing database-trigger error messages:

– Strip the application error messages fromDBMS_ERROR_TEXT or SQLERRM

– Function STRIP_APPLICATION_ERROR

• Replacing stored-program-unit error messages:

– Same as for database triggers, exceptSQLERRM only

Page 223: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 224: FormsII (Vol2)

F-8 Oracle Forms Developer: Build Internet Applications 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, 2000. 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-key constraints.

– Retrieve the message from the messages table.

Copyright Oracle Corporation, 2000. All rights reserved.®

Example Procedure for HandlingOracle Server Errors

• If the Oracle server error is an application error:

– strip the application error from the Oracleserver error text.

– Raise FORM_TRIGGER_FAILURE.

Page 225: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 226: FormsII (Vol2)

F-10 Oracle Forms Developer: Build Internet Applications 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, 2000. All rights reserved.®

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

• Handle errors caused by explicit DML orstored Program Units:

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 227: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 228: FormsII (Vol2)

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

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

In this lesson, you should have learned how to:

• Replacing Oracle Server error messages withcustomized messages

– Constraint: strip constraint name andretrieve message

– DB triggers and stored program units:strip application error

Page 229: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 230: FormsII (Vol2)

F-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Page 231: FormsII (Vol2)

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

G

EMP_PKG Package

Page 232: FormsII (Vol2)

G-2 Oracle Forms Developer: Build Internet Applications 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 233: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 234: FormsII (Vol2)

G-4 Oracle Forms Developer: Build Internet Applications 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 235: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 236: FormsII (Vol2)

G-6 Oracle Forms Developer: Build Internet Applications 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 237: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 238: FormsII (Vol2)

G-8 Oracle Forms Developer: Build Internet Applications 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 239: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 240: FormsII (Vol2)

G-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Appendix G: EMP_PKG Package

Page 241: FormsII (Vol2)

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

H

Working with ActiveXControls

Page 242: FormsII (Vol2)

H-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Objectives

After completing this lesson, you should be able

to do the following:

• Explain the differences between VBX, OCX,and ActiveX controls

• Access ActiveX properties at design time andrun time

• Import ActiveX control methods and eventpackages

• Customize event handling

Page 243: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications II H-3......................................................................................................................................................

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

Introduction

OverviewIn this lesson, you will learn how to include and use ActiveX controls in your Oracle Forms 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 244: FormsII (Vol2)

H-4 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. 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-enabled• ActiveX

– Third version of OCX– Provide integrated controls in Browsers

Page 245: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 246: FormsII (Vol2)

H-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Instructor NoteActiveX controls may be deployed on the Web, but not with Web-deployed Forms. Oracle Forms Developer applications can be enhanced with JavaBeans

Copyright Oracle Corporation, 2000. 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 247: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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. You cannot, however, deploy ActiveX controls with web forms.

The table below summarizes some of the differences among VBX controls, OCX controls, and ActiveX controls.

VBX Controls OCX Controls ActiveX Controls

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 248: FormsII (Vol2)

H-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. 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 249: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 250: FormsII (Vol2)

H-10 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Implementing an ActiveX Control in FormBuilder

1. Create an ActiveX Control Container.

2. Insert an ActiveX Control.

3. Import the desired ActiveX Control methods and events.

4. Write the appropriate PL/SQL code.

Copyright Oracle Corporation, 2000. All rights reserved.®

Creating an ActiveXControl Item

Page 251: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 252: FormsII (Vol2)

H-12 Oracle Forms Developer: Build Internet Applications 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, 2000. 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 Insert Object in the pop-up menu.4. Select a

control type.

Copyright Oracle Corporation, 2000. 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 253: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 254: FormsII (Vol2)

H-14 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Importing ActiveX Methods and EventsPackages

• Select Program OLE Importer1

2

3

4 5

- Program Units + PackageName1 (Spec) + PackageName1 (Body) + . . .

6

Page 255: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 256: FormsII (Vol2)

H-16 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Interacting with an ActiveX Control

You can interact for:

• Setting and getting ActiveX control properties

• Invoking ActiveX control methods

• Responding to ActiveX control events

Copyright Oracle Corporation, 2000. All rights reserved.®

Setting and Getting ActiveX ControlProperties

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 257: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 258: FormsII (Vol2)

H-18 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Setting and Getting ActiveX ControlProperties

• Property accessors (PL/SQL procedures)

tblname varchar2;

tblname := table_pkg.TableName(

:item(’Oblk.Oitm’).interface);

Copyright Oracle Corporation, 2000. All rights reserved.®

Setting and Getting ActiveX ControlProperties

• Control properties dialog box

– Displays ActiveX-specificproperties

– See ControlHelp propertyordocumentation

Page 259: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 260: FormsII (Vol2)

H-20 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Invoking ActiveX Control Methods

MMVX_DMMVX.PLAY(:item

(′video_ocx.video′).INTERFACE);

MMVX_DMMVX.PLAY(:item

(′video_ocx.video′).INTERFACE);

Page 261: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 262: FormsII (Vol2)

H-22 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Responding to ActiveX Control Events

Two ways to deal with events:

• Directly call the appropriate restricted procedure.

• Code the On-Dispatch-Event trigger.

PROCEDURE /*Click*/ event4294966696

(interface OleObj);

BEGIN

/* Write your code here */

END;

Copyright Oracle Corporation, 2000. All rights reserved.®

Responding to ActiveX Control Events

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

FORMS4W.DISPATCH_EVENT

(RESTRICTED_UNALLOWED);

Page 263: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 264: FormsII (Vol2)

H-24 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Technical NoteThe LAST_OLE_EXCEPTION built-in takes variables, not constants.

Copyright Oracle Corporation, 2000. All rights reserved.®

Handling Exceptions

• When a failure occurs,the FORMS_OLE_FAILURE is raised.

• Use LAST_OLE_EXCEPTION built-into get more detailed information.

. . .

WHEN FORMS_OLE_FAILURE THEN

ExceptNum :=LAST_OLE_EXCEPTION(errScr,

errDescription, errHelpfile,

errHelpContext);

. . .

Page 265: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 266: FormsII (Vol2)

H-26 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Copyright Oracle Corporation, 2000. All rights reserved.®

Registering an ActiveX Control

• Two methods to register:

– Implicitly register using the installationprogram.

– Use regsvr32.exe explicitly.

• ActiveX controls require supporting DLL:

– Must be in \Windows\System or search path

• Reregister the ActiveX control if you move itor rename its directory.

Page 267: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 268: FormsII (Vol2)

H-28 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

.

Copyright Oracle Corporation, 2000. All rights reserved.®

Summary

• VBX, OCX, and ActiveX controls

• Differences between controls

• ActiveX control in Form Builder

• Create an ActiveX control container

• Set and get ActiveX control properties

• Invoke ActiveX control methods

• Respond to ActiveX control events

• Register an ActiveX control

Page 269: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 270: FormsII (Vol2)

H-30 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

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

Page 271: FormsII (Vol2)

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

I

Using Oracle Server Rolesat Run Time

Page 272: FormsII (Vol2)

I-2 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 2000. All rights reserved.®

Oracle Server Views for Roles

• SESSION_ROLES

• ROLE_ROLE_PRIVS

• ROLE_SYS_PRIVS

• ROLE_TAB_PRIVS

Page 273: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 274: FormsII (Vol2)

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

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 2000. All rights reserved.®

Oracle Server Views for Roles

• SESSION_ROLES

• ROLE_ROLE_PRIVS

• ROLE_SYS_PRIVS

• ROLE_TAB_PRIVS

Page 275: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 276: FormsII (Vol2)

I-6 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time

Copyright Oracle Corporation, 2000. All rights reserved.®

Procedures for Managing Roles

• DBMS_SESSION.SET_ROLE

• DBMS_SESSION.IS_ROLE_ENABLED

Page 277: FormsII (Vol2)

Oracle Forms Developer: Build Internet Applications 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 278: FormsII (Vol2)

I-8 Oracle Forms Developer: Build Internet Applications II......................................................................................................................................................

......................................................................................................................................................Appendix I: Using Oracle Server Roles at Run Time