Oracle Forms Developer

:
Build Internet Applications I
Volume 2 • Instructor Guide
.......................................................................................

40033GC10
Production 1.0
March 2000
M011344

Author

Copyright  Oracle Corporation, 2000. All rights reserved.

Ellen Gravina

David Ball

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

Soley Celik

Restricted Rights Legend

Kathy Cunningham

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

Technical Contributors
and Reviewers

Ken Goetz
Andrey Ivkin
Kenji Makita
Jayne Marlow
Ian Purvis
Bryan Roberts
Rie Saitoh
Raza Siddiqui
Kajornsak
Sungchareon
Ted Witiuk
Publisher

Nita Brozowski

This material or any portion of it may not be copied in any form or by any means
without the express prior written permission of Oracle Corporation. Any other
copying is a violation of copyright law and may result in civil and/or criminal
penalties.
If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Rights,” as defined in
FAR 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 find
any problems in the documentation, please report them in writing to Education
Products, Oracle Corporation, 500 Oracle Parkway, Box SB-6, Redwood Shores,
CA 94065. Oracle Corporation does not warrant that this document is error-free.
Oracle is a registered trademark and Oracle Forms Developer, Oracle Forms
Server, Oracle Reports Developer, Oracle Reports Server, and PL/SQL are
trademarks or registered trademarks of Oracle Corporation.
All other products or company names are used for identification purposes only
and may be trademarks of their respective owners.

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

Contents
Preface
Profile xvii
Related Publications xviii
Typographic Conventions xix
Introduction
Overview I-3
Course Objectives I-5
Course Content I-7
Lesson 1: Introduction to Oracle Forms Developer and Oracle
Forms Server
Introduction 1-3
Internet Computing Solutions 1-5
What Is Oracle Forms Developer? 1-7
What Is Oracle Forms Server? 1-9
Forms Server Architecture 1-11
Oracle Forms Developer Key Features 1-13
Form Builder Components 1-15
Oracle Toolkit and Oracle Multimedia 1-19
Getting Started in the Oracle Forms Developer Interface 1-21
Navigating Around the Form Builder Main Menu 1-23
Customizing Your Oracle Forms Developer Session 1-25
Saving Tools Preferences 1-27
Oracle Developer Environment Variables 1-29
Environment Variables and Y2K Compliance 1-31
Invoking Online Help Facilities 1-33
Introducing the Course Application 1-35
Summary 1-39
Practice 1 Overview 1-41
Practice 1 1-42

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

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

Lesson 2: Running a Form Builder Application
Introduction 2-3
Application Deployment 2-5
Web Deployment: What You See at Run Time 2-7
Client-Server Environment: What You See at Run Time
Identifying the Data Elements 2-13
Navigating a Form Builder Application 2-15
Modes of Operation 2-19
Retrieving Data 2-23
Performing a Restricted Query 2-25
Using the Query/Where Dialog Box 2-27
Inserting, Updating, and Deleting Records 2-31
Making Inserts, Updates, and Deletes Permanent 2-33
Displaying Errors 2-35
Summary 2-37
Practice 2 Overview 2-39
Practice 2 2-40

2-9

Lesson 3: Working in the Form Builder Environment
Introduction 3-3
What Is Form Builder? 3-5
Form Builder Executables 3-7
Form Builder Module Types 3-9
Form Builder Components 3-11
Summary 3-23
Lesson 4: Creating a Basic Form Module
Introduction 4-3
Creating a New Form Module 4-5
Creating a New Data Block 4-11
Modifying the Layout 4-23
Template Forms 4-25
Saving, Compiling, and Running a Form Module
Practice 4-1 Overview 4-35

4-27

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

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

Creating Data Blocks with Relationships 4-37
Creating a Relation Manually 4-43
Modifying a Relation 4-45
Running a Master-Detail Form Module 4-49
Summary 4-51
Practice 4-2 Overview 4-53
Practice 4-1 4-54
Practice 4-2 4-55
Lesson 5: Working with Data Blocks and Frames
Introduction 5-3
Managing Object Properties 5-5
Controlling the Behavior of Data Blocks 5-15
Controlling the Appearance of Data Blocks 5-21
Controlling Frame Properties 5-25
More About Object Properties 5-27
Creating Control Blocks 5-33
Deleting Data Blocks 5-35
Summary 5-37
Practice 5 Overview 5-39
Practice 5 5-40
Lesson 6: Working with Text Items
Introduction 6-3
What Is a Text Item? 6-5
Creating a Text Item 6-7
Modifying the Appearance of a Text Item 6-9
Associating Text with an Item Prompt 6-15
Controlling the Data of a Text Item 6-17
Altering the Navigational Behavior of a Text Item 6-23
Enhancing the Relationship Between Text Item and Database 6-25
Adding Functionality to a Text Item 6-27
Including Helpful Messages 6-33

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

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

Summary 6-35
Practice 6 Overview 6-37
Practice 6 6-38
Lesson 7: Creating LOVs and Editors
Introduction 7-3
What Are LOVs and Editors? 7-5
Defining an LOV 7-9
Creating an LOV by Using the LOV Wizard
Defining an Editor 7-21
Summary 7-25
Practice 7 Overview 7-27
Practice 7 7-28

7-11

Lesson 8: Creating Additional Input Items
Introduction 8-3
What Are Input Items? 8-5
Creating a Check Box 8-7
Creating a List Item 8-15
Creating a Radio Group 8-23
Summary 8-31
Practice 8 Overview 8-33
Practice 8 8-34
Lesson 9: Creating Noninput Items
Introduction 9-3
What Are Noninput Items? 9-5
Creating a Display Item 9-7
Creating an Image Item 9-11
Creating a Sound Item 9-19
Creating a Push Button 9-25
Creating a Calculated Item 9-31
Creating a Hierarchical Tree Item 9-39

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

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

Summary 9-41
Practice 9 Overview 9-43
Practice 9 9-44
Lesson 10: Creating Windows and Content Canvases
Introduction 10-3
Windows and Content Canvases 10-5
Displaying a Form Module in Multiple Windows 10-9
Displaying a Form Module on Multiple Layouts 10-15
Summary 10-19
Practice 10 Overview 10-21
Practice 10 10-22
Lesson 11: Working with Other Canvases
Introduction 11-3
Canvases Overview 11-5
Creating a Stacked Canvas 11-7
Creating a Toolbar 11-13
Creating a Tab Canvas 11-17
Summary 11-25
Practice 11 Overview 11-27
Practice 11 11-28
Lesson 12: Introduction to Triggers
Introduction 12-3
What Is a Trigger? 12-5
Trigger Components 12-7
Summary 12-15
Lesson 13: Producing Triggers
Introduction 13-3
Defining Triggers in Form Builder 13-5
PL/SQL Editor Features 13-9
Database Trigger Editor 13-11
Writing the Trigger Code 13-13

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

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

Adding Functionality Using Built-in Subprograms
Using Triggers 13-27
Practice 13 Overview 13-32
Practice 13 13-33

13-19

Lesson 14: Debugging Triggers
Introduction 14-3
Debugging Triggers 14-5
Summary 14-27
Practice 14 Overview 14-29
Practice 14 14-30
Lesson 15: Adding Functionality to Items
Introduction 15-3
Item Interaction Triggers 15-5
Defining Functionality for Input Items 15-9
Defining Functionality for Noninput Items 15-13
Summary 15-27
Practice 15 Overview 15-29
Practice 15 15-30
Lesson 16: Runform Messages and Alerts
Introduction 16-3
Run-time Messages and Alerts Overview 16-5
Built-ins and Handling Errors 16-7
Errors and Built-ins 16-9
Controlling System Messages 16-11
The FORM_TRIGGER_FAILURE Exception 16-15
Triggers for Intercepting System Messages 16-17
Creating and Controlling Alerts 16-21
Summary 16-31
Practice 16 Overview 16-33
Practice 16 16-34

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

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

Lesson 17: Query Triggers
Introduction 17-3
Query Triggers 17-5
SELECT Statements Issued During Query Processing
WHERE and ORDER BY Clauses 17-9
Writing Query Triggers 17-11
Query Array Processing 17-15
Coding Triggers for Enter Query Mode 17-17
Overriding Default Query Processing 17-21
Obtaining Query Information at Run Time 17-25
Summary 17-29
Practice 17 Overview 17-31
Practice 17 17-32

17-7

Lesson 18: Validation
Introduction 18-3
Validation Process 18-5
Using Object Properties to Control Validation 18-7
Controlling Validation by Using Triggers 18-11
Validating User Input 18-13
Tracking Validation Status 18-15
Built-ins for Validation 18-17
Summary 18-19
Practice 18 Overview 18-21
Practice 18 18-22
Lesson 19: Navigation
Introduction 19-3
About Navigation 19-5
Controlling Navigation 19-7
Understanding Internal Navigation 19-11
Navigation Triggers 19-13
Using the When-New-“object”-Instance Triggers
Using the Pre- and Post-Triggers 19-17

19-15

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

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

The Navigation Trap 19-19
Navigation in Triggers 19-21
Summary 19-23
Practice 19 Overview 19-25
Practice 19 19-26
Lesson 20: Transaction Processing
Introduction 20-3
Transaction Processing 20-5
The Commit Sequence of Events 20-9
Characteristics of Commit Triggers 20-11
Common Uses for Commit Triggers 20-13
DML Statements Issued During Commit Processing 20-25
Overriding Default Transaction Processing 20-27
Running Against Data Sources Other than Oracle 20-31
Getting and Setting the Commit Status 20-33
Array Processing 20-39
Summary 20-43
Practice 20 Overview 20-45
Practice 20 20-46
Lesson 21: Writing Flexible Code
Introduction 21-3
What Is Flexible Code? 21-5
Using System Variables for Flexible Coding 21-7
Using Built-in Subprograms for Flexible Coding 21-11
Referencing Objects by Internal ID 21-15
Referencing Items Indirectly 21-23
Summary 21-27
Practice 21 Overview 21-29
Practice 21 21-30

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

........................................................................ Oracle Forms Developer: Build Internet Applications I xi ... Lesson 22: Sharing Objects and Code Introduction 22-3 Reusable Objects and Code Overview 22-5 Property Class 22-7 Creating a Property Class 22-9 Inheriting a Property Class 22-11 Creating an Object Group 22-13 Copying and Subclassing Objects and Code 22-17 What Is an Object Library? 22-23 Working with Object Libraries 22-25 What Is a SmartClass? 22-27 Reusing PL/SQL 22-29 PL/SQL Libraries 22-31 Working with PL/SQL Libraries 22-33 Summary 22-37 Practice 22 Overview 22-39 Practice 22 22-40 Lesson 23: Introducing Multiple Form Applications Introduction 23-3 Multiple Form Applications 23-5 How to Start Another Form Module 23-7 Defining Multiple Form Functionality 23-9 Summary 23-21 Practice 23 Overview 23-23 Practice 23 23-24 Appendix A: Practice Solutions Practice 1 Solutions A-2 Practice 2 Solutions A-5 Practice 4-1 Solutions A-8 Practice 4-2 Solutions A-10 Practice 5 Solutions A-13 Practice 6 Solutions A-16 ........................................................................................................................Contents ........................................................................................................

.................................... xii Oracle Forms Developer: Build Internet Applications I .................................................................................................................................................................................................................................................................Contents . Practice 7 Solutions Practice 8 Solutions Practice 9 Solutions Practice 10 Solutions Practice 11 Solutions Practice 13 Solutions Practice 14 Solutions Practice 15 Solutions Practice 16 Solutions Practice 17 Solutions Practice 18 Solutions Practice 19 Solutions Practice 20 Solutions Practice 21 Solutions Practice 22 Solutions Practice 23 Solutions A-22 A-25 A-27 A-32 A-33 A-41 A-43 A-44 A-46 A-48 A-50 A-52 A-54 A-58 A-60 A-63 Appendix B: Table Descriptions and Data Summit Sporting Goods Database Diagram B-2 S_CUSTOMER Description B-3 S_CUSTOMER Data B-4 S_DEPT Description and Data B-8 S_EMP Description B-9 S_EMP Data B-10 S_IMAGE Description and Data B-13 S_INVENTORY Description and Data B-14 S_ITEM Description B-21 S_ITEM Data B-22 S_ORD Description and Data B-24 S_PRODUCT Description B-25 S_PRODUCT Data B-26 .....

........................................................................................ S_REGION Description and Data B-30 S_TITLE Description and Data B-31 Oracle8 Objects: Types............................................... Oracle Forms Developer: Build Internet Applications I xiii ......Contents ........................................................................................... Tables B-32 Appendix C: Oracle Rdb Overview What Is Oracle Rdb? C-2 Other Information C-4 Appendix D: Locking in Form Builder Locking D-5 Default Locking in Forms D-7 Locking in Triggers D-13 Summary D-19 Appendix E: Oracle8 Object Features Overview E-3 Oracle8 Datatypes E-5 Creating Oracle8 Objects E-11 Referencing Objects E-19 Displaying Oracle8 Objects in the Object Navigator E-21 Summary E-29 Appendix F: Using the Layout Editor Overview F-3 Why Use the Layout Editor? F-5 How to Access the Layout Editor F-7 Components of the Layout Editor F-9 Creating and Modifying Objects in the Layout Formatting Objects in the Layout F-19 Coloring Objects and Text F-21 Importing Images and Drawings F-25 Summary F-27 F-11 ....................................................................

................................................................................................................................................................................................................................................ Appendix G: Introduction to Query Builder What Is Query Builder? G-3 The Query Builder Window G-7 Building a New Query G-9 Datasource Components G-11 Refining a Query G-13 Viewing and Saving Queries G-17 Including Additional Tables G-19 Relationships G-23 Selecting Rows with Conditions G-29 Operators G-31 Entering Multiple Conditions G-33 Changing Conditions G-35 Defining Columns Using an Expression G-37 Defining Columns Using a Function G-39 ..........Contents .............................. xiv Oracle Forms Developer: Build Internet Applications I ...................

...15 ........... Adding Functionality to Items ...................

......................................... 2000............................. you should be able to do the following: • Supplement the functionality of input items by using triggers and built-ins • Supplement the functionality of noninput items by using triggers and built-ins Copyright  Oracle Corporation.................... All rights reserved......................... Objectives After completing this lesson......................................................................................... 15-2 Oracle Forms Developer: Build Internet Applications I ............................Lesson 15: Adding Functionality to Items .......................................... Schedule Topic Lecture Practice Total Timing 40 minutes 40 minutes 80 minutes ...............................

...................................................................................................................................... .............................................................. Introduction Overview In this lesson.........Introduction .................. you will learn how to use triggers to provide additional functionality to GUI items in form applications........... Oracle Forms Developer: Build Internet Applications I 15-3 .....................................................................

...................... The When-Image-Activated trigger fires when the user double-clicks the image..................................... Instructor Note The When-Image-Pressed trigger fires when the user clicks the image........ In this case........................ the mouse-event triggers fire after the item interaction trigger................ Item Interaction Triggers When-Button-Pressed When-Checkbox-Changed When-Radio-Changed When-Image-Pressed When-Image-Activated When-List-Changed When-List-Activated When-Tree-Node-Activated When-Tree-Node-Expanded When-Tree-Node-Selected Copyright  Oracle Corporation...Lesson 15: Adding Functionality to Items ... when the mouse is used by the user...................... When-Mouse-Click and When-Mouse-Doubleclick.......................................... The mouse-event triggers..... may also exist within the scope of the objects discussed here.......................................... .................. 2000......... 15-4 Oracle Forms Developer: Build Internet Applications I .......................... All rights reserved...................................

................. For example................. in a radio group User single-clicks image item User double-clicks image item User changes value of a list item User double-clicks element in a T-list User double-clicks a node or presses [Enter] when a node is selected User expands or collapses a node User selects or deselects a node . Item Interaction Triggers There are several types of GUI items that the user can interact with by using the mouse or by pressing a function key.............. the user can change the value of the radio group item... by selecting a radio button.... Most of these items have default functionality............................................................................................................. They can be defined at any scope............................................... For example: • Performing tests and appropriate actions as soon as the user clicks a radio button.............. by single-click or function key User selects different button.............. Trigger When-Button-Pressed When-Checkbox-Changed When-Radio-Changed When-Image-Pressed When-Image-Activated When-List-Changed When-List-Activated When-Tree-Node-Activated When-Tree-Node-Expanded When-Tree-Node-Selected Firing Event User single-clicks with mouse or uses function key to select User changes check box state............ Oracle Forms Developer: Build Internet Applications I 15-5 .. as previously described............... or a check box • Conveniently displaying an image when the user clicks an image item • Defining the functionality of a push-button (which has none until you define it) The following triggers fire due to user interaction with an item................ a list........ or deselects current button......... You will often want to add triggers to provide customized functionality when these events occur..........Item Interaction Triggers ...

...... because this customer has a poor credit rating................................................ 2000...............Lesson 15: Adding Functionality to Items . Instructor Note • Use the orders............. Use Customer ID 214........ Explain the actions in the trigger code..........fmb file to show the When-Radio-Changed trigger on Payment_Type of the S_ORD block.................. Coding Item Interaction Triggers • Valid commands: – SELECT statements – Standard PL/SQL constructs – All built-in subprograms • Use When-Validate-“object” to trap the operator during validation............................................. Run the customer................................................ 15-6 Oracle Forms Developer: Build Internet Applications I ........... Copyright  Oracle Corporation......... .... All rights reserved......................fmb file to show the functionality of the trigger...................................................... • We will discuss using SELECT statements in triggers in the lesson on query triggers.

....................payment_type = ’CREDIT’ THEN SELECT credit_rating INTO v_credit_rating FROM S_CUSTOMER WHERE id = :S_ORD. DECLARE v_credit_rating S_CUSTOMER.................’EXCELLENT’) THEN :S_ORD.................................... Command Types in Item Interaction Triggers You can use standard SQL and PL/SQL statements in these triggers.... ..... Example of When-Radio-Changed When-Radio-Changed trigger on :S_ORD................ However........... IF v_credit_rating NOT IN(’GOOD’...... this trigger immediately confirms whether the customer has a good or excellent credit rating......... END............................. When the user selects credit as the payment type for an order........customer_id.... END IF............................. BEGIN IF :S_ORD............payment_type := ’CASH’...... The item interaction triggers do not fire on navigation or validation events.... which provide a wide variety of mechanisms.. MESSAGE(’Warning-customer must pay cash’)... END IF.......................Item Interaction Triggers ........ then the payment type is set to cash.... you will often want to add functionality to items by calling built-in subprograms..... the trigger terminates and sends the Unhandled Exception message to the operator............credit_rating%TYPE................................. If not...Payment_Type... Note: During an unhandled exception.... like the example above..... Oracle Forms Developer: Build Internet Applications I 15-7 .....

...... ............ ELSE SET_ITEM_PROPERTY(’S_ORD........ UPDATE_ALLOWED............................ PROPERTY_TRUE)... UPDATE_ALLOWED.......................... 2000.Lesson 15: Adding Functionality to Items ........ Copyright  Oracle Corporation................... Interacting with Check Boxes When-Checkbox-Changed IF CHECKBOX_CHECKED(’S_ORD..................................................................... PROPERTY_FALSE).........................order_filled’) THEN SET_ITEM_PROPERTY(’S_ORD. END IF...........................date_shipped’..........................................................date_shipped’................. 15-8 Oracle Forms Developer: Build Internet Applications I ..... All rights reserved.

.... UPDATE_ALLOWED...Defining Functionality for Input Items .................................................... the associated value for the state is set............................date_shipped’................................ ELSE SET_ITEM_PROPERTY(’S_ORD......................................... UPDATE_ALLOWED.............. Note that the CHECKBOX_CHECKED function enables you to test the state of a check box without needing to know the associated values for the item........... we now look at adding functionality to other items that accept user input... Oracle Forms Developer: Build Internet Applications I 15-9 ... You may want to perform trigger actions based on this change..... PROPERTY_TRUE ).Order_Filled item prevents the Date_Shipped item from being updated if the user marks the order as filled (checked on).............. Check Boxes When the user selects or clears a check box....order_filled’) THEN SET_ITEM_PROPERTY(’S_ORD......................... Example This When-Checkbox-Changed trigger on the :S_ORD.......................date_shipped’.......PROPERTY_FALSE ).......... If the check box is set to off.. .... then the Date_Shipped item is enabled.... Defining Functionality for Input Items You have already seen an example of adding functionality to radio groups.... END IF.......................... IF CHECKBOX_CHECKED(’S_ORD.

......... Instructor Note Using POPULATE_LIST and lists with record groups is covered in the course Oracle Forms Developer: Build Internet Applications II................................................ 2000................................................................................... 15-10 Oracle Forms Developer: Build Internet Applications I ............................................................................ All rights reserved......................Lesson 15: Adding Functionality to Items ..................... ...................................... Changing List Items at Run Time Excellent ADD_LIST_ELEMENT DELETE_LIST_ELEMENT Excellent Good Poor Index 1 2 3 Copyright  Oracle Corporation........

................................... For Tlists............ • Add or remove individual list elements through the ADD_ LIST_ELEMENT and DELETE_LIST_ELEMENT built-ins............’label’................................................................................... Oracle Forms Developer: Build Internet Applications I 15-11 ........................’value’) DELETE_LIST_ELEMENT(’list_item_name’................. ....... List Items You can use the When-List-Changed trigger to trap user selection of a list value.index) Parameter Description Index A number identifying the element position in the list (top=1) Label The name of the element Value The new value for this element Note: You can eliminate the Null list element of a list by setting the required property to Yes......index.......... you can also change the selectable elements in a list as follows: • Periodically update the list from a two-column record group...Defining Functionality for Input Items ....................... you can trap double-clicks with When-List-Activated.................. With Form Builder... ADD_LIST_ELEMENT(’list_item_name’.................. respectively.........................................

......................... 2000...... set the Keyboard Navigable and Mouse Navigate properties of the button to No............. .......... All rights reserved........ Instructor Note Use LIST_VALUES with one button for each item that has a LOV...................................... Use SHOW_LOV with a single button for the whole form......Lesson 15: Adding Functionality to Items ..... Displaying LOVs from Buttons • Uses: – Convenient alternative for accessing LOVs – Can display independently of text items • Needs: – When-Button-Pressed trigger – LIST_VALUES or SHOW_LOV built-in Copyright  Oracle Corporation....................................................................................................................................................................... 15-12 Oracle Forms Developer: Build Internet Applications I ........................ In both cases......

....... LIST_VALUES Procedure This built-in procedure invokes the LOV that is attached to the current text item in the form............................ then the user can invoke the LOV from the text item by selecting Edit—>Display List or pressing the List Values key......... y ) SHOW_LOV( lov_id..... and what the x and y coordinates are where its window should appear: SHOW_LOV( ’lov_name’................ there are arguments that let you define which LOV is to be displayed. Note: The lov_id is a PL/SQL variable where the internal ID of the object is stored........................... x. However....... invokes the LOV of the current item... ............ Oracle Forms Developer: Build Internet Applications I 15-13 ....................................... which may be set to RESTRICT..... It has an optional argument...... These are LIST_VALUES and SHOW_LOV. meaning that the current value of the text item is used as the initial search string on the LOV.. it is always useful if a button is available to display a LOV......... • It displays a LOV independently of a text item (using SHOW_LOV)............................Defining Functionality for Noninput Items . SHOW_LOV Function This built-in function......... There are two built-ins that you can call to invoke a LOV from a trigger... y ) Notice that either the LOV name (in quotes) or the LOV ID (without quotes) can be supplied in the first argument.. The default for this argument is NO_RESTRICT................ without arguments.... x...... The button has two advantages: • It is convenient alternative for accessing the LOV............................ Internal IDs are a more efficient way of identifying an object............................ However............... Defining Functionality for Noninput Items Displaying LOVs from Buttons If you have attached a LOV to a text item........

.... Name Daryl Jayne Christian Claudia Sergei Lisa Pam ID 101 102 103 104 105 106 107 Copyright  Oracle Corporation................. 15-14 Oracle Forms Developer: Build Internet Applications I ...................................... All rights reserved.......................................... LOVs and Buttons 105 LOV button Employee_Id Employees (LOV) When-Button-Pressed IF IF SHOW_LOV(’myLov’) SHOW_LOV(’myLov’) THEN....................................... ................................Lesson 15: Adding Functionality to Items .......... 2000..................... THEN...........................................................................................................

... You can use the SHOW_LOV function to display a LOV that is not even attached to a text item............................... the LOV redisplays until they do so... providing that you identify the LOV in the first argument of the function...... the cursor needs to reside in the text item that is attached to the LOV............ When called from a button.............. • FALSE indicates that the user dismissed the LOV without choosing a record.... until the function returns TRUE.... LOOP EXIT WHEN SHOW_LOV( ’customer_lov’ )..... ..........Defining Functionality for Noninput Items . this invokes the LOV to be independent of cursor location.................................... or that the LOV returned 0 records from its Record Group..... When using LIST_VALUES...... END LOOP......... MESSAGE(’You must select a value from list’)................” and arrange it on the canvas where the user intuitively associates it with the items that the LOV supports (even though the button has no direct connection with text items)....................... With SHOW_LOV.. this also maintains the cursor to in its original location after the LOV is closed................ Create the LOV button with a suitable label... • Switch off the button’s Mouse Navigate property of the button............ Using the SHOW_LOV Function The SHOW_LOV function returns a Boolean value: • TRUE indicates that the user selected a record from the LOV................ Because SHOW_LOV returns TRUE when the user selects a record.......... Example This When-Button-Pressed trigger on the Customer_Lov_Button invokes an LOV in a PL/SQL loop.... Oracle Forms Developer: Build Internet Applications I 15-15 .... Note • You can use the FORM_SUCCESS function to differentiate between the two causes of SHOW_LOV returning FALSE........... such as “Pick...................................... This is usually adjacent to the main text item that the LOV returns a value to....... wherever that may be...............

..................... ... All rights reserved................................................................................................. 2000...................................................................................... Populating Image Items ^ Fetch on query v Database WRITE_IMAGE_FILE READ_IMAGE_FILE Image file in the file system Copyright  Oracle Corporation. 15-16 Oracle Forms Developer: Build Internet Applications I ................................Lesson 15: Adding Functionality to Items ................................................................

. you must explicitly identify the item_name parameter........................... You might decide to populate an image item from a button trigger................... .......... however......’filetype’...) Note • The filetype parameter is optional in READ_IMAGE_FILE.. need to be populated by other means.. using WhenButton-Pressed. but there are two triggers that fire when the user interacts with an image item directly: • When-Image-Pressed (fires for a single click on image item) • When-Image-Activated (fires for a double-click on image item) READ_IMAGE_FILE Procedure This built-in procedure lets you load an image file..... READ_IMAGE_FILE(’filename’...................... WRITE_IMAGE_FILE............ You can use GET_FILE_NAME built-in to display the standard open file dialog box where the user can select an existing file or specify a new file. from an image file in the file system: READ_IMAGE_FILE built-in procedure..... Parameter Description filename The image file name (Without a specified path......................... • The reverse procedure............... the default path is assumed................ Refer to the online Help system for file types...... Oracle Forms Developer: Build Internet Applications I 15-17 ................. but it is recommended to set a specific file type for better performance... Nonbase table image items...................... into an image item. is also available.................. Image Items Image items that have the Database Item property set to Yes automatically populate in response to a query in the owning block (from a LONG RAW or BLOB column in the base table)....... If you omit filetype..........) item_name The name of the image item (a variable holding the Item_id is also valid for this argument) (This parameter is optional.............................’item_name’)................... For example........) filetype The file type of the image (You can use ANY as a value....... in a variety of formats........Defining Functionality for Noninput Items .

................................ ’BMP’....BMP’........................... 15-18 Oracle Forms Developer: Build Internet Applications I ........ ’S_ITEM........product_id)||’...................... All rights reserved..................... 2000.................. Copyright  Oracle Corporation.............Lesson 15: Adding Functionality to Items .................................................................................... Loading the Right Image READ_IMAGE_FILE( ’F_’||TO_CHAR(:S_ITEM.......................product_image’ )........................ ..........................

.......... This example assumes that the related filenames have the format: F_<product id>....... product_id... then its contents will be committed to the database LONG RAW or BLOB column when you save changes in the form........................................ ’BMP’.........................product_id)||’..product_image’ )..................... You can use this technique to populate a table with images................ Refer to the online Help for more information..Defining Functionality for Noninput Items ........... Note: If you load an image into a base table image item by using READ_IMAGE_FILE....BMP’........ such as pasting an image from the clipboard into an empty image item..................... .............. Notice that as the first argument to this built-in is datatype CHAR....................... the concatenated NUMBER item................ Oracle Forms Developer: Build Internet Applications I 15-19 ..... must first be converted by using the TO_CHAR function........................ Example of Image Items The following When-Image-Pressed trigger on the Product_Image item displays a picture of the current product (in the ITEM block) when the user clicks the image item........................................’S_ITEM..... Other options are available for populating an image item.......BMP READ_IMAGE_FILE(’F_’||TO_CHAR(:S_ITEM...............

........ Interacting with Sound Items GET_ITEM_PROPERTY and SET_ITEM_PROPERTY: • • • • • • • SHOW_FAST_FORWARD_BUTTON SHOW_PLAY_BUTTON SHOW_RECORD_BUTTON SHOW_REWIND_BUTTON SHOW_SLIDER SHOW_TIME_INDICATOR SHOW_VOLUME_CONTROL Copyright  Oracle Corporation........................................................................................ 15-20 Oracle Forms Developer: Build Internet Applications I ........................................ 2000....Lesson 15: Adding Functionality to Items .................. ............................................................................................... All rights reserved...................................................

................ You can hide or display or get information about each component of a sound item control programmatically by using SET_ITEM_PROPERTY and GET_ITEM_PROPERTY built-ins (however................................................................. you must always have either the Play or Record button displayed for a sound item)... Interacting with Sound Items When you create a sound item...................... You can use the following properties with these two built-ins: • SHOW_FAST_FORWARD_BUTTON • SHOW_PLAY_BUTTON • SHOW_RECORD_BUTTON • SHOW_REWIND_BUTTON • SHOW_SLIDER • SHOW_TIME_INDICATOR • SHOW_VOLUME_CONTROL Use the PROPERTY_TRUE or PROPERTY_FALSE parameters with the SET_ITEM_PROPERTY built-in................. The GET_ITEM_PROPERTY built-in returns TRUE or FALSE as data type VARCHAR2............................ Form Builder automatically represents the item in the layout with the sound item control......................................Defining Functionality for Noninput Items ........................... ...................................................................................... Oracle Forms Developer: Build Internet Applications I 15-21 .....

.fmb file contains a more complete example.............. Populating Hierarchy Trees CREATE_GROUP_FROM_QUERY Database Record Group When-New-Form-Instance - Car SET_TREE_PROPERTY Ford Volvo VW Toyota Copyright  Oracle Corporation....... The example used in the following slides is contained in the HTreeDemo............................ .................. using the data stored in the tree nodes to display details about a specific employee......................... Developers can also use a query to populate a hierarchical tree......Lesson 15: Adding Functionality to Items ............................................................................................................... All rights reserved.......................... 15-22 Oracle Forms Developer: Build Internet Applications I ................... Instructor Note This example uses a record group to populate the tree........................ The HTreeDemo2................ 2000.......fmb file.........

..... The data type of the name is VARCHAR2.... modify. Parameter Description item_name Specifies the name of the object created at design time.. Oracle Forms Developer: Build Internet Applications I 15-23 ... similar to the Object Navigator used in Oracle Forms Developer........................ Note: All built-ins are located in the FTREE built-in package..... property Specifies one of the following properties: RECORD_GROUP: Replaces the data set of the hierarchical tree with a record group and causes it to display QUERY_TEXT: Replaces the data set of the hierarchical tree with an SQL query and causes it to display ALLOW_EMPTY_BRANCHES: Possible values are PROPERTY_TRUE and PROPERTY_FALSE value Specifies the value appropriate to the property you are setting: PROPERTY_TRUE: The property is set to the TRUE state..................... remove................ Populating Hierarchical Trees The hierarchical tree displays data in the form of a standard navigator.... or evaluate elements in a hierarchical tree.... Ftree.................................Defining Functionality for Noninput Items ............... ......................... You can also use the property palette to populate the hierarchical tree.................. SET_TREE_PROPERTY Procedure This built-in procedure can be used to change certain properties for the indicated hierarchical tree item It can also be used to populate the indicated hierarchical tree item from a record group...Set_Tree_Property(item_name.................................... You can populate a hierarchical tree with values contained in a Record Group or Query Text................................ At run time.................. you can programmatically add....................property.......... PROPERTY_FALSE: The property is set to the FALSE state. Ftree.............. value).......

....... to_char(id) ‘ || ‘from s_emp ‘ || ‘connect by prior id= manager_id ‘|| ‘start with title = ‘‘President’’’)................record_group.... last_name........................... Displaying Hierarchy Trees WHEN-NEW-FORM-INSTANCE rg_emps := create_group_from_query(‘rg_emps’ create_group_from_query(‘rg_emps’......tree5’.................... 15-24 Oracle Forms Developer: Build Internet Applications I .............................set_tree_property(‘block4...................................... rg_emps)......................... All rights reserved.... Technical Note The columns in a record group or query used to populate a hierarchical tree are: • Initial state • Node tree depth • Label for the node • Icon for the node • Data Instructor Note Hierarchical tree items are covered in the course Oracle Forms Developer: Build Internet Applications II.............. ........................... 2000.......... NULL.. ftree... level. v_ignore := populate_group(rg_emps).....Lesson 15: Adding Functionality to Items ............... set_tree_property ftree....................................................... ‘select 1.. Copyright  Oracle Corporation........

to_char(empno) ’ || ' from emp ' || 'connect by prior empno = mgr ' || ’start with job = ’’PRESIDENT’’’).................................... ename..... NUMBER............. RECORDGROUP....... BEGIN htree := Find_Item('tree_block. DECLARE htree v_ignore rg_emps ITEM............. NULL..................... ’select 1............. a record group is created and the hierarchical tree is populated............ END.....................................htree3')...........................RECORD_GROUP... Then....... rg_emps := Create_Group_From_Query('rg_emps'.... Oracle Forms Developer: Build Internet Applications I 15-25 .Set_Tree_Property(htree............ rg_emps)..... The example locates the hierarchical tree first................. SET_TREE_PROPERTY Procedure (continued) You can add data to a tree view by: • Populating a tree with values contained in a record group or query by using the POPULATE_TREE built-in • Adding data to a tree under a specific node by using the ADD_TREE_DATA built-in • Modifying elements in a tree at run time by using built-in subprograms • Adding or deleting nodes and the data elements under the nodes Example This code could be used in a WHEN-NEW-FORM-INSTANCE trigger to initially populate the hierarchical tree with data......................................Defining Functionality for Noninput Items .. Ftree......... level.. Ftree....................... ........... v_ignore := Populate_Group(rg_emps)....

...... hierarchical tree.....Lesson 15: Adding Functionality to Items ...................... 15-26 Oracle Forms Developer: Build Internet Applications I .................. list item control...... LOV control.................................. • You use built-ins for check boxes........... and sound item control.. All rights reserved............................................................. ..................... Summary • Item interaction triggers accept SELECT statements and other standard PL/SQL constructs.................................................... 2000.............................. image file reading..................................... Copyright  Oracle Corporation......

................. sound item control..................................................................................Summary ................. image file reading.............. ....... Summary In this lesson........................ Oracle Forms Developer: Build Internet Applications I 15-27 .............. list item control... and so on............. you learned to use triggers to provide functionality to the GUI items in form applications....................................... hierarchical tree................... • The item interaction triggers accept SELECT statements and other standard PL/SQL constructs.......................................................... • There are built-ins for LOV control...

...................................................................................... Practice 15 Overview This practice covers the following topics: • Writing a trigger to check whether the customer’s credit rating forces him to pay cash • Creating a toolbar button to display and hide product images Copyright  Oracle Corporation................. All rights reserved................................................................................” ..... see Practice 15 in Appendix A...Lesson 15: Adding Functionality to Items ............... 15-28 Oracle Forms Developer: Build Internet Applications I ................................. Note For solutions to this practice...................... 2000................................ “Practice Solutions..............

.........................................................................Practice 15 Overview .......................................... ................. You also create some additional functionality for a radio group......... • Writing a trigger to check whether the customer’s credit rating forces him to pay cash • Creating a toolbar button to display and hide product images Instructor Note Be sure the students understand that the code they will import for practice #3 will only toggle the image item...................... you add some triggers that enable interaction with buttons.................................... Oracle Forms Developer: Build Internet Applications I 15-29 ........... Practice 15 Overview In this practice.............................................................................................. The code to display an image in the image item will be implemented in a later practice..

......... 15-30 Oracle Forms Developer: Build Internet Applications I ..... However.VISIBLE)=’TRUE’ THEN SET_ITEM_PROPERTY(’S_ITEM... ELSE SET_ITEM_PROPERTY(’S_ITEM....... PROPERTY_TRUE)..... ........ The file contains code that determines the current value of the visible property of the Product Image item...image_description’........image_button’.................. PROPERTY_FALSE)............ if the visible property is currently False........Lesson 15: Adding Functionality to Items ......... Deploy the form on the Web.. 3 Import the file pr15_3... 2 In the CONTROL block.. VISIBLE. PROPERTY_TRUE).. PROPERTY_FALSE).......................’Image On’).....txt file.....LABEL............... When-Button-Pressed on CONTROL.......................... Set Label property to Image Off.. create a new button called Image_Button and position it on the Toolbar.............. allowing only those customers with a good or excellent credit rating to pay for orders on credit.........txt into a trigger that fires when the Image_Button is clicked....Image_Button IF GET_ITEM_PROPERTY(’S_ITEM.......... Practice 15 1 In the ORDGXX form write a trigger that fires when the payment type changes....... SET_ITEM_PROPERTY(’S_ITEM............. VISIBLE...... ’Image Off’). 4 Save and compile the form. the visible property toggles to True for both the Product Image item and the Image Description item........... Finally the label changes on the Image_Button to reflect its next toggle state...............LABEL.... SET_ITEM_PROPERTY(’CONTROL....... VISIBLE. SET_ITEM_PROPERTY(’CONTROL.product_image’. If the current value is True........ VISIBLE......... the visible property toggles to False for both the Product Image item and the Image Description item. END IF..product_image’....... You can import the pr15_1....... SET_ITEM_PROPERTY(’S_ITEM....................image_description’.image_button’..product_image’...

.................... Runform Messages and Alerts .........16 ....

.................. 16-2 Oracle Forms Developer: Build Internet Applications I ............. Objectives After completing this lesson................................................................. 2000....... All rights reserved.................... you should be able to do the following: • • • Describe the default messaging • • Control system messages Handle errors using built-in subprograms Identify the different types of Form Builder messages Create and control alerts Copyright  Oracle Corporation...............Lesson 16: Runform Messages and Alerts ....................................................................................................... Schedule Topic Lecture Practice Total Timing 60 minutes 20 minutes 80 minutes ................................................................

..... and how to build customized alerts for communicating with users.... Oracle Forms Developer: Build Internet Applications I 16-3 ........... You will also learn how to handle errors by using built-in subprograms.......................................... and if desired..... Introduction Overview This lesson shows you how to intercept system messages.......................................................................Introduction .......................................................................... replace them with ones that are more suitable for your application........... ...................................................................................

.................................................................................................................... ........................................... 16-4 Oracle Forms Developer: Build Internet Applications I .....................................................................Lesson 16: Runform Messages and Alerts .............................. All rights reserved................................. 2000........... Communicating with the Operator Alerts System Application Messages Informative Error Working Application Copyright  Oracle Corporation..

.. and issue to the operator for a response by using the SHOW_ALERT built-in.... The default display is on the message line..................................... This is displayed as a modal window.................. You can also build messages and alerts into your application: • Application message: These are messages that you build into your application by using the MESSAGE built-in... The default display is on the message line....................................... • System alert: Alerts give information to the operator that require either an acknowledgment or an answer to a question before processing can continue.... depending on the nature of the application..................... the current message also displays as an alert..........)......... Form Builder can communicate with the user in the following ways: • Informative message: A message tells the user the current state of processing.. • Error message: This informs the user of an error that prevents the current action................... When more than one message is waiting to show on the message line........... As the designer........... or gives context-sensitive information.................................... You can suppress message line errors with an On-Error trigger...... Oracle Forms Developer: Build Internet Applications I 16-5 ... you may want to either suppress or modify some of these messages.. The default display is on the message line...................... ..... You can suppress its appearance with an On-Message trigger.......... Run-time Messages and Alerts Overview Form Builder displays messages at run time to inform the operator of events that occur in the session....... • Application alert: These are alerts that you design as part of your application.. This type of message can be suppressed by setting the system variable SUPPRESS_WORKING to True......Run-time Messages and Alerts Overview ................. • Working message: This tells the operator that the form is currently processing (for example: Working........ This is shown on the message line............

. 2000......................................................................................................................................... Detecting Run Time Errors • FORM_SUCCESS – TRUE: Action successful – FALSE: Error/Fatal error occurred • FORM_FAILURE – TRUE: A nonfatal error occurred – FALSE: No error/No fatal error • FORM_FATAL – TRUE: A fatal error occurred – FALSE: No error/No nonfatal error Copyright  Oracle Corporation.... All rights reserved............................... ........................Lesson 16: Runform Messages and Alerts ..................................... 16-6 Oracle Forms Developer: Build Internet Applications I ......................................................................

.............. then the EXECUTE_QUERY procedure still executes... this When-Button-Pressed trigger navigates to the S_INVENTORY block.. EXECUTE_QUERY........... The failing action may occur in a trigger that fired as a result of a built-in from the first trigger.. When clicked.............. which may itself fail.... This means that subsequent code continues after a built-in fails.... and attempts a query in the wrong block. or a nonfatal error Note: These built-in functions return success or failure of the latest action in the form.....Built-ins and Handling Errors ..................... the EXECUTE_QUERY procedure.... Oracle Forms Developer: Build Internet Applications I 16-7 ... or because it is nonenterable... Built-in Functions for Detecting Success and Failure The Form Builder supplies some functions that indicate whether the latest action in the form was successful: Built-in Function FORM_SUCCESS FORM_FAILURE FORM_FATAL Description of Returned Value TRUE: Action successful FALSE: Error or fatal error occurred TRUE: A nonfatal error occurred FALSE: Either no error............... and performs a query there.. GO_BLOCK(’S_INVENTORY’). can cause a Pre-Query trigger to fire................ Built-ins and Handling Errors When a built-in subprogram fails.................................................. unless you take action to detect a failure..................... For example... If the GO_BLOCK built-in procedure fails because the S_INVENTORY block does not exist................................ or a fatal error TRUE: A fatal error occurred FALSE: Either no error.......... it does not directly cause an exception in the calling trigger or program unit........................................................ Example A button in the CONTROL block called Stock_Button is situated on the Toolbar canvas of the ORDERS form.................... ......

............. All rights reserved.. ..... Test built-in success with FORM_SUCCESS function.... MESSAGE _TEXT......... ERROR_TYPE – MESSAGE _CODE...........................Lesson 16: Runform Messages and Alerts ......................................... ............ ................................... Errors and Built-ins • • Built-in failure does not cause an exception............................ 16-8 Oracle Forms Developer: Build Internet Applications I .. • What went wrong? – ERROR_CODE...................... MESSAGE _TYPE Copyright  Oracle Corporation.......................................... ERROR_TEXT.. IF FORM_SUCCESS THEN ................................................................. 2000....

................. GO_BLOCK(’S_INVENTORY’)........ ............ ELSE MESSAGE(’An error occurred while navigating to Stock’)................ Errors and Built-ins It is usually most practical to use FORM_SUCCESS.................. IF FORM_SUCCESS THEN EXECUTE_QUERY.. which is written for you as part of Relation management.... ORA=Oracle error (datatype CHAR) We will look at these built-ins again when we discuss controlling messages.............. the FORM_SUCCESS function is used in a condition to decide if the query should be performed..... Three more built-in functions provide this information: Built-in Function ERROR_CODE ERROR_TEXT ERROR_TYPE Description of Returned Value Error number (datatype NUMBER) Error description (datatype CHAR) FRM=Form Builder error.. This procedure may be called to fail a trigger if the last action was unsuccessful......................................... when you build master-detail blocks.................... you may need to identify it to take a specific action........ Note: Look at the program unit CHECK_PACKAGE_FAILURE.. You can then code the trigger to take appropriate action........................... This time.......... Triggers fail only if there is an unhandled exception or you raise the FORM_TRIGGER_FAILURE exception to fail the trigger in a controlled manner........................................ depending on the success of the GO_BLOCK action.................... because this returns FALSE if either a fatal or a nonfatal error occurs. Built-in Functions to Determine the Error When you detect an error.................. Example of FORM_SUCCESS Here is the same trigger again................Errors and Built-ins ..... END IF.. Oracle Forms Developer: Build Internet Applications I 16-9 .............

..................................... 2000..... 16-10 Oracle Forms Developer: Build Internet Applications I ................................................................................................................................................................ Message Severity Levels 0 All (default) 5 10 15 20 More critical 25 >25 Define by: :SYSTEM.............................Lesson 16: Runform Messages and Alerts .....MESSAGE_LEVEL Copyright  Oracle Corporation........................................ All rights reserved..................... ........

..................... You do this by assigning a value to the system variable MESSAGE_LEVEL. There are six levels that you can affect............ Severity Level 0 5 10 15 20 25 >25 Description All messages Reaffirms an obvious condition User has made a procedural mistake User attempting action for which the form is not designed Cannot continue intended action due to a trigger problem or some other outstanding condition A condition that could result in the form performing incorrectly Messages that the designer cannot suppress In a trigger................. the higher the numbers.................... based on their severity level................ The default value for MESSAGE_LEVEL (at form startup) is 0................................................ you can specify that only messages above a specified severity level are to be issued by the form......... the more critical the message............................................ Oracle Forms Developer: Build Internet Applications I 16-11 ................Controlling System Messages ............................... .. Controlling System Messages Suppressing Messages According to Their Severity You can prevent system messages from being issued. Form Builder then only issues messages that are above the severity level defined in this variable...................................... This means that messages of all severities are displayed..................... Form Builder classifies every message with a severity level that indicates how critical or trivial the information is................

. 16-12 Oracle Forms Developer: Build Internet Applications I .....MESSAGE_LEVEL := ’0’.... UP............................. Suppressing Messages :SYSTEM.... Copyright  Oracle Corporation............................. ’TRUE’........................................ :SYSTEM........................ All rights reserved.MESSAGE_LEVEL := ’5’........... :SYSTEM..........................................................................................SUPPRESS_WORKING := := ’TRUE’................. .........SUPPRESS_WORKING :SYSTEM..... IF NOT FORM_SUCCESS THEN MESSAGE(’Already at the first Order’).Lesson 16: Runform Messages and Alerts ................... END IF......... 2000.................

. However the trigger suppresses this. if required.......MESSAGE_LEVEL := ’0’.......... by performing the assignments in a When-New-Form-Instance trigger............................Controlling System Messages ...... while querying you receive: Working...................... Example of Suppressing Messages The following When-Button-Pressed trigger moves up one record........ :SYSTEM........ and outputs its own application message instead......... Suppressing Working Messages Working messages are displayed when the Form Builder is busy processing an action..... For example....................... message.... You can suppress this message by setting the system variable SUPPRESS_WORKING to True..... If the cursor is already on the first record..................... The trigger resets the message level to normal (0) afterwards.. Oracle Forms Developer: Build Internet Applications I 16-13 ................... IF NOT FORM_SUCCESS THEN MESSAGE(’Already at the first Order’)............................... UP............. :SYSTEM.................... This is a severity level 5 message. the built-in fails and the following message usually displays: FRM-40100: At first record..... :SYSTEM...MESSAGE_LEVEL := ’5’......... Note: You can set these system variables as soon as the form starts up............. .....SUPPRESS_WORKING := ’TRUE’.................. using the built-in procedure UP.................... END IF...........

.......................... Fail trigger Copyright  Oracle Corporation................................ --END.... All rights reserved... --EXCEPTION EXCEPTION --WHEN WHEN <exception> <exception> THEN THEN RAISE RAISE form_trigger_failure............................... form_trigger_failure......................................................... .. 2000.............................. FORM_TRIGGER_FAILURE BEGIN BEGIN --RAISE RAISE form_trigger_failure........................................ Instructor Note The broken line in the diagram represents possible route into the EXCEPTION section if the designer has coded an exception handler for FORM_TRIGGER_FAILURE or OTHERS....... form_trigger_failure..............Lesson 16: Runform Messages and Alerts ............... 16-14 Oracle Forms Developer: Build Internet Applications I .................................................

........customer_name................ Oracle Forms Developer: Build Internet Applications I 16-15 .... to skip remaining actions and fail the trigger • In an exception handler..... RAISE form_trigger_failure................customer_id.............................................. raising an exception to fail the trigger when the message is sent............... You can raise this exception: • In the executable part of a trigger.. This means that you can fail the trigger in a controlled manner.. phone INTO :S_ORD.. beyond the visible trigger text that you write... EXCEPTION WHEN no_data_found THEN MESSAGE(’Customer with this ID not found’).......................customer_phone FROM S_CUSTOMER WHERE id = :S_ORD..... Form Builder has its own exception handler for FORM_TRIGGER_ FAILURE................................ .............................................................The FORM_TRIGGER_FAILURE Exception ... to fail the trigger after your own exception handling actions have been obeyed In either case... which fails the trigger but does not cause an unhandled exception..... and therefore trapping the user in the Customer_ID item: SELECT name.................... :S_ORD.................... Example This example adds an action to the trigger exception handler................... The FORM_TRIGGER_FAILURE Exception Triggers fail only when one of the following occurs: • During an Unhandled Exception • When you request Form Builder to fail the trigger by raising the built-in exception FORM_TRIGGER_FAILURE This exception is defined and handled by Form Builder.........

. All rights reserved.....................................................................Lesson 16: Runform Messages and Alerts ....................... .......................................................... Instructor Note Remind students that On triggers fire in place of the usual processing........ 16-16 Oracle Forms Developer: Build Internet Applications I ............... and to customize error messages • On-Message: – Fires when an informative system message is issued – Is used to suppress or customize specific messages Copyright  Oracle Corporation........................................ 2000................ Error Triggers • On-Error: – Fires when a system error message is issued – Is used to trap Form Builder and Oracle Server errors............................................................................

........ Remember that you can use the built-in functions ERROR_CODE................ if you define one or both of these triggers at form level............ END IF......Triggers for Intercepting System Messages ................... However........... This trigger can perform corrective actions based on the error that occurred.............. RAISE FORM_TRIGGER_FAILURE...................... On-Error Trigger Use this trigger to: • Detect Form Builder and Oracle Server errors................. For example........................ Oracle Forms Developer: Build Internet Applications I 16-17 ............... but reconstructs the standard system message for all other errors... ............. an On-Error trigger at item level only intercepts error messages that occur while control is in that item.................... ERROR_ TEXT...... Example of an On-Error Trigger This On-Error trigger sends a customized message for error 40202 (field must be entered)............... and ERROR_TYPE to identify the details of the error...................... ELSE MESSAGE(ERROR_TYPE || ’-’ || TO_CHAR(ERROR_CODE) || ’: ’ || ERROR_TEXT)................... so that no message is seen by the operator unless you issue one from the trigger itself... You can define these triggers at any level........... IF ERROR_CODE = 40202 THEN MESSAGE(’You must fill in this field for an Order’)............ all messages that cause them to fire will be intercepted regardless of which object in the current form causes the error or message.... Triggers for Intercepting System Messages By writing triggers that fire on message events you can intercept system messages before they are displayed on the screen..... and possibly use this information in your own message............. • Replace the default error message with a customized message for this application....... These triggers are: • On-Error: Fires on display of a system error message • On-Message: Fires on display of an informative system message These triggers replace the display of a message......

. 2000........................................................ 16-18 Oracle Forms Developer: Build Internet Applications I ............................................................ ............................. All rights reserved.............................................................. Handling Informative Messages • • On-Message trigger Built-in functions: – MESSAGE_CODE – MESSAGE_TEXT – MESSAGE_TYPE Copyright  Oracle Corporation.........................................................................Lesson 16: Runform Messages and Alerts .......................

............................................................ If your applications must be supported in more than one national language......... Oracle Forms Developer: Build Internet Applications I 16-19 ................. because this trigger fires due to informative messages..................... you will use different built-ins to determine the nature of the current message...........Triggers for Intercepting System Messages ........... as appropriate............... END IF. On-Message Trigger Use this trigger to suppress informative messages.................................................. ELSE MESSAGE(MESSAGE_TYPE || ’-’ || TO_CHAR(MESSAGE_CODE) || ’: ’|| MESSAGE_TEXT)....................................... replacing them with customized application messages............... IF MESSAGE_CODE = 40350 THEN MESSAGE(’No Orders found-check your search values’)............................. then use MESSAGE_CODE in preference to MESSAGE_TEXT when checking a message..... However. Example of an On-Message Trigger This On-Message trigger modifies the “Query caused no records to be retrieved” message (40350)................ You can handle messages in On-Message in a similar way to On-Error............. . Built-in Function MESSAGE_CODE MESSAGE_TEXT MESSAGE_TYPE Description of Returned Value Number of informative message that would have displayed (datatype NUMBER) Text of informative message that would have displayed (datatype CHAR) FRM=Form Builder message ORA= Oracle server message NULL=No message issued yet in this session (datatype CHAR) Note: These functions return information about the most recent message that was issued.

...... caution......................................................................................................................... You may want to define more than one button so that you can show the testing of user response.......... 16-20 Oracle Forms Developer: Build Internet Applications I ................................... note) 4 Button1 label 5 Button2 label 6 Button3 label Instructor Note Create an alert that you can display in your application during a later demonstration...................... 1 Title 2 Message 3 Alert style (stop............ 2000. Alert Example This is a generic example of an alert.. Alert Properties 1 2 3 4 5 6 Copyright  Oracle Corporation.......................... showing all three icons and buttons that can be defined.......... All rights reserved............... as in the Delete Record example that follows................................. ...........Lesson 16: Runform Messages and Alerts .......

.................... Caution................ • Activate the alert at run time by using built-ins........ or Note Labels for each of the three possible buttons (Null indicates that the button is not required..... and then select Create.........) Button 1... No..................... Property Name Title Alert Style Button1.. alerts are created from the Object Navigator.. Button3 Default Alert Button Message Description Name for this object Alert title Defines the symbol that accompanies message: Stop................. Button 2............. or Cancel).... • Ask the operator a question where up to three answers are appropriate (typically Yes............. Here are the properties that are specific to an alert...... and define its properties in the Property palette........................ and take action based on the operator’s returned response... Oracle Forms Developer: Build Internet Applications I 16-21 .. and must acknowledge..... How to Create an Alert Like other objects you create at design-time... Button2................ Because they display in a modal window......... Creating and Controlling Alerts Alerts are an alternative method for communicating with the operator.......... This is an abridged list..... 2 Define the properties of the alert in the Property Palette........ Alerts are therefore managed in two stages: • Create the alert at design-time........... You handle the display and responses to an alert by using built-in subprograms.............Creating and Controlling Alerts .......................................... 1 Select the Alerts node in the Navigator.......... Use alerts when you need to do the following: • Display a message that the operator cannot ignore... or Button 3 Message that will appear in the alert (maximum 200 characters) .................... alerts provide an effective way of drawing attention and forcing the operator to answer the message before processing can continue.....

................................ ...............................................Lesson 16: Runform Messages and Alerts ................................ Planning Alerts Yes/No questions Yes/No/Cancel questions Caution messages Informative messages Copyright  Oracle Corporation................... All rights reserved......................................................... 16-22 Oracle Forms Developer: Build Internet Applications I .................................................. Instructor Note When a form is deployed to the Web and the LookAndFeel parameter is set to Oracle........................................................ 2000.. the icons for the stop and note style alerts are different than they are in client-server...........

.

............................................................................... 2000......... 16-24 Oracle Forms Developer: Build Internet Applications I ................. All rights reserved... .................................................................. Controlling Alerts SET_ALERT_PROPERTY SET_ALERT_BUTTON_PROPERTY Copyright  Oracle Corporation...............................................................................................................................Lesson 16: Runform Messages and Alerts ...

’message’) Parameter Description Alert_name The name of the alert............ ’value’) Parameter Description Alert_name The name of the alert....................... ALERT_BUTTON3 constants....... as defined in the Designer (You can alternatively specify an alert_id (unquoted) for this argument.Creating and Controlling Alerts ................................................. and to display the alert.... which returns the operator’s response to the calling trigger....................property................................) SET_ALERT_BUTTON_PROPERTY Procedure Use this built-in to change the label on one of the alert buttons: SET_ALERT_BUTTON_PROPERTY(’alert_name’... SET_ALERT_PROPERTY Procedure Use this built-in to change the message that is currently assigned to an alert.. to change alert button labels................ ALERT_BUTTON2............) Property The property being set....................................... property.... the default message (as defined in the Property palette) is initially assigned: SET_ALERT_PROPERTY(’alert_name’... as defined in the Designer (You can alternatively specify an alert_id (unquoted) for this argument.) Property The property being set (Use ALERT_MESSAGE_TEXT when defining a new message for the alert.......) Message The character string that defines the message (You can give a character expression instead of a simple quoted string... if required.......... use LABEL Value The character string that defines the label ........... Oracle Forms Developer: Build Internet Applications I 16-25 ................................ Controlling Alerts at Run Time There are built-in subprograms to change an alert message............. button.........) Button The number that specifies the alert button (Use ALERT_BUTTON1... At form startup.......

................... 3 Show the underlying code in this form....... Demonstration Run the Show_Alert.....Lesson 16: Runform Messages and Alerts ................................... 1 Set title............. ............................... All rights reserved...... 2000.................... SHOW_ALERT(’del_Check’)=ALERT_BUTTON1 SHOW_ALERT(’del_Check’)=ALERT_BUTTON1 THEN THEN ........... SHOW_ALERT Function •IF •IF ................fmb file that demonstrates creating a generic alert.... 2 Click the Show the Alert button................... and button labels to any value you want... The button number that you clicked appears in the text item............................................... Alert_Button1 Alert_Button2 Alert_Button3 Copyright  Oracle Corporation.. Instructor Note Write a trigger that displays your earlier alert............ message... ............... 16-26 Oracle Forms Developer: Build Internet Applications I ...................................................

...... then the DELETE_RECORD built-in is called to delete the current record from the block......................... END IF.............. Example A trigger that fires when the user attempts to delete a record might invoke the alert.................................................. ....................... IF SHOW_ALERT(’del_check’) = ALERT_BUTTON1 THEN DELETE_RECORD........ You can alternatively specify an Alert_Id (unquoted) for this argument..... These numbers correspond to the values of three PL/SQL constants.... .................. .. and return the operator’s response to the calling trigger: selected_button := SHOW_ALERT(’alert_name’).. ALERT_BUTTON1 ALERT_BUTTON2 ALERT_BUTTON3 The Operator selected is...................... .........Creating and Controlling Alerts ......... that indicates which of the three possible buttons the user pressed in response to the alert......... which are predefined by the Form Builder: If the number equals..... If the operator selects Yes......... shown opposite...... SHOW_ALERT Function SHOW_ALERT is how you display an alert at run time................. Alert_Name is the name of the alert.... to obtain confirmation........ as defined in the builder... Button 1 Button 2 Button 3 After displaying an alert that has more than one button............. Oracle Forms Developer: Build Internet Applications I 16-27 .. SHOW_ALERT returns a NUMBER constant........................ you can determine which button the operator pressed by comparing the returned value against the corresponding constants..............................

............... Directing Errors to an Alert PROCEDURE Alert_On_Failure IS n NUMBER............. ..................... BEGIN SET_ALERT_PROPERTY(’error_alert’................................................. ALERT_MESSAGE_TEXT.. 16-28 Oracle Forms Developer: Build Internet Applications I ................................................................................ 2000....................ERROR_TYPE|| ’-’||TO_CHAR(ERROR_CODE)|| ’: ’||ERROR_TEXT).. n := SHOW_ALERT(’error_alert’)........................................ END...... All rights reserved..Lesson 16: Runform Messages and Alerts ................ Copyright  Oracle Corporation............................................

.................. can be used in the SET_ALERT_PROPERTY procedure...................... The built-in functions that return error information............................. Oracle Forms Developer: Build Internet Applications I 16-29 .......... ERROR_TYPE||’-’||TO_CHAR(ERROR_CODE)||’: ’ || ERROR_TEXT)................... Example The following user-named procedure can be called when the last form action was unsuccessful.................. PROCEDURE alert_on_failure IS n NUMBER........................... The procedure fails the calling trigger and displays Error_Alert containing the error information........... through an On-Error trigger..... ..... such as ERROR_TEXT............................ ALERT_MESSAGE_TEXT............................................................ to construct the alert message for display............. END.....Creating and Controlling Alerts ......... n := SHOW_ALERT(’error_alert’)............. BEGIN SET_ALERT_PROPERTY( ’error_alert’............ Directing Errors to an Alert You may want to display errors automatically in an alert...........

.................. Summary • On-Error trigger intercepts system error messages....... Summary • Application and system messages appear on message line.... Change alert message with SET_ALERT_PROPERTY.. Up to three buttons are available for operator response..... 2000. All rights reserved........................................................ Copyright  Oracle Corporation....... Copyright  Oracle Corporation.......................... • On-Message trigger intercepts system informative messages................ All rights reserved.................. 16-30 Oracle Forms Developer: Build Internet Applications I ............................................. • • Alert types: Stop..............Lesson 16: Runform Messages and Alerts ........... Caution...... ......... 2000.................................. and Note • • Display alerts with SHOW_ALERT.............. • Set system variables to suppress system messages: MESSAGE_LEVEL and SUPPRESS_WORKING.............. • Test for built-in failure by using FORM_SUCCESS or other built-in functions..........

.... • Set system variables to suppress system messages: .. Oracle Forms Developer: Build Internet Applications I 16-31 ........ • Alert types: Stop.................................Assign a value of True to SUPPRESS_WORKING to suppress all working messages.... you saw how to intercept system messages. Caution............ .. • Change alert messages with SET_ALERT_PROPERTY........................... • On-Error trigger intercepts system error messages............................................................... • Display alerts at run time with SHOW_ALERT...... • On-Message trigger intercepts informative system messages............. • Test for failure of built-ins by using the FORM_SUCCESS built-in function or other built-in functions.. and Note...........Assign a value to MESSAGE_LEVEL to specify that only messages above a specific severity level are to be used by the form.... You also learned how to build customized alerts for communicating with operators.................................. ...............Summary ....... • The application and system messages appear on the Message line..)................................. and how to replace them with ones that are more suitable for your application... Summary In this lesson...................... • Up to three buttons are available for operator response (NULL indicates that the button is not required............

..................................... Practice 16 Overview This practice covers the following topics: • Using an alert to inform the operator that the customer must pay cash • Using a generic alert to ask the operator to confirm that the form should terminate Copyright  Oracle Corporation....................................................................................................... see Practice 16 in Appendix A....... “Practice Solutions............Lesson 16: Runform Messages and Alerts .......” .... 16-32 Oracle Forms Developer: Build Internet Applications I .................................. Note For solutions to this practice......................................... All rights reserved.......................... 2000....................................

...............................................................................Practice 16 Overview .. Practice 16 Overview In this practice........................................... These include a general alert for questions and a specific alert that is customized for payment type...................... Oracle Forms Developer: Build Internet Applications I 16-33 .................................................................................................................................. you create some alerts in the ORDGXX form........... • Using an alert to inform the operator that the customer must pay cash • Using a generic alert to ask the operator to confirm that the form should terminate .................

............... Practice 16 1 Create an alert in ORDGXX called Payment_Type_Alert with a single 2 3 4 5 OK button.......................... and call the EXIT_FORM built-in if the operator replied Yes.............................Exit_Button that uses Question_Alert to ask the operator to confirm that the form should terminate............... Create a generic alert called Question_Alert that allows Yes and No replies......... ..... Select the Stop style.................. Deploy the form on the Web to test.............. and define two buttons in the alert: Yes and No...................Lesson 16: Runform Messages and Alerts ....... Style: Caution.......................................... 16-34 Oracle Forms Developer: Build Internet Applications I ....... Alter the When-Button-Pressed trigger on CONTROL.... The message should read “This customer must pay cash!” Suggested Title: Payment Type.................................................. Leave the Message property blank for this alert.......... Save and compile the form....... Call the SET_ALERT_PROPERTY built-in to define the message: “Do you really want to leave the form?” Test the returned value of SHOW_ALERT............................... Alter the When-Radio-Changed trigger on Payment_Type to show the Payment_Type_Alert instead of the message when a customer must pay cash.......

...................17 ............ Query Triggers ..

............................................................ All rights reserved................................................................ Schedule Topic Lecture Practice Total Timing 60 minutes 30 minutes 90 minutes ....... 17-2 Oracle Forms Developer: Build Internet Applications I ........ you should be able to do the following: • Explain the processes involved in querying a data block • • Describe query triggers and their scope • Control trigger action based on the form query status Write triggers to supplement query results and screen query conditions Copyright  Oracle Corporation..Lesson 17: Query Triggers .................................................... 2000........................................................................................... Objectives After completing this lesson.....................

..... You can customize the query process as necessary............................................................................................................................ and supplement the results returned by a query.............................................. Introduction Overview In this lesson........................ ...Introduction ...................... Oracle Forms Developer: Build Internet Applications I 17-3 ............................................................... you learn how to control events associated with queries on base table data blocks..................

............. Abort query on failure Perform Perform query query Fetch a row into a new record Mark Mark record record as as valid valid Flush record on failure Fire Fire Post-Query Post-Query trigger trigger Validate Validate any any record record changes changes Copyright  Oracle Corporation................................................ 2000............................................................................ ...................Lesson 17: Query Triggers ...................................................................... All rights reserved............... 17-4 Oracle Forms Developer: Build Internet Applications I ................... Query Processing Fire Fire Pre-Query Pre-Query trigger trigger Construct Construct SELECT. SELECT.................................................

.......... this record is flushed from the block..... Oracle Forms Developer: Build Internet Applications I 17-5 ...... if the Fire in Enter Query Mode property of the associated trigger is enabled The query triggers.Query Triggers .... Form Builder constructs the query SELECT statement............. 6 Form Builder fires the Post-Query trigger.................. Pre-Query and Post-Query..... 8 Step 4 is repeated for any remaining records of this query.................. Query Triggers Generally................. based on any existing criteria in the block (either entered by the operator or by the Pre-Query).. 5 The record is marked Valid...... With these triggers you can add to the normal Form Builder processing of records. 7 Form Builder performs item and record validation if the record has changed (due to a trigger)..... if the required conditions are not suitable..................... fire due to the query process itself...................................... 4 Form Builder fetches the column values of a row into the base table items of a new record in the block...................................... either by the operator or by a built-in subprogram........................... Form Builder Query Processing When a query is initiated on a data block....... 2 If the Pre-Query succeeds........ triggers are associated with a query in one of two ways: • A trigger fires due to the query process itself For example: Pre-Query and Post-Query • An event can fire a trigger in Enter Query mode........................ the following major events take place: 1 In Enter Query mode. .......... and are usually defined on the block where the query takes place.................... or possibly abandon a query before it is even executed............. 3 The query is performed. Form Builder fires the Pre-Query trigger if defined.. If it fails....

................................................. ............................................................................................ .......................................... ...... SELECT Statements Issued base_column... ROWID :base_item......... :ROWID base_table FROM WHERE default_where_clause AND (example_record_conditions) AND (query_where_conditions) ORDER BY default_order_by_clause | query_where_order_by SELECT INTO Slightly different for COUNT Copyright  Oracle Corporation. 2000.............................................................Lesson 17: Query Triggers ........................ All rights reserved............... 17-6 Oracle Forms Developer: Build Internet Applications I ............

.......... enter one or more variables and press Count Query in the Example Record................... .............SELECT Statements Issued During Query Processing .... ................................... The entire WHERE clause is optional................................ SELECT base_column... base_column........................ ... .............. Oracle Forms Developer: Build Internet Applications I 17-7 . Form Builder retrieves the ROWID only when the Key Mode block property is set to Unique (the default).......... If you want to count records that satisfy criteria specified in the Query/Where dialog box........... ................. ROWID INTO :base_item....................... The ORDER BY clause is also optional.......... Form Builder issues a SELECT statement when you want to retrieve or count records............................................................................ SELECT Statements Issued During Query Processing If you have not altered default query processing. :ROWID FROM base_table WHERE default_where_clause AND (example_record_conditions) AND (query_where_conditions) ORDER BY default_order_by_clause | query_where_order_by SELECT COUNT(*) FROM base_table WHERE default_where_clause AND (example_record_conditions) AND (query_where_conditions) ORDER BY default_order_by_clause | query_where_order_by Note: The vertical bar ( | ) in the ORDER BY clause indicates that either of the two possibilities can be present....:base_item...........

................................. 17-8 Oracle Forms Developer: Build Internet Applications I .............................. 2000................... All rights reserved............................... WHERE Clause • Three sources for the WHERE clause: – WHERE clause block property – Example Record – Query/Where dialog box • WHERE clauses are combined by the AND operator Copyright  Oracle Corporation............. .............................................................. All rights reserved............ 2000..................................Lesson 17: Query Triggers ....................................................................... ORDER BY Clause • Two sources for the ORDER BY clause: – ORDER BY clause block property – Query/Where dialog box • Second source for ORDER BY clause overrides the first one Copyright  Oracle Corporation..

.......... Two Sources for the ORDER BY Clause • ORDER BY clause block property • Query/Where dialog box An ORDER BY clause specified in the Query/Where dialog box overrides the value of the ORDER BY clause block property........................................................ WHERE and ORDER BY Clauses The WHERE and ORDER BY clauses of a default base table SELECT statement are derived from several sources.............................. Note: You can change the WHERE clause and ORDER BY clause block properties at run time by using the SET_BLOCK_PROPERTY built-in.............................................................. Oracle Forms Developer: Build Internet Applications I 17-9 ...............WHERE and ORDER BY Clauses .......................................... It is important to know how different sources interact............. .......................... Three Sources for the WHERE Clause • WHERE clause block property • Example Record • Query/Where dialog box If more than one source is present......... the different conditions will all be used and linked with an AND operator............................................

Pre-Query Trigger • • IF Defined at block level Fires once..................................DATE_SHIPPED) IS NULL THEN MESSAGE(’You must query by Order ID or Date’)........... Instructor Note With a restricted query..... END IF. 2000. For example......... this trigger code can cause an error................................. 17-10 Oracle Forms Developer: Build Internet Applications I ...............ID)|| TO_CHAR(:S_ORD..................... RAISE form_trigger_failure............................... All rights reserved....... Using NAME_IN in the code ensures that the correct datatype is used........................................ ............... before query is performed TO_CHAR(:S_ORD..........DATE_ORDERED)|| TO_CHAR(:S_ORD...................Lesson 17: Query Triggers ........................ Copyright  Oracle Corporation...... entering >10 for the ID item causes an error because the TO_CHAR in the trigger code around the ID item..................................

. RAISE form_trigger_failure.......................... the trigger fires after the query criteria is entered..........id)|| TO_CHAR(:S_ORD.. .... Oracle Forms Developer: Build Internet Applications I 17-11 ................. This means you can use Pre-Query as follows: • To test the operator’s query conditions..... Note: Pre-Query is useful for assigning values passed from other Oracle Forms Developer modules.... while the form is in Enter Query mode (that is............ so that the query is related to data elsewhere in the session..... before Form Builder executes the query)................. Date Ordered........ It fires for either a global or restricted query.........................................Writing Query Triggers ....... If the operator has initiated the query........ IF TO_CHAR(:S_ORD................................... and to fail the query process if the conditions are not satisfactory for the application • To add criteria for the query by assigning values to base table items Example This Pre-Query trigger on the S_ORD block permits queries only if there is a restriction on either the Order ID......date_ordered)|| TO_CHAR(:S_ORD..... We will look at doing this later............................................. This prevents attempts at very large queries............ END IF.. or Date Shipped........................ Writing Query Triggers Pre-Query Trigger You must define this trigger at block level or above...........date_shipped) IS NULL THEN MESSAGE(’You must query by Order ID or Date’)..............

.....Lesson 17: Query Triggers ........................... 2000......... Copyright  Oracle Corporation.. Post-Query Trigger • Fires for each fetched record (except during array processing) • Use to populate nondatabase items and calculate statistics SELECT COUNT(ord_id) INTO :S_ORD..............................id.lineitem_count FROM WHERE S_ITEM ord_id = :S_ORD....................... 2000................................................... All rights reserved........ Using SELECT Statements in Triggers • • • • Form Builder variables are preceded by a colon. The INTO clause is mandatory...... ............ Code exception handlers................... • ORDER BY is not relevant.......... 17-12 Oracle Forms Developer: Build Internet Applications I ............................... Copyright  Oracle Corporation......... All rights reserved................................................................... The query must return one row for success.. with a variable for each selected column or expression...

.............. or else an exception is raised that terminates the normal executable part of the block.......... colons are required in front of Form Builder variables to distinguish them from PL/SQL variables and database columns.. Oracle Forms Developer: Build Internet Applications I 17-13 .............. Post-Query Trigger This trigger is defined at block level or above.......... Here is a reminder of some other rules regarding SELECT statements in PL/SQL: • A single row must be returned from the query.............. • ORDER BY and other clauses that control multiple-row queries are not relevant (unless they are part of an Explicit Cursor definition)............................. form items or global variables in the INTO clause... SELECT COUNT(ord_id) INTO :S_ORD.....lineitem_count FROM S_ITEM WHERE ord_id = :S_ORD............ populates the Lineitem_Count item through the INTO clause.. not when a record is subsequently scrolled back into view a second or third time..id................... Again..... • Code exception handlers in your PL/SQL block to deal with possible exceptions raised by SELECT statements............... and must define a receiving variable for each selected column or expression.......................... • The INTO clause is mandatory... Note that the trigger fires only on the initial fetch of a record.................... Use Post-Query as follows: • To populate nondatabase items as records are returned from a query • To calculate statistics Example This Post-Query trigger on the S_ORD block selects the total count of line items for the current Order.................... ....... Post-Query fires for each record that is fetched into the block as a result of a query.................................... You can use PL/SQL variables.............................. You usually want to match a form value with a unique column value in your restriction.. and displays this number as a summary value in the nonbase table item :Lineitem_count................Writing Query Triggers .. Using SELECT Statements in Triggers The previous trigger example.....

...........................................................................................................................Lesson 17: Query Triggers ................................................................. ......... Query Array Processing • • Reduces network traffic Enables Query Array processing: – Enable Array Processing option – Set Query Array Size property • • Query Array Size property Query All Records property Copyright  Oracle Corporation..................................... All rights reserved..... 17-14 Oracle Forms Developer: Build Internet Applications I ....... 2000..........................................................

.... This lesson focuses on array query processing....... select the Data Blocks node... For both querying and DML operations........... ..... because Form Builder fetches and displays only one record at a time...... ..... ............................ Query Array Processing The default behavior of Form Builder is to process records one at a time.......................................... 2 Setting properties: .. Query All Records Property Specifies whether all the records matching the query criteria should be fetched into the data block when a query is executed. By contrast........ Oracle Forms Developer: Build Internet Applications I 17-15 ....Select the Array Processing check box....Select Tools—>Preferences....Under the Records category.... • No: Fetches the number of records specified by the Query Array Size block property..... .......Query Array Processing ........ you can determine the array size to optimize performance for your needs.. A size of 1 provides the fastest perceived response time.... a size of 10 fetches up to ten records before displaying any of them..Double-click the Data Blocks icon to display the Property Palette............... a structure (array) containing multiple records is sent to or returned from the server for processing.......... ... With array processing............ Enabling Array Processing for Queries 1 Setting preferences: ... Form Builder supports both array fetch processing and array DML processing........................................................ Query Array Size Property This property specifies the maximum number of records that Form Builder should fetch from the database at one time..........In the Object Navigator. set the Query Array Size property to a number that represents the number of records in the array for array processing.......... however......... the larger size reduces overall processing time by making fewer calls to the database for records.Click the Runtime tab...... • Yes: Fetches all records from query..............................

........................................When-Validate-Item To create a trigger that fires in Enter Query mode: 1 In the Object Navigator............................ All rights reserved.When-Validate-Record . 2 In the Property Palette................Lesson 17: Query Triggers ..................... Instructor Note The following triggers may fire in Enter Query mode: • Key• On-Error • On-Message • When.....MODE – NORMAL – ENTER-QUERY – QUERY Copyright  Oracle Corporation....................... Set to fire in Enter-Query Mode property...When-Create-Record ..... select a trigger...When-Image-Activated .... ........ 2000........When-Database-Record ........... 17-16 Oracle Forms Developer: Build Internet Applications I ...............When-Remove-Record ...........triggers........................................When-New-Block-Instance ...... set the Fire in Enter Query Mode property to Yes...................... Coding for ENTER-QUERY Mode • • • Some triggers may fire in Enter-Query mode..........When-New-Form-Instance ............ Test mode during execution with :SYSTEM........... except: .................

Fire in Enter Query Mode Property This property determines whether Form Builder fires a trigger if the associated event occurs in Enter Query mode..... Set it to No in the Property Palette if you only want the trigger to fire in Normal mode....... By default................ then the When-Button-Pressed trigger needs to fire in both modes........... You need to consider the trigger type and actions in these cases.......... Coding Triggers for Enter Query Mode Some triggers that fire when the form is in Normal mode (during data entry and saving) may also be fired in Enter Query mode........................ Example If you provide a button for the operator to invoke an LOV..... consult Form Builder online Help................... and the LOV is required to help with query criteria as well as data entry.......... Not all triggers can do this. END IF............ .................................... which lists each trigger and whether this property can be set.....Coding Triggers for Enter Query Mode ........................................ the Fire in Enter Query Mode property is set to Yes for triggers that accept this.......................................................... Oracle Forms Developer: Build Internet Applications I 17-17 ......... This trigger has Fire in Enter Query Mode set to Yes (default for this trigger type): IF SHOW_LOV(’Customers’) THEN MESSAGE(’Selection successful’)...............................................

........Lesson 17: Query Triggers ................................................. 2000............MODE = ’NORMAL’ THEN ENTER_QUERY........................ END IF............. You cannot navigate to another record in the current form.......................................... All rights reserved..................... Consult online Help. .......... • • • Some built-ins are illegal........................................................ 17-18 Oracle Forms Developer: Build Internet Applications I ........ Copyright  Oracle Corporation............ Coding for ENTER-QUERY Mode • Example IF :SYSTEM.................... ELSE EXECUTE_QUERY...................................

.

......Lesson 17: Query Triggers ............................................ 2000.......................................................................................................... .......... 17-20 Oracle Forms Developer: Build Internet Applications I ........... Overriding Default Query Processing Trigger Do-the-Right-Thing Built-in On-Close On-Count COUNT_QUERY On-Fetch FETCH_RECORDS Pre-Select On-Select SELECT_RECORDS Post-Select Copyright  Oracle Corporation.................................................................................................................. All rights reserved.............

.................................................................................................... You can use “Do-the-right-thing” built-ins to augment default query processing............... Some of the transactional triggers can also be used to replace default query processing................... Overriding Default Query Processing You can use certain transactional triggers to replace default commit processing.............. do not use “Do-the-right-thing” to replace default processing........... Additional Transactional Triggers for Query Processing Trigger On-Close On-Count On-Fetch Pre-Select On-Select Post-Select Do-the-Right-Thing Built-in COUNT_QUERY FETCH_RECORDS SELECT_RECORDS ..................................... Oracle Forms Developer: Build Internet Applications I 17-21 .................................................................Overriding Default Query Processing ............................................

..................... • On-Select replaces open cursor..... and execute phases..............Lesson 17: Query Triggers ...................................... but have not yet been placed on the block list of active records....................................... All rights reserved... 17-22 Oracle Forms Developer: Build Internet Applications I . This built-in is included primarily for applications using transactional triggers to run against a data source other than Oracle. parse...................... – It raises FORM_TRIGGER_FAILURE.... The waiting list is an intermediary record buffer that contains records that have been fetched from the data source............ 2000. it creates a record on the block waiting list.................................................... Instructor Note When the CREATE_QUERIED_RECORD built-in is called from an On-Fetch trigger..................................................................... Copyright  Oracle Corporation............... . – The query is closed by the user or by ABORT_QUERY............. Overriding Default Query Processing • On-Fetch continues to fire until: – It fires without executing CREATE_QUERIED_RECORD....

........... and execute phases of a query.. Oracle Forms Developer: Build Internet Applications I 17-23 .............................. but before it fetches the records Uses for Transactional Triggers for Query Processing Transactional triggers for query processing are primarily intended to access certain data sources other than Oracle...) Fires when Form Builder would usually perform default Count Query processing to determine the number of rows that match the query conditions Fires when Form Builder performs a fetch for a set of rows (You can use the CREATE_QUERIED_RECORD built-in to create queried records if you want to replace default fetch processing....) Fires after Form Builder has constructed and issued the block SELECT statement... but before it issues this statement Fires when Form Builder would usually issue the block SELECT statement (The trigger replaces the open cursor............................... parse............ However.........................................................) The trigger continues to fire until: • Pre-Select On-Select Post-Select No queried records are created during a single execution of the trigger • The query is closed by the user or by the ABORT_QUERY built-in is executed from another trigger • The trigger raises FORM_TRIGGER_FAILURE Fires after Form Builder has constructed the block SELECT statement based on the query conditions................................. ...................... you can also use these triggers to implement special functionality by augmenting default query processing against an Oracle database... Characteristics of Transactional Triggers for Query Processing Trigger On-Close On-Count On-Fetch Characteristic Fires when Form Builder closes a query (It augments..............................................Overriding Default Query Processing ............................ default processing.................... rather than replaces........

........... 17-24 Oracle Forms Developer: Build Internet Applications I .......... Obtaining Query Information at Run Time • • SYSTEM................ All rights reserved.........................LAST_QUERY – Contains bind variables (ORD_ID = :1) before SELECT_RECORDS – Contains actual values (ORD_ID = 102) after SELECT_RECORDS Copyright  Oracle Corporation...................................................Lesson 17: Query Triggers ............................................................................MODE SYSTEM.............................................. 2000...................................................... .................

..................................... Obtaining Query Information at Run Time If you want to exercise more control over your queries...Obtaining Query Information at Run Time ....... and QUERY.............LAST_QUERY to obtain the text of the base-table SELECT statement that was last executed by Form Builder..................................... ORD_ID = 102)..... ORD_ID = :1)...........MODE Use the SYSTEM..... If the system variable is used before Form Builder has implicitly executed the SELECT_RECORDS built-in......MODE system variable to obtain the form mode.. the SELECT statement contains the actual search values (for example.... If the system variable is used after Form Builder has implicitly executed the SELECT_RECORDS built-in........................ The three values are NORMAL.......... ........ For example.... ENTER_QUERY......................... Using SYSTEM................. the system variable contains bind variables during the Pre-Select trigger and actual search values during the Post-Select trigger...... If a user has entered query conditions in the Example Record.......... use system variables and builtins to obtain information about queries.......... the exact form of the SELECT statement depends on when this system variable is used..............LAST_QUERY Use SYSTEM...................... the SELECT statement contains bind variables (for example............................ We discussed this system variable in the section “Finding Out the Current Mode” in this lesson. Oracle Forms Developer: Build Internet Applications I 17-25 . Using SYSTEM.............

.............Lesson 17: Query Triggers .. Obtaining Query Information at Run Time • GET_BLOCK_PROPERTY SET_BLOCK_PROPERTY – Get and set: DEFAULT_WHERE ORDER_BY QUERY_ALLOWED QUERY_HITS – Get only: QUERY_OPTIONS RECORDS_TO_FETCH Copyright  Oracle Corporation.................. All rights reserved.............................................. All rights reserved..................................................................... 2000.................. Obtaining Query Information at Run Time • GET_ITEM_PROPERTY SET_ITEM_PROPERTY – Get and set: CASE_INSENSITIVE_QUERY QUERYABLE QUERY_ONLY – Get only: QUERY_LENGTH Copyright  Oracle Corporation............................................................ 2000...................... ............ 17-26 Oracle Forms Developer: Build Internet Applications I ...............................................

............... ... • CASE_INSENSITIVE_QUERY (*) • QUERYABLE (*) • QUERY_ONLY (*) • QUERY_LENGTH Instructor Note QUERYABLE determines if the item can be included in a query against the base table of the block to which the item belongs.............. QUERY_ONLY specifies that an item can be queried but that it should not be included in any INSERT or UPDATE statement that Form Builder issues for the block at run time....................................................Obtaining Query Information at Run Time ................................................................. Only the properties marked with an asterisk can be set.............................................................................. Only the properties marked with an asterisk can be set..... Using GET_BLOCK_PROPERTY and SET_BLOCK_PROPERTY The following block properties may be useful for obtaining query information.............................. • DEFAULT_WHERE (*) • ORDER_BY (*) • QUERY_ALLOWED (*) • QUERY_HITS (*) • QUERY_OPTIONS • RECORDS_TO_FETCH Using GET_ITEM_PROPERTY and SET_ITEM_PROPERTY The following item properties may be useful for getting query information......... Oracle Forms Developer: Build Internet Applications I 17-27 ....................................

................... Use it to check or modify query conditions............ 17-28 Oracle Forms Developer: Build Internet Applications I ............. All rights reserved..................................... • A Post-Query trigger fires as each record is fetched (except array processing)....Lesson 17: Query Triggers .................................. 2000..................................................................................MODE – SYSTEM........ ... 2000................. Use it to perform calculations and populate additional items...........................................MODE..... – Some built-ins are illegal in Enter Query mode. • Obtain query information at run time: – SYSTEM. Copyright  Oracle Corporation.. Summary • A Pre-Query trigger fires before a query executes..LAST_QUERY Copyright  Oracle Corporation........................ Summary • Some triggers can fire in both Normal and Enter Query modes: – Test the current mode with SYSTEM....... All rights reserved..

..................... Summary In this lesson... you learned how to control the events associated with queries on base table blocks.................. This trigger is defined at the block level or above.. • Obtain query information at run-time by using: ...............MODE.................................... Use the Post-Query trigger to perform calculations and populate additional items.................SYSTEM.... • Some triggers can fire in both Normal and Enter Query modes............................MODE to test the current mode...................Use SYSTEM................ ..... • The Post-Query trigger fires as each record is fetched (except array processing)........ SYSTEM...........LAST_QUERY .......... Oracle Forms Developer: Build Internet Applications I 17-29 .......................... • Override default query processing by using “Do-the-right-thing” built-ins.. This trigger is defined at the block level or above........ ....Some properties of GET/SET_BLOCK_PROPERTY and GET/SET_ITEM_PROPERTY ............................................... • The Pre-Query trigger fires before the query executes......Summary .Some built-ins are illegal in Enter Query mode............. Use the Pre-Query trigger to check or modify query conditions.

........................ “Practice Solutions....................Lesson 17: Query Triggers ....... see Practice 17 in Appendix A............................................................. All rights reserved.............................................” ....................................... 17-30 Oracle Forms Developer: Build Internet Applications I ............................................................................ 2000..... Note For solutions to this practice.. Practice 17 Overview This practice covers the following topics: • Populating customer names and sales representative names for each row of the S_ORD block • Populating descriptions for each row of the S_ITEM block • Disabling the effect of the Exit button in Enter Query mode • Adding two check boxes to enable case-sensitive and exact match query Copyright  Oracle Corporation............................

................................................. Practice 17 Overview In this practice...... • Populating customer names and sales representative names for each row of the S_ORD block • Populating descriptions for each row of the S_ITEM block • Disabling the effect of the Exit button in Enter Query mode • Adding two check boxes to enable case-sensitive and exact match query ................................................................................ you create two query triggers to populate nonbase table items................................................................................... Oracle Forms Developer: Build Internet Applications I 17-31 .......................Practice 17 Overview ............................. You will also change the default query interface to enable case-sensitive and exact match query..................................

........... Open the CUSTOMERS form module.......................txt file into the Pre-Query Trigger............ PROPERTY_TRUE)..... Add a check box called CONTROL....... write a trigger that populates the Customer_Name and the Sales_Rep_Name for every row fetched by a query on the S_ORD block....... Set the Mouse Navigate property to No. END IF...name’.. CASE_INSENSITIVE_QUERY..... add a check box (called CONTROL.................txt file into the When-Checkbox-Changed trigger...CASE_INSENSITIVE_QUERY. and create the following trigger......... Set the initial value property to “Y.. Set the initial value property to “Y.. ’Y’) = ’Y’ THEN SET_ITEM_PROPERTY(’S_CUSTOMER............Exact_Match to the form so that the user can specify whether or not a query condition for a customer name should exactly match the table value..... PROPERTY_FALSE). 4 Adjust the default query interface.....name’..case_sensitive...name || ’%’....... ’Y’ ) = ’N’ THEN :S_CUSTOMER............ Pre-Query Trigger on the S_CUSTOMER Block IF NVL( :CONTROL.. ELSE SET_ITEM_PROPERTY(’S_CUSTOMER........ 2 Write a trigger that populates the Description for every row fetched by a query on the S_ITEM block.....Exact_Match as shown below) to the CONTROL block and create the following trigger.......Case_Sensitive Item (Checkbox) IF NVL(:CONTROL......Case_Sensitive as shown below) to it.... 17-32 Oracle Forms Developer: Build Internet Applications I ........ Set the “Mouse Navigate” property to No.... Practice 17 1 In the ORDGXX form........... 3 Ensure that the Exit_Button has no effect in Enter Query mode.... (If a nonexact match is allowed... You can import the pr17_4........ END IF...... ....... 5 Add a check box called CONTROL.... Ensure that the When-Radio-Changed trigger has no effect in Enter Query mode........” In the CONTROL block. the search value can be part of the table value..Lesson 17: Query Triggers .....) You can import the pr17_5......... When-Checkbox-Changed Trigger on the CONTROL................Case_Sensitive to the form so that the user can specify whether or not a query for a customer name should be case sensitive.exact_match.....” Add another check box (called CONTROL...............................name := ’%’ || :S_CUSTOMER........................

.................. Validation .18 ..............

......................................................................Lesson 18: Validation ............................................. 2000................................. Objectives After completing this lesson.............................................................................. 18-2 Oracle Forms Developer: Build Internet Applications I ................ All rights reserved................. Schedule Topic Lecture Practice Total Timing 35 minutes 30 minutes 65 minutes ............................ you should be able to do the following: • Explain the effects of the validation unit upon a form • • List Form Builder validation properties Control validation by using triggers Copyright  Oracle Corporation..................

.................................................................................. Oracle Forms Developer: Build Internet Applications I 18-3 ....... Introduction Overview In this lesson......................................................................................................................................... ... You will also learn to control when validation occurs..........................Introduction ............................... you will learn how to supplement item validation by using both object properties and triggers..................

........................... 2000... All rights reserved.................................................. 2000....................................................Lesson 18: Validation ............................................................... 18-4 Oracle Forms Developer: Build Internet Applications I ................................. All rights reserved. ........................................................ Validation • Form Builder validates at the following levels: Form level Block level Record level Item level Copyright  Oracle Corporation.......... Validation • Validation occurs when: – [Enter] key or ENTER Built-in is obeyed – Operator or trigger leaves the validation unit (includes a Commit) Copyright  Oracle Corporation............

The validation unit is discussed in the next section..... it is set to valid. block...... Form Builder checks to see whether the record is valid.... If not........ When Does Validation Occur? Form Builder carries out validation for the validation unit under the following conditions: • The [Enter] key is (ENTER command is not necessary mapped to the key that is physically labeled Enter) pressed or the ENTER built-in procedure is run (whose purpose is to force validation immediately)..Validate from List (see later in this lesson) • Record level: After leaving a record.. so that the operator can make corrections........ If validation fails.............................................. For example............. Oracle Forms Developer: Build Internet Applications I 18-5 .......... Validation occurs at: • Item level: Form Builder records a status for each item to determine whether it is currently valid... These checks are carried out before firing any When-Validate-Item triggers that you have defined...... if present.Data type .....Required (if so.......... and a When-Validate-Record trigger is then fired....... Validation Process Form Builder performs a validation process at several levels to ensure that records and individual values follow appropriate rules................ • Block and form level: At block or form level................ then Form Builder first performs standard validation checks to ensure that the value conforms to the item’s properties........ or form by the designer.............. unless you have suppressed this action... • The operator or a trigger navigates out of the validation unit.................... When the record passes these checks.. The default validation unit is item.. .... This includes when changes are committed............................. then control is passed back to the appropriate level.... if you commit (save) changes in the form.............Format mask .................... then the status of each item in the record is checked.... but can also be set to record..............Validation Process . all records below that level are validated. If an item has been changed and is not yet marked as valid..Range (Lowest-Highest Allowed Value) ........ then all records in the form are validated......... Standard checks include the following: ...... then is the item null?) ....

........................................... ........................................ and demonstrate its effect at run time............................. 18-6 Oracle Forms Developer: Build Internet Applications I .................................. You may want to set Validation Unit to a higher level...Lesson 18: Validation ......................... Validation Unit Property Copyright  Oracle Corporation................................. Instructor Note Show the Validation Unit property in Form Builder.................................. All rights reserved.................... 2000..............................................

........................... This way........................ even without triggers........... All outstanding items and records are validated together................................... Validation unit is a property of the form module................ As a result.... and it can be set in the Property Palette to any of the following: • Default • Item • Record • Block • Form The default setting is item level............. The default setting is usually chosen..... At higher validation units (record.. operators are aware of validation failure as soon as they attempt to leave the item......... Do this by setting properties for the form and for individual items within it..Using Object Properties to Control Validation ..... an item-level validation unit means that Form Builder validates changes when an operator navigates out of a changed item.... including the firing of When-Validate-Item and When-Validate-Record triggers......... Oracle Forms Developer: Build Internet Applications I 18-7 ............. The Validation Unit The validation unit defines the maximum amount of data an operator can enter in the form before Form Builder initiates validation............................... or form level)... and you want to postpone traffic until the operator has completed a record (record level).......... In practice.................. standard validation checks and firing the When-Validate-Item trigger of that item can be done immediately............ Using Object Properties to Control Validation You can control when and how validation occurs in a form............................ the above checks are postponed until navigation moves out of that unit........................... ....... • The application runs in a block-mode environment (block level)... You might set a validation unit above item level under one of the following conditions: • Validation involves database references.... block.

........................ LOV for Validation TERRY LOV Full list ENAME HDATE --------------- --------------- MARTIN 20-FEB-1981 MARTINEZ 22-FEB-1981 SEDAT 06-MAR-1996 WARD 06-FEB-1995 ALAN 08-SEP-1981 Partial list MART Valid WARD AL Auto complete ALAN Copyright  Oracle Corporation............. Then..................................................... All rights reserved................ ............................................................ Instructor Note Set the Validate from List property on an item to which you have already attached a suitable LOV................................................. build and run the form to show the use of this feature................................. 2000................................ 18-8 Oracle Forms Developer: Build Internet Applications I ..Lesson 18: Validation .........................

............................ Form Builder then automatically uses the item value as a non case-sensitive search string on the LOV contents......... do not use the LOV for Validation property for large LOVs............... Note: Make sure that LOVs you create for validation purposes have the validation column defined first. with a display width greater than 0........... For performance reasons.. Form Builder displays the LOV and uses the text item value as the search criteria to automatically reduce the list........ validation succeeds......... Using LOVs for Validation When you attach an LOV to a text item by setting the LOV property of the item........... .... the LOV is not displayed......... Oracle Forms Developer: Build Internet Applications I 18-9 ........... Do this by setting the Validate from List property to Yes for the item......................... you can optionally use the LOV contents to validate data entered in the item........ You also need to define the Return Item for the LOV column as the item being validated........... The item then passes this validation phase. then the full LOV column value is returned to the item (providing that the item is defined as the return item in the LOV).. depending on the circumstances: • If the value in the text item matches one of the values in the first column of the LOV. but is a partial value of the LOV value........... • If the item value causes multiple records to be found in the LOV........................... At validation time................................ The following events then occur........ • If no match is found.........Using Object Properties to Control Validation .. and processing continues normally.. • If the item’s value causes a single record to be found in the LOV............ then the full LOV contents are displayed to the operator.......................................... so that the operator must choose..............

date_ordered THEN THEN MESSAGE(’Ship MESSAGE(’Ship Date Date is is before before Order Order Date!’).....................Lesson 18: Validation ...... RAISE RAISE form_trigger_failure......... Its use is not recommended in new applications... 18-10 Oracle Forms Developer: Build Internet Applications I ..........................date_ordered :S_ORD........3) sometimes ask about using Post-Change as a validation trigger........................................ Validation Triggers • Item level When-Validate-Item • Block level When-Validate-Record IF IF :S_ORD............. Date!’)........ Copyright  Oracle Corporation. Students who have experience with early versions of the product (SQL*Forms V2.............................. 2000...date_shipped << :S_ORD.........................date_shipped :S_ORD.................. The Post-Change trigger is included only for compatibility with previous versions of Form Builder..... ..... END IF....... and it can fire on population at query time............. END IF.................... Instructor Note Introduce When-Validate-Record as an additional validation trigger......... making it less specific to validation than the When-Validate-Object triggers.. Post-Change does not fire if an item is set to Null...... form_trigger_failure............................. All rights reserved...............

......... When-Validate-Record Trigger This trigger fires after standard record-level validation.Controlling Validation by Using Triggers . RAISE form_trigger_failure............ The trigger fires after standard item validation........................ RAISE form_trigger_failure......... Example This When-Validate-Item trigger on :S_ORD... when the operator has left a new or changed record................. IF :S_ORD.................date_shipped < :S_ORD............date_ordered > SYSDATE THEN MESSAGE(’Order Date is later than today!’).... When-Validate-Record must be defined at block level or above......................................... There are also some built-in subprograms that you can call from triggers that affect validation........ When-Validate-Item Trigger You have already used this trigger to add item-level validation.....................date_ordered THEN MESSAGE(’Ship Date is before Order Date!’)..................... Because Form Builder has already checked that required items for the record are valid........ Oracle Forms Developer: Build Internet Applications I 18-11 ..................... END IF......... Example This When-Validate-Record trigger on block S_ORD ensures that orders cannot be shipped before they are ordered....... END IF........................................... which let you add your own customized actions........ Controlling Validation by Using Triggers There are triggers that fire due to validation.......... ........ in the order they were entered. you can use this trigger to perform additional checks that may involve more than one of the record’s items..date_ordered ensures that the Order Date is not later than the current (database) date: IF :S_ORD. and input focus is returned to the item if the trigger fails......

............................................ ..... Validating User Input Customer ID 998 W-V-I SELECT ....................... ......... WHERE id = :S_ORD............ All rights reserved.................................................. 2000.............. 18-12 Oracle Forms Developer: Build Internet Applications I ..................................................................................customer_id Trigger failure? Copyright  Oracle Corporation..........Lesson 18: Validation ................................... ........................

.........................customer_id.........Validating User Input . Validating User Input While populating other items.................... • TOO_MANY_ROWS More than one row is returned from the query....................................... If the Customer_ID item contains a value that is not found in the table.............customer_name...... :S_ORD.... be used to validate user input..... the NO_DATA_FOUND exception is raised........... and the SELECT statement will cause an exception.. The success or failure of the query can................. the user receives the message: FRM-40735: <trigger type> trigger raised unhandled exception <exception> ..... phone INTO :S_ORD.. The exceptions that can occur when a single row is not returned from a SELECT in a trigger are: • NO_DATA_FOUND No rows are returned from the query.... and returns both the Name and Phone Number that correspond to the Customer ID entered by the user.. SELECT name.................... a matching row will not be found............... Example The following When-Validate-Item trigger is again placed on the Customer_ID item............ therefore.... if the user enters an invalid value in the item................................... For an unhandled exception.......... and the trigger will fail because there is no exception handler to prevent the exception from propagating to the end of the trigger.......... as above...... Note: A failing When-Validate-Item trigger prevents the cursor from leaving the item..................................... Oracle Forms Developer: Build Internet Applications I 18-13 .......customer_phone FROM s_customer WHERE id = :S_ORD...

...................... All rights reserved.........................................Lesson 18: Validation .... Tracking Validation Status • NEW – When a record is created – Also for Copy Value from Item or Initial Value • CHANGED – When changed by user or trigger – When any item in new record is changed Copyright  Oracle Corporation........ 18-14 Oracle Forms Developer: Build Internet Applications I ....... All rights reserved...................................................... ...................................................................................... Tracking Validation Status • VALID – When validation has been successful – After records are fetched from database – After a successful post or commit – Duplicated record inherits status of source Copyright  Oracle Corporation................................... 2000........................................... 2000.......

.............. VALID Form Builder marks a record as valid under the following conditions: • • • • After all items in the record have been successfully validated All records that are fetched from the database are marked as valid After successful post or commit A duplicated record inherits the status of its source ................ or by the When-Create-Record trigger......... This is true even if the item is populated by the Copy Value from Item or Initial Value item properties........... Tracking Validation Status When Form Builder leaves an object......................... all of the items in the record are marked as changed Form Builder marks an item as valid under the following conditions: • • • • All items in record that are fetched from the database are marked as valid If validation of the item has been successful After successful post or commit Each item in a duplicated record inherits the status of its source Record Validation Status Status Definition NEW When a record is created................... or by the When-Create-Record trigger.................Tracking Validation Status ............................ To determine whether validation must be performed......... CHANGED Form Builder marks an item as changed under the following conditions: • • VALID When the item is changed by the user or a trigger When any item in a new record is changed....................................... it usually validates any changes that were made to the contents of the object... Form Builder marks that record as new....................................... Oracle Forms Developer: Build Internet Applications I 18-15 ....... Form Builder tracks the validation status of items and records............ This is true even if the item is populated by the Copy Value from Item or Initial Value item properties............ Form Builder marks that record as changed............................ CHANGED Whenever an item in a record is marked as changed.................. Item Validation Status Status Definition NEW When a record is created..... Form Builder marks every item in that record as new.....

.. All rights reserved........ ....................... 2000.Lesson 18: Validation .............................................. EXIT_FORM ENTER SET_FORM_PROPERTY – (............................... VALIDATION) – (...................... CLEAR_ FORM....................... Built-ins for Validation • • • CLEAR_BLOCK....................................... 18-16 Oracle Forms Developer: Build Internet Applications I ............................................................................................................... VALIDATION_UNIT) • • ITEM_IS_VALID item property VALIDATE (VALIDATION_ UNIT) Copyright  Oracle Corporation........

. Oracle Forms Developer: Build Internet Applications I 18-17 ........................... For example. When the parameter is set to NO_VALIDATE....................Built-ins for Validation ........................................... or the form is exited respectively.. scope)....... ITEM_IS_VALID Item Property You can use GET_ITEM_PROPERTY and SET_ITEM_PROPERTY built-ins with the ITEM_IS_VALID parameter to get or set the validation status of an item...... and EXIT_FORM The first parameter to these built-ins....... controls what will be done with unapplied changes when a block is cleared. You cannot directly get and set the validation status of a record............... COMMIT_MODE............. CLEAR_BLOCK...... changes are neither validated nor committed (by default.. the operator is prompted for the action)............ Built-ins for Validation You can use the following built-in subprograms in triggers to affect validation... you can get or set the validation status of all the items in a record............VALIDATION.... and you need to bypass normal validation......... RECORD_SCOPE....... However............ the form is cleared.VALIDATION_UNIT....... CLEAR_FORM........... .. SET_FORM_PROPERTY You can use this to disable Form Builder validation. Set the Validation property to Property_False for this purpose: SET_FORM_PROPERTY(’form_name’................. You can also use this built-in to change the validation unit programmatically: SET_FORM_PROPERTY(’form_name’...... Note: Scope is one of DEFAULT_SCOPE... BLOCK_SCOPE... That is........... PROPERTY_FALSE)..... it forces validation of data in the current validation unit.. VALIDATE VALIDATE forces Form Builder to immediately execute validation processing for the indicated scope... or ITEM_SCOPE.................................... suppose you are testing a form........... ENTER The ENTER built-in performs the same action as the [Enter] key.....

...Lesson 18: Validation ......................... record....... 2000. • • Default validation unit is item level....................... Summary • Standard validation occurs before trigger validation..................................... and form levels..... block........... Summary • Validation occurs at item..... • Validation happens when: – [Enter] Key or ENTER built-in is activated – Control leaves the validation unit due to navigation or commit Copyright  Oracle Corporation......... Copyright  Oracle Corporation............... ................................................................................................................ All rights reserved................. All rights reserved..... 18-18 Oracle Forms Developer: Build Internet Applications I ....................... Validation status – NEW – CHANGED – VALID • When-Validate-“object” triggers to supplement validation.. 2000..............

.Summary ............. Oracle Forms Developer: Build Internet Applications I 18-19 ............ • The Default validation unit is item level............................ • Validation occurs at three levels: ........... • Validation happens when: .Item level: To ensure that the value conforms to the item’s properties ....Block and form level: To ensure that the all records below the level are validated.....NEW ............................VALID • The When-Validate-“object” triggers supplement standard validation............................. you learned to use additional validation features in Form Builder.......The [Enter] Key is pressed or the ENTER built-in procedure is run (to force validation immediately....CHANGED .) .... • Standard validation occurs before trigger validation........................................... • Validation Status: ..Control leaves the validation unit due to navigation or Commit..............................) .................................... and to control when validation occurs...... ..... then the status of each item in the record is checked....................................Record level: To ensure that the record is valid (If it is not......... Summary In this lesson.....

...................................... “Practice Solutions........................................... 18-20 Oracle Forms Developer: Build Internet Applications I ........................................................................” ................................................................... Note For solutions to this practice............................................. see Practice 18 in Appendix A.... 2000........ Practice 18 Overview This practice covers the following topics: • Validating the Sales Representative item value by using an LOV • Writing a validation trigger to check that the shipped date is not before the ordered date • Populating customer names. and IDs when a customer ID is changed • Writing a validation trigger to populate the name and the price of the product when the product ID is changed Copyright  Oracle Corporation.....Lesson 18: Validation .................. All rights reserved. sales representative names.......

.

.......................................................................................................................................................Lesson 18: Validation ........ Practice 18 1 ................ 18-22 Oracle Forms Developer: Build Internet Applications I ..............................................................................................................................

..... 19-2 Oracle Forms Developer: Build Internet Applications I ....Lesson 19: Navigation ...................................................................................... Schedule Topic Lecture Practice Total Timing 45 minutes 20 minutes 65 minutes ........ 2000.................. All rights reserved...................................................................................................... Objectives After completing this lesson................................ you should be able to do the following: • Distinguish between internal and external navigation • • Describe and use navigation triggers Identify built-ins that cause navigation Copyright  Oracle Corporation..................................................

.....................................................................................................Lesson 19: Navigation .......................... 2000............. Schedule Topic Lecture Practice Total Timing 45 minutes 20 minutes 65 minutes ............................ you should be able to do the following: • Distinguish between internal and external navigation • • Describe and use navigation triggers Identify built-ins that cause navigation Copyright  Oracle Corporation........................................................................................ All rights reserved.............................. 19-2 Oracle Forms Developer: Build Internet Applications I .... Objectives After completing this lesson...............

........................................................................ Introduction Overview Form Builder offers a variety of ways to control cursor movement........................................................ ...................................... Oracle Forms Developer: Build Internet Applications I 19-3 ......................................................................................... This lesson looks at the different methods of forcing navigation both visibly and invisibly.............................................Introduction ...

............... About Navigation • What is the navigational unit? – Outside the form – Form – Block – Record – Item • • Entering and leaving objects What happens if navigation fails? Copyright  Oracle Corporation.................... 19-4 Oracle Forms Developer: Build Internet Applications I ....................................Lesson 19: Navigation ................................................................................................... 2000.............................. ................................................................ All rights reserved........................................

.......... Entering and Leaving Objects During navigation...... the navigation unit acts as a probe.... Entering an object means changing the navigation unit from the object above in the hierarchy........................................ Leaving an object means changing the navigation unit to the object above.......................... Form Builder uses the navigation unit to keep track of the object that is currently the focus of a navigational process... If Form Builder cannot move the navigation unit back to its initial location. it changes the navigation unit moving through this object hierarchy until the target item is reached......... Note that the cursor is still at its initial position............... The Cursor and How It Relates to the Navigation Unit The cursor is a visible. About Navigation The following sections introduce a number of navigational concepts to help you to understand the navigation process................ In this sense............. What Happens If Navigation Fails? If navigation fails............................. What Is the Navigational Unit? The navigational unit is an invisible....... Form Builder reverses the navigation path and attempts to move the navigation unit back to its initial location. external object that indicates the current input focus..................About Navigation ........ Oracle Forms Developer: Build Internet Applications I 19-5 ........ it exits the form.................................................. Form Builder leaves and enters objects.............. internal object that determines the navigational state of a form......... The navigation unit can be one of the objects in the following hierarchy: • Outside the form • Form • Block • Record • Item When Form Builder navigates. ....... Form Builder will not move the cursor until the navigation unit has successfully become the target item.........................

. ............................................................................ 2000................Lesson 19: Navigation ........................ All rights reserved..... 2000...................................................................................... 19-6 Oracle Forms Developer: Build Internet Applications I ... Navigation Properties • Item – Enabled – Keyboard navigable – Mouse navigate – Previous navigation item – Next navigation item Copyright  Oracle Corporation............ Navigation Properties • Form module – Mouse navigation limit – First navigation data block • Block – Navigation style – Previous navigation data block – Next navigation data block Copyright  Oracle Corporation...................................... All rights reserved..............................................

.......................Controlling Navigation .......................) Property Navigation Style Previous Navigation Block Next Navigation Block Enabled Keyboard Navigable Mouse Navigate Previous Navigation Item Next Navigation Item Note: In a bitmapped environment.. There are two other navigation properties that you can set for the form module: Mouse Navigation Limit and First Navigation Block.............................. you can use the mouse to navigate to any enabled item regardless of its position in the navigational order............................................................ You have seen navigation properties for blocks and items...... Form Module Properties Mouse Navigation Limit First Navigation Block Object Block Item Function Determines how far outside the current item the user can navigate with the mouse Specifies the name of the block to which Form Builder should navigate on form startup (Setting this property does not override the order used for committing...................................... Controlling Navigation You can control the path through an application by controlling the order in which the user navigates to objects............................... Oracle Forms Developer: Build Internet Applications I 19-7 .......................................................................... ....................

...... Instructor Note Point out that with Mouse Navigate set to No.............................................Lesson 19: Navigation .......................... 2000................ Mouse Navigate Property = Yes Exit item Exit record ^ x Exit block v Enter block Enter record Enter item Copyright  Oracle Corporation.......................................................... none of the navigation events listed in the above slide occur... 19-8 Oracle Forms Developer: Build Internet Applications I ........... ..................................................... All rights reserved........................................................................................

............................Bean Area Setting Yes No Use to Ensure That Form Builder navigates to the new item which causes the relevant navigational and validation triggers to fire Form Builder does not navigate to the new item or validate the existing item when the user activates the new item with the mouse Note: The default setting for the Mouse Navigate property is Yes............................... Oracle Forms Developer: Build Internet Applications I 19-9 ........................... and is valid for the following items: • Push Button • Check box • List item • Radio group • Hierarchical tree item • Sound item • Custom item .......................................OLE2 Container ...........................................ActiveX Control ............ Mouse Navigate Property The Mouse Navigate property applies only to mouse-driven applications.......... .....................................VBX Control ...................................................Controlling Navigation .............................

.........” PRE-FORM PRE-BLOCK PRE-RECORD PRE-TEXT-ITEM POST-TEXT-ITEM POST-RECORD POST-BLOCK .................................... 19-10 Oracle Forms Developer: Build Internet Applications I ............................ Instructor Note Draw navigation examples of “on entry” and “on commit......................... All rights reserved........... 2000......................................Lesson 19: Navigation .................................................................................. Internal Navigation Exit item ^ x Next Record Exit record v Enter record Enter item Copyright  Oracle Corporation............................................................................

............... You have seen that navigation involves changing the location of the input focus on the screen.Understanding Internal Navigation .............. This logical navigation is also known as internal navigation...................................... you see the input focus in the first enterable item of the first navigation block........................................................................ However............. In addition to the visible navigation that occurs. you do not see the input focus moving................................................... These internal navigation events are as follows: • Entry to form • Entry to block • Entry to record • Entry to item Example When you commit your inserts.. some logical navigation takes place............ Oracle Forms Developer: Build Internet Applications I 19-11 ... Understanding Internal Navigation Navigation occurs when the user or a trigger causes the input focus to move to another object......................... internally the following navigation events must occur before commit processing begins: • Exit current item • Exit current record • Exit current block ........ You do not see the internal navigation events that must occur for the input focus to enter the first item........ updates.............. Example When you enter a form module................................ and deletes to the database.....

.. 2000....... Navigation Triggers ^ x Pre................................................................................................................... .......................................... All rights reserved....... All rights reserved... Navigation Triggers Pre....... 2000...and Post- When-New-“object”-Instance Fire during navigation Fire after navigation Does not fire if validation unit is higher than trigger object Does fire when validation unit is higher than the trigger object Allow unrestricted built-ins Allow restricted and unrestricted built-ins Handle failure by returning to initial object Are not affected by failure Copyright  Oracle Corporation.........Lesson 19: Navigation ..................................................... 19-12 Oracle Forms Developer: Build Internet Applications I ........................................and Post- v When-New-“object”-Instance Copyright  Oracle Corporation.....................

.... that is just before entry to or just after exit from the object specified as part of the trigger name.navigation triggers fire during navigation.. Example The When-New-Item-Instance trigger fires immediately after navigation to a new instance of an item........... Note: Be sure that Pre............... Pre-Block. Pre......................... ................ or Pre-Text-Item on entry to the form will cancel execution of the form..Navigation Triggers ............................... What Happens When a Navigation Trigger Fails? If a Pre....................and Post.......and Post-Text-Item triggers do not fire.............or Post-navigation trigger fails......... Oracle Forms Developer: Build Internet Applications I 19-13 ......................... if the validation unit is Record.............. failure of Pre-Form.........and Post-navigation triggers do not fire if they belong to a unit that is lower in the hierarchy than the current validation unit......................... Failure of a navigation trigger can cause a fatal error to your form.........and Post-navigation triggers display a message on failure.......................... To the user............ Navigation Triggers The navigation triggers can be subdivided into two general groups: • Pre........and Post. When Do Navigation Triggers Not Fire? The Pre.. When Do When-New-“object”-Instance Triggers Fire? The When-New-“object”-Instance triggers fire immediately after navigation to the object specified as part of the trigger name...... Pre-Record. For instance....... For example..and Post-Navigation Triggers Fire? The Pre....... the input focus returns to its initial location (where it was prior to the trigger firing)...........navigation triggers • When-New-“object”-Instance triggers When Do Pre... it appears that the input focus has not moved at all... Example The Pre-Text-Item trigger fires just before entering a text item..

........ ’S_ITEM’)........... STATUS.. QUERY_STATUS)....... 19-14 Oracle Forms Developer: Build Internet Applications I . ’stock’).... ’stock’)......................stock_button’..... SET_“object”_PROPERTY Examples SET_FORM_PROPERTY(FIRST_NAVIGATION_BLOCK.......................... ICON_NAME. ’S_ITEM’).......... SET_ITEM_PROPERTY(’CONTROL........ ORDER_BY..... QUERY_STATUS).... 2000. STATUS.Lesson 19: Navigation ..... ................................stock_button’.. All rights reserved............. 2000......... All rights reserved.......................... SET_RECORD_PROPERTY(3....... ’CUSTOMER_ID’).......... SET_BLOCK_PROPERTY(’S_ORD’.. SET_ITEM_PROPERTY(’CONTROL............. SET_RECORD_PROPERTY(3................. When-New-“object”-Instance Triggers • • • • When-New-Form-Instance When-New-Block-Instance When-New-Record-Instance When-New-Item-Instance Copyright  Oracle Corporation.. SET_FORM_PROPERTY(FIRST_NAVIGATION_BLOCK............................ Copyright  Oracle Corporation......... ’S_ITEM’................................... ICON_NAME... ’S_ITEM’.

.... by including the following code in your When-New-Form-Instance trigger: EXECUTE_QUERY............. IF GET_APPLICATION_PROPERTY(username) = ’SCOTT’ THEN SET_BLOCK_PROPERTY(’S_ITEM’........ Example The following example of a When-New-Block-Instance trigger conditionally sets the DELETE ALLOWED property to FALSE.... END IF........ you may want to check or set initial conditions when the input focus arrives in a particular block............. Using the When-New-“object”-Instance Triggers If you include complex navigation paths through your application........................... along with the SET_“object”_PROPERTY built-in subprograms to initialize Form Builder objects..DELETE_ALLOWED.................................................... Use the following triggers to do this: Trigger When-New-Form-Instance When-New-Block-Instance When-New-Record-Instance When-New-Item-Instance Fires Whenever Form Builder runs a form....................... ............... Example Perform a query of all orders.......................... PROPERTY_FALSE)..................... after successful navigation into a form After successful navigation into a block After successful navigation into the record After successful navigation to a new instance of the item Initializing Form Builder Objects Use the When-New-“object”-Instance triggers. when the ORDERS form is run......... Oracle Forms Developer: Build Internet Applications I 19-15 .................................................Using the When-New-“object”-Instance Triggers ............... or item....... record....... These triggers are particularly useful if you conditionally require a default setting.............

............. The Pre.................stock_button’..........................stock_button’....... 19-16 Oracle Forms Developer: Build Internet Applications I ........ Post-Block Trigger Example Disabling Stock_Button when leaving the S_ITEM block: SET_ITEM_PROPERTY(’CONTROL.... SET_ITEM_PROPERTY(’CONTROL....................................... property_false)............................... All rights reserved.......... .............................................. enabled..Lesson 19: Navigation ............ Instructor Note Ask the students what type of trigger you would use reenable the Stock_Button.. enabled........................ property_false). 2000.and Post-Triggers • • • • Pre/Post-Form Pre/Post-Block Pre/Post-Record Pre/Post-Text-Item Copyright  Oracle Corporation....................................... 2000...... All rights reserved........................ Copyright  Oracle Corporation.....

.

......... click the Display Messages check box........ a message displays.....fmb file contains navigation triggers defined at the form level..............Lesson 19: Navigation .......... and navigate through the form......... Run the file... 2000........................................................ The Navigation Trap ^ A Post-Text-Item Pre-Text-Item v B Pre-Text-Item Copyright  Oracle Corporation................................................................ 19-18 Oracle Forms Developer: Build Internet Applications I .... Use this demonstration to explain navigation triggers and the potential navigation trap..... All rights reserved.................. Instructor Note Demonstration The navigation.................. As each navigation trigger fires.............................. ...........................................................

.......or Post........................................................ The Navigation Trap You have seen that the Pre.......navigation triggers fire during navigation.........................................The Navigation Trap ....navigation trigger fails and attempts to return the logical cursor to its initial item... and when they fail the internal cursor attempts to return to the current item (SYSTEM.............. Oracle Forms Developer: Build Internet Applications I 19-19 ...and Post. This can occur when a Pre........ The diagram on the opposite page illustrates the navigation trap.......... However................................................................................................................... ..............CURSOR_ITEM).... Note: Be sure to code against navigation trigger failure.............. if the initial item has a Pre-Text-Item trigger that also fails the cursor has nowhere to go..... and a fatal error occurs........

......................... property_false).... property_false).....................date_shipped’)... UPDATE_ALLOWED..............date_shipped’........date_shipped’....order_filled’)THEN SET_ITEM_PROPERTY(’S_ORD........................ SET_ITEM_PROPERTY(’S_ORD............... GO_ITEM(’S_ORD.............. whereas the second incorrectly uses the Pre-Text-Item trigger and contains a restricted built-in... Copyright  Oracle Corporation.......... All rights reserved... Instructor Note Point out that the first example correctly uses the When-New-Item-Instance trigger..........order_filled’) THEN THEN SET_ITEM_PROPERTY(’S_ORD..... ..... 19-20 Oracle Forms Developer: Build Internet Applications I .. UPDATE_ALLOWED...................... END IF...date_shipped’)............... Navigation in Triggers • When-New-Item-Instance IF CHECKBOX_CHECKED(’S_ORD.......Lesson 19: Navigation ............. END END IF.............. GO_ITEM(’S_ORD.......date_shipped’....... UPDATE_ALLOWED............................ property_false)............. IF. 2000................... • Pre-Text-Item IF IF CHECKBOX_CHECKED(’S_ORD.......order_filled’) CHECKBOX_CHECKED(’S_ORD..

....................... Navigation in Triggers You can initiate navigation programmatically by calling the built-in subprograms............................................ primary key item Navigates to the first enterable item in the next record Fetches another set of records from the database and navigates to the first record that the fetch retrieves Navigates to the instance of the current item in the previous record Navigates to the instance of the current item in the next record Navigates to the previous enterable block Navigates to the previous enterable item Navigates to the previous record Scrolls the block so that the records above the top visible one display Scrolls the block so that the records below the bottom visible one display ........... such as GO_ITEM and PREVIOUS_BLOCK from triggers........................................ Oracle Forms Developer: Build Internet Applications I 19-21 ..................................................................... Built-in Routines for Navigation GO_FORM GO_BLOCK GO_ITEM GO_RECORD NEXT_BLOCK NEXT_ITEM NEXT_KEY NEXT_RECORD NEXT_SET UP DOWN PREVIOUS_BLOCK PREVIOUS_ITEM PREVIOUS_RECORD SCROLL_UP SCROLL_DOWN Function Navigates to an open form (in a multiple form application) Navigates to an indicated block Navigates to an indicated item Navigates to a specific record Navigates to the next enterable block Navigates to the next enterable item Navigates to the next enterable..................................................Navigation in Triggers ...................................................................

.. All rights reserved............................................ Summary • • • Controlling navigation through properties Internal navigation Navigation triggers – When-New-“object”-Instance – Pre– Post- • • Navigation trap Navigation in triggers Copyright  Oracle Corporation........ 2000................................................................................................... 19-22 Oracle Forms Developer: Build Internet Applications I ............... ..........................................................................................................................Lesson 19: Navigation ..............

..........Data block properties ... • Navigation triggers: ...................................Form module properties ..... • You can control navigation through the following properties: ....................Pre................................. Summary In this lesson.........Item properties • Internal navigation events also occur................................................and Post• Avoid the navigation trap............................................... Oracle Forms Developer: Build Internet Applications I 19-23 .........Summary ........................................When-New-“object”-Instance .............. you learned at the different methods of forcing visible navigation and also the invisible events........... • Navigation built-ins are available....... .....................

. Practice 19 Overview This practice covers the following topics: • • Executing a query at form startup Populating product images when cursor arrives on each record of the S_ITEM block Copyright  Oracle Corporation.................................... “Practice Solutions.................................................................................. see Practice 19 in Appendix A...... 2000.................................................................................Lesson 19: Navigation .. 19-24 Oracle Forms Developer: Build Internet Applications I .....................................” ............... Note For solutions to this practice....................................... All rights reserved........

.................................................. you use When-New-“object”-Instance triggers to populate the Product_Image item as the operator navigates between records in the ORDGXX form................................................... Also.... you provide a trigger to automatically perform query at form startup..................................................................Practice 19 Overview ............................................................................... • Executing a query at form startup • Populating product images when the cursor arrives on each record of the S_ITEM block ..... Oracle Forms Developer: Build Internet Applications I 19-25 ................................ Practice 19 Overview In this practice..................

....Lesson 19: Navigation ............image_id AND s_product............................... Get_Product_Image function is already created for you............... Practice 19 1 Write a When-New-Form-Instance trigger on the ORDGXX form to execute a query at form startup.. 4 Is there another trigger where you might also want to place this code? 5 Save and compile the form................................................... your trigger should pass this name to the READ_IMAGE_FILE built-in............. Use Get_Product_Image function for this purpose..... IF v_filename is null THEN v_filename := ’No file’. Use the EXECUTE_QUERY built-in.... END IF. if one exists......................................................id = s_product... END....... 2 Write a trigger that fires as the cursor arrives in each record of the S_ITEM block.......... .... EXCEPTION WHEN no_data_found THEN return(’No file’).” FUNCTION get_product_image (product_number IN NUMBER) RETURN VARCHAR2 IS v_filename VARCHAR2(20). 3 Define the same trigger type and code on the S_ORD block. This function returns the image file name for the given product number. and populate the Product_Image item with a picture of the product................... the function returns “No file...... If the function returns a usable filename......................filename INTO v_filename FROM s_image... Deploy the form on the Web to test...................id = product_number.... s_product WHERE s_image. RETURN v_filename............ This will display the image for the first line item’s product if the operator changes the displayed order...... If a file is not found........... BEGIN SELECT s_image. 19-26 Oracle Forms Developer: Build Internet Applications I ....

.....................20 ........ Transaction Processing ....

.................................................................................. All rights reserved............................... 2000.................................... you should be able to do the following: • Describe details of commit processing and commit triggers • Supplement transaction processing by using triggers • Allocate sequence numbers to records as they are applied to tables • Implement array DML Copyright  Oracle Corporation................... Objectives After completing this lesson............................................................................. Schedule Topic Lecture Practice Total Timing 90 minutes 30 minutes 120 minutes ....... 20-2 Oracle Forms Developer: Build Internet Applications I ..................Lesson 20: Transaction Processing ...................................

.................Introduction .............. ........................................................................................... This lesson shows you how to build triggers that can perform additional tasks during this stage of a transaction......................... Oracle Forms Developer: Build Internet Applications I 20-3 .... Form Builder enables you to make triggers fire in order to alter or add to the default behavior.............................................................................................................. Introduction Overview While applying a user’s changes to the database...........................................

................................................................ Transaction Processing FORM A Action Edit Transaction (Begin) Save Block#1 INSERT INSERT INTO INTO Table1 Table1 New Record Updated Record UPDATE UPDATE Table1 Table1 Block#2 Updated Record DELETE DELETE FROM FROM Table2 Table2 Deleted Record UPDATE UPDATE Table2 Table2 Transaction (End) Commit Commit work............................. All rights reserved........................Lesson 20: Transaction Processing ......................... 20-4 Oracle Forms Developer: Build Internet Applications I ..................... work............................................ 2000........................................................................................ ........ Copyright  Oracle Corporation...

.................................. making the changes permanent....... In either case.............. The built-in procedure POST alone can invoke this posting process.................. • The COMMIT_FORM built-in procedure is called from a trigger................. UPDATE................. deletes are performed first.. Transactional triggers fire during this cycle if defined by the designer.......... ................... or clicks on the Save button on the default Form toolbar............ using implicit INSERT................................. What Happens in Transaction Processing? The transaction process occurs as a result of either of the following actions: • The user presses Save or selects Action—>Save from the menu. The changes are applied in block sequence order as they appear in the Object Navigator at design time........ and DELETE statements generated by Form Builder.... For each block.................. This process includes: • Default Form Builder transaction processing: Applies the user’s changes to the base tables • Firing transactional triggers: Needed to perform additional or modified actions in the saving process defined by the designer When all of these actions are successfully completed............ the process involves two phases............................. posting and committing... Oracle Forms Developer: Build Internet Applications I 20-5 ...... followed by inserts and updates... making the applied changes permanent and releasing locks... Post Posting writes the user’s changes to the base tables. a process takes place involving events in the current database transaction............Transaction Processing ......... Transaction Processing When Form Builder is asked to save the changes made in a form by the user........... Form Builder commits the transaction............ Commit This performs the database commit.........

....... 20-6 Oracle Forms Developer: Build Internet Applications I ............. 2000.......................................... Transaction Processing Transaction processing includes two phases: • Post: – Writes record changes to base tables – Fires transactional triggers • Commit: Performs database commit Errors result in: • • Rollback of the database changes Error message Copyright  Oracle Corporation...................................................................................... All rights reserved.............................Lesson 20: Transaction Processing ... ............................................................................................................................

....... Rollbacks Form Builder will roll back applied changes to a savepoint if an error occurs in its default processing....... but certain built-ins......... database locks are automatically applied............ such as the EXIT_FORM built-in procedure.... By default....Transaction Processing ......... the user is informed of the error through a message............... and will roll back to the latest savepoint if certain events occur......................... and a failing insert or update results in the record being redisplayed. The user can then attempt to correct the error before trying to save again......... ...... and SAVEPOINT cannot be called from a trigger directly............... and ROLLBACK as the CLEAR_FORM built-in................................. Locks also apply during the posting phase of a transaction................ If encountered in a client-side program unit. Locking When you update or delete base table records in a form application. Savepoints Form Builder issues savepoints in a transaction automatically.................... Oracle Forms Developer: Build Internet Applications I 20-7 ................ ROLLBACK. Form Builder treats COMMIT as the COMMIT_FORM built-in......................... Note: The SQL statements COMMIT.......................... can request a rollback to the latest savepoint by using the TO_SAVEPOINT option............ these savepoints are for Form Builder internal use. Generally.......... or when a transactional trigger fails................... and for DML statements that you explicitly use in your code....................

........... 20-8 Oracle Forms Developer: Build Internet Applications I ........................................................ ........................... 2000.................... Copyright  Oracle Corporation...............Lesson 20: Transaction Processing .............................................................................................................................................................. All rights reserved.................

....... ..... ..Fire the Pre-Update trigger...............Delete the row from the base table or fire the On-Delete trigger.. 7 Fire the Post-Database-Commit trigger................................... ...Update the row in the base table or fire the On-Update trigger................. ...........The Commit Sequence of Events .............. For all inserted or updated records of the block in sequential order: If it is an inserted record: ........... ..... Oracle Forms Developer: Build Internet Applications I 20-9 .. 3 Fire the Pre-Commit trigger... If it is an updated record: ................Fire the Pre-Insert trigger........... ............................... 4 Validate the block (for all blocks in sequential order)... then: 6 Issue an SQL-COMMIT statement... For all deleted records of the block (in reverse order of deletion): . ... ...Check the record uniqueness ..Copy Value From Item........Check the record uniqueness...... ... The Commit Sequence of Events The commit sequence of events (when the Array DML size is 1) is as follows: 1 Validate the form.Insert the row into the base table or fire the On-Insert trigger........................ 2 Process savepoint................................................Fire the Post-Delete trigger...Fire the Post-Update trigger...Fire the Post-Insert trigger............. 5 Fire the Post-Forms-Commit trigger. If the current operation is COMMIT.............Fire the Pre-Delete trigger....

............ UPDATE_RECORD built-ins Copyright  Oracle Corporation....... .............................................. Characteristics of Commit Triggers • Pre-Commit: Fires once if form changes are made or uncommitted changes are posted • • Pre.......... 2000.... INSERT_RECORD..................................... Copyright  Oracle Corporation.......... All rights reserved.................................. Characteristics of Commit Triggers • Post-Forms-Commit: Fires once even if no changes are made • Post-Database-Commit: Fires once even if no changes are made Note: A commit-trigger failure causes a rollback to the savepoint....... replacing default DML on row Use DELETE_RECORD............................... 2000............. 20-10 Oracle Forms Developer: Build Internet Applications I ................ All rights reserved....................Lesson 20: Transaction Processing .............................................................and Post-DML On-DML: Fires per record....

.....and Post-DML On-DML Post-Forms-Commit Post-Database-Commit Characteristic Fires once during commit processing............................... even if there are no changes to post.................... Oracle Forms Developer: Build Internet Applications I 20-11 .................. UPDATE_RECORD...... or delete when Forms would typically issue its INSERT..............Characteristics of Commit Triggers ... This also means that earlier............. Include a call to the INSERT_RECORD.) Fire for each record that is marked for insert........... or delete......... Characteristics of Commit Triggers You have already seen when commit triggers fire during the normal flow of commit processing...... or DELETE_RECORD built-in to perform the default processing for these triggers..... update................. after the SQL-COMMIT statement is issued...... even fires if there are no changes to commit (This is also true for the SQL-COMMIT statement itself............... or deleted in the database Fires for each record that is marked for insert.. just before or after the row is inserted.......... before base table blocks are processed........... or DELETE statement (These triggers replace the DML statements........................... update.... Trigger Pre-Commit Pre.... UPDATE........ The following table gives more detailed information regarding the conditions under which these triggers fire.................. even fires if there are no changes to post or commit..... ... Fires once during commit processing................... updated. not yet committed posts are not rolled back.. the transaction is rolled back to the savepoint that was set at the beginning of the current commit processing...) Fires once during commit processing. fires if there are changes to base table items in the form or if changes have been posted but not yet committed (This trigger always fires in case of uncommitted posts...... after base table blocks are processed but before the SQL-COMMIT statement is issued.........) Note: If a commit trigger—except for the Post-Database-Commit trigger—fails..................

............................ auto-generated columns..... All rights reserved...............Lesson 20: Transaction Processing . check constraints Pre-Update Journaling................................. check constraints Copyright  Oracle Corporation............ implement foreign-key update rule............................ All rights reserved. 20-12 Oracle Forms Developer: Build Internet Applications I .................................. implement foreign-key delete rule Pre-Insert Generate sequence numbers.......... ........... Commit Triggers Uses On-Insert/Update/Delete Replace default block DML statements Post-Forms-Commit Check complex multirow constraints Post-Database-Commit Test commit success........................... automatically generated columns............. test uncommitted posts Copyright  Oracle Corporation..................... journaling.......... Commit Triggers Uses Pre-Commit Check user authorization. 2000......................... 2000............ set up special locking Pre-Delete Journaling.............................

.

.................................................................................................. Life of an Update Query Item 20 Column Rollback Locked Data 20 30 20 [Save] 30 20 Pre-Update 30 20 Row Updated updated 30 30 20 Post-Update 30 30 20 Update record in form Commit 30 30 Copyright  Oracle Corporation............ 20-14 Oracle Forms Developer: Build Internet Applications I ............................................................................... 2000..................................... All rights reserved......... ..............................................................Lesson 20: Transaction Processing .......

.

...................... ELSE CLOSE C1... a local PL/SQL variable could be used rather than a global variable....... Copyright  Oracle Corporation................ RAISE form_trigger_failure.Lesson 20: Transaction Processing ... a PL/SQL variable ceases to exist...............................................id..dummy........................ END........................ Instructor Note In the example above........................... ............ 2000... A global variable exists for the session........ END IF................................. Delete Validation • • Pre-Delete trigger Final checks before row deletion DECLARE CURSOR C1 IS SELECT ’anything’ FROM S_ORD WHERE customer_id = :S_CUSTOMER.............. MESSAGE(’There are orders for this customer!’)........ All rights reserved.... FETCH C1 INTO :GLOBAL.................... BEGIN OPEN C1............... 20-16 Oracle Forms Developer: Build Internet Applications I . IF C1%FOUND THEN CLOSE C1... When the block terminates.......................

.

..Lesson 20: Transaction Processing .......... Insert Pre-Insert ID 601 6 60 Value Value 01 2 Database 602 Sequence Copyright  Oracle Corporation...... shown above.... All rights reserved.............................. 2000...dual........................... • Generate and run to show effects...id SYS.......nextval :S_ORD........nextval S_ORD_ID..... in the S_ORD block.................................. Assigning Sequence Numbers SELECT SELECT INTO INTO FROM FROM S_ORD_ID.................................................................... SYS....dual...................... 20-18 Oracle Forms Developer: Build Internet Applications I .....id :S_ORD.... Instructor Note Demonstration In the demonstration form that you are building: • Create the Pre-Insert trigger................................................................... noting that the assigned sequence number appears when the new record is saved... .....

.

...................... Post-Insert example: :GLOBAL................... TO_CHAR(TO_NUMBER(:GLOBAL.......................... All rights reserved.................... Gather statistics on applied changes.................................. 2000. Copyright  Oracle Corporation....insert_tot)+1)........insert_tot)+1)..................... Keeping an Audit Trail • • Write changes to nonbase tables.............................................................................insert_tot :GLOBAL.......... 20-20 Oracle Forms Developer: Build Internet Applications I .....Lesson 20: Transaction Processing ........................................... ......insert_tot := := TO_CHAR(TO_NUMBER(:GLOBAL................

........................... which is recorded in the global variable INSERT_TOT............ Example This Post-Update trigger writes the current record ID to the UPDATE_AUDIT table..Common Uses for Commit Triggers ........ ...... If the base table changes are committed at the end of the transaction.................... this may involve duplicating inserts or updates in backup history tables... SYSDATE........... INSERT INTO update_audit (id.............................................................................. Example This Post-Insert trigger adds to a running total of Inserts for the transaction........................ In some cases..................... USER )........ or recording statistics each time a DML operation occurs...id... Keeping an Audit Trail You may want to use the Post event transactional triggers to record audit information about the changes applied to base tables............ timestamp................. along with a time stamp and the user who performed the update.. Oracle Forms Developer: Build Internet Applications I 20-21 .............. who_did_it) VALUES ( :S_ORD.........insert_tot := TO_CHAR(TO_NUMBER(:GLOBAL. :GLOBAL..................insert_tot)+1).................. the audit information will also be committed...

.......... Copyright  Oracle Corporation.................... Testing the Result of Trigger DML • • • SQL%FOUND SQL%NOTFOUND SQL%ROWCOUNT UPDATE S_ORD SET date_shipped = SYSDATE WHERE id = :S_ORD................ ..................................................................................... 2000...... RAISE form_trigger_failure................id................................. 20-22 Oracle Forms Developer: Build Internet Applications I ..................................... All rights reserved.. IF SQL%NOTFOUND THEN MESSAGE(’Record not found in database’)......................... END IF......Lesson 20: Transaction Processing .....................................................

.

.....) base_table base_column = :base_item............................. 2000................... Copyright  Oracle Corporation............. All rights reserved...) (:base_item.... base_column = :base_item............................. DML Statements Issued During Commit Processing Rules: • • • DML statements may fire database triggers...... The Update Changed Columns Only and Enforce Column Security properties affect UPDATE statements......Lesson 20: Transaction Processing .......... 20-24 Oracle Forms Developer: Build Internet Applications I ....................... base_column............................................... :base_item.. ............... ............................ • Locking statements are not issued............. DML Statements Issued During Commit Processing INSERT INTO base_table VALUES UPDATE SET WHERE (base_column................... 2000...... Form Builder uses and retrieves ROWID............... ROWID = :ROWID DELETE FROM base_table WHERE ROWID = :ROWID Copyright  Oracle Corporation..... .................. All rights reserved...........

.

........................ All rights reserved.................................................................................... Instructor Note The above transactional triggers are meant to be used when connecting to data sources other than Oracle..................................... 20-26 Oracle Forms Developer: Build Internet Applications I .. 2000...................... Overriding Default Transaction Additional transactional triggers: Trigger Do-the-Right-Thing Built-in On-Check-Unique CHECK_RECORD_UNIQUENESS On-Column-Security ENFORCE_COLUMN_SECURITY On-Commit COMMIT_FORM On-Rollback ISSUE_ROLLBACK On-Savepoint ISSUE_SAVEPOINT On-Sequence-Number GENERATE_SEQUENCE_NUMBER Copyright  Oracle Corporation...... ...............................................................................................................................Lesson 20: Transaction Processing ...

............. Oracle Forms Developer: Build Internet Applications I 20-27 .......................... Additional Transactional Triggers for Commit Processing Trigger On-Check-Unique On-Column-Security On-Commit On-Rollback On-Savepoint On-Sequence-Number Do-the-Right-Thing Built-in CHECK_RECORD_UNIQUENESS ENFORCE_COLUMN_SECURITY COMMIT_FORM ISSUE_ROLLBACK ISSUE_SAVEPOINT GENERATE_SEQUENCE_NUMBER ...........Overriding Default Transaction Processing ........................................................ Other examples include triggers that fire during logon and logout or during queries performed on the data source............ Overriding Default Transaction Processing You have already seen that some commit triggers can be used to replace the default DML statements that Form Builder issues during commit processing....................................................... You can use several other triggers to override the default transaction processing of Form Builder.............. Commit triggers form a subset of these triggers.................................................................................... Transactional Triggers All triggers that are related to accessing a data source are called transactional triggers...................................

.......................................... 20-28 Oracle Forms Developer: Build Internet Applications I ................................................................... All rights reserved................ but those covered on this and the previous slides are the most important................................................ 2000.Lesson 20: Transaction Processing ............. Overriding Default Transaction Transactional triggers for logging on and off: Trigger Do-the-Right-Thing Built-in Pre-Logon - Pre-Logout - On-Logon LOGON On-Logout LOGOUT Post-Logon - Post-Logout - Copyright  Oracle Corporation.......................... ..................... Instructor Note There are more transactional triggers........................................................................

................ Transactional Triggers for Logging On and Off Trigger Pre-Logon Pre-Logout On-Logon On-Logout Post-Logon Post-Logout Do-the-Right-Thing Built-in LOGON LOGOUT - Uses for Transactional Triggers • Transactional triggers...................................................... except for the commit triggers........................................ ......................................................Overriding Default Transaction Processing ................. • The logon and logoff transactional triggers can also be used with Oracle databases to change connections at run time................ Oracle Forms Developer: Build Internet Applications I 20-29 .................... are primarily intended to access certain data sources other than Oracle........................................................................................

........................ Running with Data Sources Other than Oracle • Three ways to run against data sources other than Oracle: – Oracle Open Gateways – Oracle Open Client Adapter for ODBC – Write appropriate transactional triggers Copyright  Oracle Corporation........ 2000............. All rights reserved................................................................................................................................................... 20-30 Oracle Forms Developer: Build Internet Applications I .......... Running with Data Sources Other than Oracle • Connecting with Open Gateway: – Cursor and Savepoint mode form module properties – Key mode and Locking mode block properties • Using transactional triggers: – Call 3GL programs – Database data block property Copyright  Oracle Corporation........................ 2000..............................Lesson 20: Transaction Processing ....................... All rights reserved.......................... ..

............... Setting this property to Yes ensures that transactional triggers will fire for the block..... you must call 3GL programs that implement the access to the data source...... If you set this property to Yes..................Running Against Data Sources Other than Oracle ........................ .......... • Use Oracle Open Client Adapter for ODBC............... you must define all On-Event transactional triggers.. that is.................................. you must define transactional triggers.......... even though it is not a base table block...... • Write the appropriate set of Transactional triggers........... Database Data Block Property This block property identifies a block as a transactional control block.. From these triggers.............................. otherwise you will get an error during form generation..... you should be aware of these transactional properties: • Cursor mode form module property • Savepoint mode form module property • Key mode block property • Locking mode block property You can set these properties to specify how Form Builder should interact with your data source............... Running Against Data Sources Other than Oracle Three Ways to Run Against Data Sources Other than Oracle • Use Oracle Open Gateway products............... Connecting with Open Gateway When you connect to a data source other than Oracle with an Open Gateway product................................................................................. a control block that should be treated as a base table block..... The specific settings depend on the capabilities of the data source... Using Transactional Triggers If no Open Gateway or Open Client Adapter drivers exist for your data source..... Oracle Forms Developer: Build Internet Applications I 20-31 ..

....... 20-32 Oracle Forms Developer: Build Internet Applications I ...........................................Lesson 20: Transaction Processing ....... All rights reserved............................................................................................................................ ............................RECORD_STATUS: – NEW – INSERT (also caused by control items) – QUERY – CHANGED Copyright  Oracle Corporation............................... 2000..................... Getting and Setting the Commit Status • • What is commit status? SYSTEM............................................

..................................) Indicates that the record corresponds to a row in the database........ The Four Values of SYSTEM...... it is often useful to know if the record is in the database or if it has been changed............... and so on............ Note that when you change a control item of a NEW record..... the record can be inserted........... updated....................................... For example. the record status also becomes INSERT............. but that none of its items have been changed yet (The record may have been populated by default values....... Oracle Forms Developer: Build Internet Applications I 20-33 ....................) Indicates that one or more of the items in a newly created record have been changed (The record will be processed as an insert during the next commit process if its block has the CHANGED status....) ..Getting and Setting the Commit Status .................................. What Is the Commit Status of a Record? The commit status of a record of a base table block determines how the record will be processed during the next commit process......RECORD_STATUS Value NEW INSERT QUERY CHANGED Description Indicates that the record has been created.... or not processed at all................. but that none of its base table items have been changed Indicates that one or more base table items in a database record have been changed (The record will be processed as an update (or delete) during the next commit process............... see below...................... Getting and Setting the Commit Status If you want to process a record in your form...................................... You can use system variables and built-ins to obtain this information......

.................................................... ..... 2000.....BLOCK_STATUS: – NEW (may contain records with status INSERT) – QUERY (also possible for control block) – CHANGED (block will be committed) Copyright  Oracle Corporation.................Lesson 20: Transaction Processing .... 20-34 Oracle Forms Developer: Build Internet Applications I ........................... Getting and Setting the Commit Status • SYSTEM.......................................................................................... All rights reserved...........FORM_STATUS: – NEW – QUERY – CHANGED Copyright  Oracle Corporation..... Getting and Setting the Commit Status • SYSTEM................................................................................. 2000........ All rights reserved....

.. Oracle Forms Developer: Build Internet Applications I 20-35 ............... Indicates that all records of the block have the status QUERY if the block is a base table block (A control block has the status QUERY if it contains at least one record with the status INSERT................................................................. Three Values of SYSTEM...........................FORM_STATUS Value NEW QUERY CHANGED Description Indicates that all blocks of the form have the status NEW Indicates that at least one block of the form has status QUERY and all other blocks have the status NEW Indicates that at least one block of the form has the status CHANGED .................................................................) Indicates that the block contains at least one record with the status INSERT or CHANGED if the block is a base table block (The block will be processed during the next commit process.............Getting and Setting the Commit Status .......................................BLOCK_STATUS Value NEW QUERY CHANGED Description Indicates that all records of the block have the status NEW (Note that a base table block with the status NEW may also contain records with the status INSERT caused by changing control items).............. Note that a control block cannot have the status CHANGED......................................) Three Values of SYSTEM.............................

........ 20-36 Oracle Forms Developer: Build Internet Applications I ... Getting and Setting the Commit Status • Example: If the third record of block S_ORD is a changed database record............................................. ................................................. Copyright  Oracle Corporation..... 2000............ All rights reserved.... Getting and Setting the Commit Status • System variables versus built-ins for commit status • Built-ins for getting and setting commit status: – GET_BLOCK_PROPERTY – GET_RECORD_PROPERTY – SET_ RECORD _PROPERTY Copyright  Oracle Corporation............................. – The commit status is updated during validation............................ All rights reserved................................ set the status back to QUERY.......Lesson 20: Transaction Processing .............................................. 2000... • Warnings: – Do not confuse commit status with validation status........................................

........... query_status). ’S_ORD’.......status)= ’CHANGED’ THEN SET_RECORD_PROPERTY(3........ INSERT_STATUS QUERY_STATUS CHANGED_STATUS Example If the third record of the S_ORD block is a changed database record.............................................. Oracle Forms Developer: Build Internet Applications I 20-37 ..... BEGIN IF GET_RECORD_PROPERTY(3............. status..............................RECORD_STATUS and SYSTEM........ Built-in GET_BLOCK_PROPERTY GET_RECORD_PROPERTY SET_RECORD_PROPERTY Description Use the STATUS property to obtain the block status of the specified block.................. Using Built-ins to Get the Commit Status The system variables SYSTEM..... set the status back to QUERY. END IF................................ Use the STATUS property to obtain the record status of the specified record in the specified block............... END................................... You can use built-ins to obtain the status of other blocks and records....... ....................BLOCK_STATUS apply to the record and block where the cursor is located........ ’S_ORD’.......................Getting and Setting the Commit Status ..... Set the STATUS property of the specified record in the specified block to one of the following constants: • • • NEW_STATUS....................

20-38 Oracle Forms Developer: Build Internet Applications I .... ......................... All rights reserved.. updates...... delete Fires for each insert........... delete Array DML Size > 1 Copyright  Oracle Corporation............ delete PREFires DML DML POST- POSTFires Array DML Size = 1 Fires for each insert......................................... update..... Array DML • • Performs array inserts.................Lesson 20: Transaction Processing ............... 2000............ Effect of Array DML on Transactional Triggers PRERepeated for each insert..................... All rights reserved................................................................................... update....... 2000........ update.......................... and deletes Vastly reduces network traffic Empno Ename Job Hiredate Fewer round trips (exact number depends on array size) 1234 Jones Clerk 01-Jan-1995 2 inserts 1235 Smith Clerk 01-Jan-1995 2 updates 1236 Adams Clerk 01-Jan-1995 1 delete 1237 Clark Clerk 01-Jan-1995 Database Copyright  Oracle Corporation....................

..........triggers fire. Array Processing Overview Array processing is an option in Form Builder that alters the way records are processed...... With DML Array Size set to greater than 1... For both querying and DML operations.............. .............triggers...... and 100 Post.... views..... changed.. Array processing is available for query and DML operations for blocks based on tables.. procedures...... all of the DML statements are issued.....Array Processing ..... and Pre-Delete triggers fire for each new... you get 100 Pre.......... a large array size might result in records being broken into multiple packets. The default behavior of Form Builder is to process records one at a time....... and all of the Post.................. the DML is issued.. Oracle Forms Developer: Build Internet Applications I 20-39 . the appropriate Pre. the Pre-Insert.........triggers fire for all of the new.....triggers............ and deleted record...... you can process groups of records at a time.............. With array processing....... This lesson focuses on array DML processing........................ it is not supported for blocks based on transactional triggers.......... If you change 100 rows and DML Array Size is 20.... Instructor Note Some students may ask why DML Array Size is not always set to a very large number...... reducing network traffic and thereby increasing performance... Effect of Array DML on Transactional Triggers With DML Array Size set to 1. and the Post... 5 arrays of 20 DML statements... you can determine the array size to optimize performance for your needs............... If each record is very large................... By enabling array processing........... and deleted rows......trigger for that record fires..... you overwrite default transaction processing and cancel array processing.... If you write On-DML triggers. Form Builder supports both array fetch processing and array DML processing...... a structure (an array) containing multiple records is sent to or returned from the server for processing.......... Pre-Update........... There is a point of diminishing return............. changed.. and subqueries...........

. All rights reserved................................ .....................Lesson 20: Transaction Processing ............................... 2000......................... Specify a DML Array Size of greater than 1............ 20-40 Oracle Forms Developer: Build Internet Applications I .............................. Copyright  Oracle Corporation................................ Specify block primary keys........................................... 3........... 2... Enable the Array Processing option.............................................................. Implementing Array DML 1.......

... you must specify the primary key......In the Object Navigator.............. ................. .................................... select the Data Blocks node........Select the Array Processing check box...Select Tools—>Preferences......... You can also set this property programmatically................... If you update a record in the same session that you inserted it...... Note: When the DML Array Size property is greater than 1..............Double-click the Data Blocks icon to display the Property Palette.......... the server locks the record by using the primary key............................. except after an array insert.Under the Advanced Database category......................................... The Oracle server uses the ROWID to identify the row..........Array Processing . How to Implement Array DML 1 To set preferences: ............ Key mode can still be unique.... ................ Oracle Forms Developer: Build Internet Applications I 20-41 ... .......... ................Click the Runtime tab.. 2 To set properties: ............. set the DML Array Size property to a number that represents the number of records in the array for array processing....................

................................................................. ........ 2000..................... 20-42 Oracle Forms Developer: Build Internet Applications I ....................Lesson 20: Transaction Processing ............................................. Summary • • • Post and commit phases • Characteristics and common uses of commit triggers • • • Overriding default transaction processing Flow of commit processing DML statements issued during commit processing Getting and setting the commit status Implementing Array DML Copyright  Oracle Corporation......... All rights reserved........................................................................................................................................

..UPDATE and DELETE statements use ROWID by default • Characteristics of commit triggers: ........................ and Post-Insert............... Update..The Pre-............... Oracle Forms Developer: Build Internet Applications I 20-43 ...............Built-ins • Array DML ...........................Transactional On-Event triggers and “Do-the-Right-Thing” built-ins ........... set up special locking requirements..... check complex constraints......................... but consider uncommitted changes or posts.................. replace default DML statements issued by Form Builder... ODBC....Commit: Commits the database transaction • Flow of commit processing • DML statements issued during commit processing: ...The Pre-Commit.................Summary ...... • Transactions are processed in two phases: ................... generate sequence numbers. • Overriding default transaction processing: ...Post: Applies form changes to the base tables and fires transactional triggers ............................... • Common uses for commit triggers: check authorization............. On-...... or transactional triggers • Getting and setting the commit status: .... and Delete triggers fire once per processed record...... Post-Forms-Commit......................... .............. Summary This lesson showed you how to build triggers that can perform additional tasks during the save stage of a current database transaction.Based on base table items .Data sources other than Oracle use Open Gateway.....System variables ... and Post-Database-Commit triggers fire once per commit process....

... All rights reserved...... 20-44 Oracle Forms Developer: Build Internet Applications I ..........................” ........................................................ Note For solutions to this practice..................................... “Practice Solutions................................................................................... 2000................. see Practice 20 in Appendix A........................................Lesson 20: Transaction Processing ................................ Practice 20 Overview This practice covers the following topics: • Automatically populating order IDs by using a sequence • Automatically populating item IDs by adding the current highest order ID • Customizing the commit messages in the CUSTOMERS form • Customizing the login screen in the CUSTOMERS form Copyright  Oracle Corporation.......

............................... you add transactional triggers to the ORDGXX form to automatically provide sequence numbers to records at save time.Practice 20 Overview .................................................................................................................................................................................... You also customize commit messages and the login screen in the CUSTGXX form................. Oracle Forms Developer: Build Internet Applications I 20-45 ........... • Automatically populating order IDs by using a sequence • Automatically populating item IDs by adding the current highest order ID • Customizing the commit messages in the CUSTOMERS form • Customizing the login screen in the CUSTOMERS form ...... Practice 20 Overview In this practice..........................................................

.DELETE.. The unique ID for the order should appear when you save it..... ........... Instructor Note Solution 20:4 is not the safest way............. updates................. and deletes... In the S_ORD block............ Post-Update.......................... but this solution is too advanced at this stage..... Perform the action in a Pre-Insert trigger........... and run the form to test. set the Enabled property of the ID item to No...Id with the next value from the S_ORD_ID sequence......... then save it...... and GLOBAL......... If an exception occurs in the trigger...... compile. Create three global variables called GLOBAL. Set the Required and Enabled properties to No for Item_Id....... The better solution is to keep the total number of rows in another table that you can lock................ Deploy the form on the Web to test.. fail the trigger with a message. Insert a new line-item record in the S_ITEM block...............INSERT................. Derive this number by adding to the current highest Item_Id for the order............ 20-46 Oracle Forms Developer: Build Internet Applications I ..... You need to write Post-Insert..... Create a Pre-Insert trigger that assigns a value from this sequence... GLOBAL.....Lesson 20: Transaction Processing ............. write a transactional trigger on the S_ORD block 2 3 4 5 that populates S_ORD. 6 Open the CUSTGXX form module.......... Practice 20 1 In the ORDGXX form.......................UPDATE... Save and compile the form. These variables indicate respectively the number of inserts........................ Create a similar trigger on the S_ITEM block that assigns the Item_Id when a new record is saved..... Insert a new order. Save......................... and Post-Delete triggers to initialize and increment the value of each global variable..

............. DEFAULT_VALUE( ’0’............... Pass the message code and FALSE.... Practice 20 (continued) 7 Create a procedure called HANDLE_MESSAGE. Write an On-Logon trigger to control the number of connection tries........ ’GLOBAL. PROCEDURE handle_message( message_number IN NUMBER.............. ’|| :GLOBAL........... ELSE MESSAGE( MESSAGE_TEXT )....................................................delete’ ). DEFAULT_VALUE( ’0’.update’ ).. ’GLOBAL...delete || ’records deleted !!!’ )... Use the LOGON_SCREEN built-in to simulate the default login screen and LOGON to connect to the database... Call the procedure when a message occurs...insert’ )..............txt file.................... ........ 8 Open the CUSTGXX form module..............Practice 20 ..... Pass the error code and TRUE....... IS_ERROR IN BOOLEAN ) IS BEGIN IF message_number IN ( 40400....... END .... and the second is a Boolean error indicator............ 40406.. You can import the pr20_11...txt file...update || ’records updated......... This procedure uses the three global variables to display a customized commit message and then erases the global variables...insert || ’records inserted.. Oracle Forms Developer: Build Internet Applications I 20-47 ................ ELSIF is_error = TRUE THEN MESSAGE(’ERROR: ’|| ERROR_TEXT ). Import the pr20_10..... ’|| :GLOBAL......... ’GLOBAL....... The first one is a message number............ END IF.......... This procedure receives two arguments..... 40407 ) THEN DEFAULT_VALUE( ’0’... MESSAGE('Save Ok: ' || :GLOBAL........... Call the procedure when an error occurs............

.1.......... un := GET_APPLICATION_PROPERTY( USERNAME )................................................................... pw VARCHAR2(30)... FALSE )......... ’DEFAULT’)..... 20-48 Oracle Forms Developer: Build Internet Applications I .. END IF...... ..... END LOOP............ pw || ’@’ || cs...... WHILE connected = FALSE and tries > 0 LOOP LOGON_SCREEN...... On-Logon at Form Level DECLARE connected BOOLEAN := FALSE.............. BEGIN SET_APPLICATION_PROPERTY(CURSOR_STYLE... IF NOT CONNECTED THEN MESSAGE(’Too many tries!’)... END... END IF............................ IF FORM_SUCCESS THEN connected := TRUE ............................... cs := GET_APPLICATION_PROPERTY( CONNECT_STRING ).......... tries := tries .... tries NUMBER := 3.................... pw := GET_APPLICATION_PROPERTY( PASSWORD )........ RAISE FORM_TRIGGER_FAILURE................. cs VARCHAR2(30)........................ LOGON( un.........Lesson 20: Transaction Processing ............ un VARCHAR2(30)......

......21 .. Writing Flexible Code .........................

...................................................................................................... 21-2 Oracle Forms Developer: Build Internet Applications I . Objectives After completing this lesson.................................... you should be able to do the following: • • • Describe flexible code • • Write code to reference objects by internal ID State the advantages of using system variables Identify built-in subprograms that assist flexible coding Write code to reference objects indirectly Copyright  Oracle Corporation...................................................Lesson 21: Writing Flexible Code ............... All rights reserved................ Schedule Topic Lecture Practice Total Timing 50 minutes 30 minutes 80 minutes ....................... 2000.............................................................

....................................................................................... Introduction Overview Form Builder has a variety of features that enable you to write code in a flexible.............................Introduction ................................................................................................................. ............................................................... reusable way...... Oracle Forms Developer: Build Internet Applications I 21-3 .....

.. Flexible Code • • • • • Is reusable code Is generic code Avoids hard-coded object names Makes maintenance easier Increases productivity Copyright  Oracle Corporation...................................................................................................................................................... ... All rights reserved.......... 2000........................................................ 21-4 Oracle Forms Developer: Build Internet Applications I .................................................Lesson 21: Writing Flexible Code ..................................

................... Oracle Forms Developer: Build Internet Applications I 21-5 .............What Is Flexible Code? ...................... ................................................................................................................ It typically includes the use of system variables instead of hard-coded object names.. • It increases productivity................. Flexible code is often generic code that you can use in any form module in an application.................................................. Why Write Flexible Code? Writing flexible code gives you the following advantages: • It is easier for you and others to maintain.................... What Is Flexible Code? Flexible code is code that you can use again...................................................

...TRIGGER_ITEM Copyright  Oracle Corporation......... 2000............CURSOR_RECORD – SYSTEM..................CURSOR_ITEM – SYSTEM.. 21-6 Oracle Forms Developer: Build Internet Applications I ........ 2000......... System Variables for Current Context • Input focus: – SYSTEM....................................................TRIGGER_BLOCK – SYSTEM........................................ System Variables for Current Context • Trigger focus: – SYSTEM....................CURSOR_BLOCK – SYSTEM......... All rights reserved...................Lesson 21: Writing Flexible Code ................TRIGGER_RECORD – SYSTEM.....................................................CURSOR_VALUE Copyright  Oracle Corporation. ................... All rights reserved........................

Using System Variables for Flexible Coding
......................................................................................................................................................

Using System Variables for Flexible Coding
In this lesson, you use the system variables that provide the current status of the
record, the block, and the form, as well as system variables that return the current input
focus location.
System Variables for Locating Current Input Focus
System Variable
CURSOR_BLOCK
CURSOR_RECORD
CURSOR_ITEM
CURSOR_VALUE

Function
Determines which block has the input focus
Determines which record has the input focus
Determines which item in which block has the input focus
Determines the value of the item with the input focus

System Variables for Locating Trigger Focus
System Variable
TRIGGER_BLOCK
TRIGGER_RECORD
TRIGGER_ITEM

Function
Determines the block that the input focus was in when the
trigger initially fired
Determines the number of the record that Form Builder is
processing
Determines the block and item that the input focus was in
when the trigger initially fired

Note: The best way to learn about system variables is to look at their values when a
form is running. You can examine the system variables by using the Debugger.
Instructor Note
SYSTEM.CURRENT_BLOCK, SYSTEM.CURRENT_FORM,
SYSTEM.CURRENT_ITEM, and SYSTEM.CURRENT_VALUE are included for
compatibility with earlier versions (version 3.0 and earlier) of Forms.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
21-7

Lesson
21: Writing Flexible Code
......................................................................................................................................................

System Status Variables
When-Button-Pressed
ENTER;
ENTER;
IF
IF :SYSTEM.BLOCK_STATUS
:SYSTEM.BLOCK_STATUS == ’CHANGED’
’CHANGED’ THEN
THEN
COMMIT_FORM;
COMMIT_FORM;
END
END IF;
IF;
CLEAR_BLOCK;
CLEAR_BLOCK;
IF
IF :SYSTEM.CURSOR_BLOCK
:SYSTEM.CURSOR_BLOCK == ’S_ORD’
’S_ORD’ THEN
THEN
GO_BLOCK(’S_ITEM’);
GO_BLOCK(’S_ITEM’);
ELSIF
ELSIF :SYSTEM.CURSOR_BLOCK
:SYSTEM.CURSOR_BLOCK == ’S_ITEM’
’S_ITEM’ THEN
THEN
GO_BLOCK(’S_INVENTORY’);
GO_BLOCK(’S_INVENTORY’);
ELSIF
ELSIF :SYSTEM.CURSOR_BLOCK
:SYSTEM.CURSOR_BLOCK =’S_INVENTORY’
=’S_INVENTORY’ THEN
THEN
GO_BLOCK(’S_ORD’);
GO_BLOCK(’S_ORD’);
END
END IF;
IF;
Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note
Explain that the first example performs a commit before clearing a block if there are
changes to commit within that block.
Explain that the second example is a form-level trigger code for testing the current
block name and then navigating depending on the result.

......................................................................................................................................................
21-8
Oracle Forms Developer: Build Internet Applications I

Using System Variables for Flexible Coding
......................................................................................................................................................

System Variables for Determining the Current Status of the Form
You can use these system status variables to write code that performs one action for
one particular status and a different action for another.
SYSTEM.RECORD_STATUS
CHANGED
INSERT
NEW
QUERY

SYSTEM.BLOCK_STATUS
CHANGED
NEW
QUERY
SYSTEM.FORM_STATUS
CHANGED
NEW
QUERY

Description
The record was fetched from the database, and a base table
item on the record has been updated.
The user (or a trigger) has entered a value into a base table
item of a nonfetched record.
The user (or a trigger) has not yet entered any values into
the base table items of the record.
The record was fetched from the database, but no base
table item on the record has been updated.
Description
The block contains at least one record with a status of
CHANGED or INSERT.
The block contains only NEW records.
The block contains only QUERY records.
Description
The form contains at least one record with a status of
CHANGED or INSERT.
The form contains only NEW records.
The form contains only QUERY records.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
21-9

Lesson
21: Writing Flexible Code
......................................................................................................................................................

GET_object_PROPERTY
Built-Ins






GET_APPLICATION_PROPERTY
GET_FORM_PROPERTY
GET_BLOCK_PROPERTY
GET_RELATION_PROPERTY
GET_RECORD_PROPERTY
GET_ITEM_PROPERTY
GET_ITEM_INSTANCE_PROPERTY

Copyright  Oracle Corporation, 2000. All rights reserved.

GET_object_PROPERTY
Built-Ins






GET_LOV_PROPERTY
GET_RADIO_BUTTON_PROPERTY
GET_MENU_ITEM_PROPERTY
GET_CANVAS_PROPERTY
GET_TAB_PAGE_PROPERTY
GET_VIEW_PROPERTY
GET_WINDOW_PROPERTY

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
21-10
Oracle Forms Developer: Build Internet Applications I

Using Built-in Subprograms for Flexible Coding
......................................................................................................................................................

Using Built-in Subprograms for Flexible Coding
Some of Form Builder built-in subprograms provide the same type of run-time status
information that built-in system variables do.
GET_APPLICATION_PROPERTY
The GET_APPLICATION_PROPERTY built-in returns information about the current
Form Builder application.
Example
The following example captures the username and operating system information:
:GLOBAL.username := GET_APPLICATION_PROPERTY(USERNAME);
:GLOBAL.o_sys := GET_APPLICATION_PROPERTY(OPERATING_SYSTEM);

GET_BLOCK_PROPERTY
The GET_BLOCK_PROPERTY built-in returns information about a specified block.
Example
To determine the current record that is visible at the first (top) line of a block:
...GET_BLOCK_PROPERTY(’blockname’,top_record)...

GET_ITEM_PROPERTY
The GET_ITEM_PROPERTY built-in returns information about a specified item.
Example
To determine the canvas that the item with the input focus displays on, use:
DECLARE
cv_name varchar2(30);
BEGIN
cv_name := GET_ITEM_PROPERTY(:SYSTEM.CURSOR_ITEM,item_canvas);
...

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
21-11

Lesson
21: Writing Flexible Code
......................................................................................................................................................

SET_object_PROPERTY
Built-Ins






SET_APPLICATION_PROPERTY
SET_FORM_PROPERTY
SET_BLOCK_PROPERTY
SET_RELATION_PROPERTY
SET_RECORD_PROPERTY
SET_ITEM_PROPERTY
SET_ITEM_INSTANCE_PROPERTY

Copyright  Oracle Corporation, 2000. All rights reserved.

SET_object_PROPERTY
Built-Ins






SET_LOV_PROPERTY
SET_RADIO_BUTTON_PROPERTY
SET_MENU_ITEM_PROPERTY
SET_CANVAS_PROPERTY
SET_TAB_PAGE_PROPERTY
SET_VIEW_PROPERTY
SET_WINDOW_PROPERTY

Copyright  Oracle Corporation, 2000. All rights reserved.

Instructor Note
Use SET_ITEM_PROPERTY to change fonts and colors directly. Use the
SetFontDemo.fmb file.

......................................................................................................................................................
21-12
Oracle Forms Developer: Build Internet Applications I

Using Built-in Subprograms for Flexible Coding
......................................................................................................................................................

SET_ITEM_INSTANCE_PROPERTY
The SET_ITEM_INSTANCE_PROPERTY built-in modifies the specified instance of
an item in a block by changing the specified item property.
Example
The following example sets the visual attribute to VA_CURR for the current record of
the current item:
SET_ITEM_INSTANCE_PROPERTY(:SYSTEM.CURSOR_ITEM,
VISUAL_ATTRIBUTE, CURRENT_RECORD, ’VA_CURR’);

SET_MENU_ITEM_PROPERTY
The SET_MENU_ITEM_PROPERTY built-in modifies the given properties of a
menu item.
Example
To enable the save menu item in a file menu:
SET_MENU_ITEM_PROPERTY(’FILE.SAVE’,ENABLED,PROPERTY_TRUE);

SET_TAB_PAGE_PROPERTY
The SET_TAB_PAGE_PROPERTY built-in sets the tab page properties of the
specified tab canvas page.
Example
To enable tab_page_1, if it is already disabled, use:
DECLARE
tbpg_id TAB_PAGE;
BEGIN
tbpg_id := FIND_TAB_PAGE(’tab_page_1’);
IF GET_TAB_PAGE_PROPERTY(tbpg_id, enabled) = ’FALSE’ THEN
SET_TAB_PAGE_PROPERTY(tbpg_id, enabled, property_true);
END IF;
END;

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

Lesson
21: Writing Flexible Code
......................................................................................................................................................

Object IDs
Finding the object ID:

ID

lov_id
lov_id :=
:= FIND_LOV(’my_lov’)
FIND_LOV(’my_lov’)

Referencing an object by ID:
...SHOW_LOV(lov_id)

Referencing an object by name:
...SHOW_LOV(’my_lov’)
...SHOW_LOV(’my_lov’)

ID

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
21-14
Oracle Forms Developer: Build Internet Applications I

Referencing Objects by Internal ID
......................................................................................................................................................

Referencing Objects by Internal ID
Form Builder assigns an ID to each object that you create. An object ID is an internal
value that is never displayed. You can get the ID of an object by calling the built-in
FIND_ subprogram appropriate for the object. The FIND_ subprograms require a fully
qualified object name as a parameter. For instance, when referring to an item, use
BLOCKNAME.ITEMNAME.
The return values of the FIND_ subprograms (the object IDs) are of a specific type.
The types for object IDs are predefined in Form Builder. There is a different type for
each object.
Three Reasons for Using Object IDs
• Improving performance (Form Builder looks up the object only once
when you initially call the FIND_ subprogram to get the ID. When you
refer to an object by name in a trigger, Form Builder must look up the
object ID each time.)
• Writing more generic code
• Testing whether an object exists (using the ID_NULL function and
FIND_object)

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

Lesson
21: Writing Flexible Code
......................................................................................................................................................

FIND_ Built-Ins




FIND_FORM
FIND_BLOCK
FIND_ITEM

ID

FIND_RELATION
FIND_LOV

Copyright  Oracle Corporation, 2000. All rights reserved.

FIND_ Built-Ins




FIND_WINDOW
FIND_VIEW
FIND_CANVAS

ID

FIND_ALERT
FIND_EDITOR

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
21-16
Oracle Forms Developer: Build Internet Applications I

............ Form Builder Class Types The table below lists some of the FIND_ subprograms........................................................................................................... along with the object classes that use them and the return types they produce: Object Class Alert Block Canvas Editor Form Item LOV Relation View Window Subprogram FIND_ALERT FIND_BLOCK FIND_CANVAS FIND_EDITOR FIND_FORM FIND_ITEM FIND_LOV FIND_RELATION FIND_VIEW FIND_WINDOW Return Type ALERT BLOCK CANVAS EDITOR FORMMODULE ITEM LOV RELATION VIEWPORT WINDOW ....................... Oracle Forms Developer: Build Internet Applications I 21-17 .......................................................................................................................Referencing Objects by Internal ID .........................................

.... 2000. All rights reserved......Lesson 21: Writing Flexible Code ............. All rights reserved...... Copyright  Oracle Corporation...’Current’)...........................CURSOR_ITEM)............ BEGIN item_var := FIND_ITEM(:SYSTEM. SET_ITEM_PROPERTY(item_var.....position........................ END............... • Use the variable within the current PL/SQL block only................ SET_ITEM_PROPERTY(item_var........30........55)........................ 21-18 Oracle Forms Developer: Build Internet Applications I .......................... Copyright  Oracle Corporation... 2000....... Use the variable for any later reference to the object...........prompt_text................................................ Using Object IDs Example: DECLARE item_var item............ Using Object IDs • • Declare a PL/SQL variable of the same data type.................... .....................

.................... .... The following calls are logically equivalent: SET_ITEM_PROPERTY(’S_ITEM... Once you assign an object ID to a variable in a trigger or PL/SQL program unit.........35)............... You must declare a variable of the same type as the object ID.....50. The following example uses the FIND_ITEM built-in to assign the ID of the item that currently has input focus to the variable id_var.... Declaring Variables for Object IDs To use an object ID......... The following call is illegal: GO_ITEM(block_id.....................35).. . DECLARE id_var item............. BEGIN id_var := FIND_ITEM(:SYSTEM...’item_name’)................... ... rather than referring to the object by name.................... You cannot......... .CURSOR_ITEM).... Note: Use the FIND_ built-in subprograms only when referring to an object more than once in the same trigger or PL/SQL program unit...........Referencing Objects by Internal ID .itemname)...... you can use that variable to reference the object............ provided that each individual argument refers to a distinct object...... SET_ITEM_PROPERTY(id_var.position............ use an object ID and an object name to form a fully qualified object_name (blockname......... The two examples below show that you can pass either an item name or an item ID to the SET_ITEM_PROPERTY built-in subprogram.........50................position......... however....................... Oracle Forms Developer: Build Internet Applications I 21-19 ............................. END... You can use either object IDs or object names in the same argument list....... you must first assign it to a variable.............price’.

............................................Lesson 21: Writing Flexible Code ........................................................ All rights reserved..... 21-20 Oracle Forms Developer: Build Internet Applications I .............. An ............................................................... 2000......................... . Using Object IDs • • A PL/SQL variable has limited scope..........................................id extension: – Broadens the scope – Converts to a numeric format – Enables assignment to a global variable – Converts back to the object data type Copyright  Oracle Corporation........................................................

.. Example The following example shows the conversion of the global variable back to its original PL/SQL variable data type: DECLARE item_var item............. Using Object IDs Outside the Initial PL/SQL Block You have seen how object IDs are referenced within the trigger or program unit by means of PL/SQL variables.... however.......... then to a global variable (global...............................................id := TO_NUMBER(:GLOBAL.. you need to convert it back to its original data type....... ..... then assign it to a global variable..CURSOR_ITEM).Referencing Objects by Internal ID ....id. BEGIN item_var.................. END..................... GO_ITEM(item_var)...............................item)........ You can only reference these PL/SQL variables in the current PL/SQL block.................. you can increase the scope of an object ID............ To reference an object ID outside the initial PL/SQL block.............id extension for your declared PL/SQL variable..... you need to convert the ID to a numeric format using an .......................................item := item_var...................... Example The following example of trigger code assigns the object ID to a local PL/SQL variable (item_var) initially... END.. To be able to reuse the object ID. You can pass the global variable around within the application............ :GLOBAL. Oracle Forms Developer: Build Internet Applications I 21-21 . BEGIN item_var := FIND_ITEM(:SYSTEM..item): DECLARE item_var item....................

..... All rights reserved.............................................. 2000.....................................................................................................................................Lesson 21: Writing Flexible Code ..... Referencing Objects Indirectly ITEM A Direct reference KIDSPORT ITEM B Indirect reference ITEM A ITEM A Kidsport Copyright  Oracle Corporation................................ 21-22 Oracle Forms Developer: Build Internet Applications I ......................................... ..........................................

............................................... because direct references cannot be resolved....................................................... you can write a PL/SQL program unit to use any item whose name is assigned to the indicated variable........................... You can reference items indirectly with the NAME_IN and COPY built-in subprograms............................. ... Note: Use indirect referencing when you create procedures and functions in a library module.................................................................... Oracle Forms Developer: Build Internet Applications I 21-23 ............................................Referencing Items Indirectly ..................... Using variables instead of actual item names. Referencing Items Indirectly By referencing items indirectly..... reusable code. you can write more generic........

.................... 2000..............name’)............. All rights reserved...............customer_name)...:GLOBAL.............................................customer_name).. 21-24 Oracle Forms Developer: Build Internet Applications I .......... Copyright  Oracle Corporation...... Referencing Objects Indirectly The COPY procedure allows: • Direct copy COPY(’Kidsport’..................................... . COPY(’Kidsport’.Lesson 21: Writing Flexible Code .............. All rights reserved.......................................................... • Indirect copy COPY(’Kidsport’......... 2000......... Referencing Objects Indirectly The NAME_IN function: • Returns: – The contents of variable – Character string • Use conversion functions for NUMBER and DATE Copyright  Oracle Corporation.......:GLOBAL...................’S_CUSTOMER.................................

Referencing Items Indirectly . Using the NAME_IN Built-in Function The NAME_IN function returns the contents of an indicated variable....................................customer_name)..name............. Unlike the standard PL/SQL assignment statement............ For instance: date_var := TO_DATE(NAME_IN(’S_ORD...... as in the following example: COPY(’Kidsport’.......... The first one uses a direct reference to customer.............................. Using the COPY Built-in Procedure The COPY built-in assigns an indicated value to an indicated variable or item.... The following statements are equivalent............ The first example below shows direct referencing and the second shows indirect referencing: COPY(’Kidsport’.............date_ordered’))....... Oracle Forms Developer: Build Internet Applications I 21-25 ............ To use NAME_IN for a date or number item............ Use the COPY built-in subprogram with the NAME_IN built-in to assign a value to an item whose name is stored in a global variable.............. In a library....................NAME_IN(’GLOBAL....................customer_name’))...... ...name’) = ’Kidsport’......... The return value of NAME_IN is always a character string. convert the string to the desired data type with the appropriate conversion function. COPY(’Kidsport’......................’S_CUSTOMER...........:GLOBAL......... you could avoid this direct reference by using: IF NAME_IN(’S_CUSTOMER. whereas the second uses an indirect reference: IF :S_CUSTOMER.........name = ’Kidsport’......................name’)..... using the COPY built-in enables you to indirectly reference the item whose value is being set.........

......................... 2000...................... 2000.. Use indirect referencing to allow form module variables to be referenced in library and menu modules.........Lesson 21: Writing Flexible Code .. 21-26 Oracle Forms Developer: Build Internet Applications I .......................................... Summary • • Use object IDs to improve performance................................................................ Copyright  Oracle Corporation... .... All rights reserved......... Summary • Use system variables: – To avoid hard-coding object names – To return information about the current state of the form • Use GET_object_PROPERTY built-ins to return current property values for Form Builder objects.................................................................... All rights reserved.......................................... Copyright  Oracle Corporation..................

. to improve performance • Indirect referencing.................. Oracle Forms Developer: Build Internet Applications I 21-27 .............. to allow form module variables to be referenced in library and menu modules .....................................To return information about the current state of the form • GET_object_PROPERTY built-ins....................... to return current property values for Form Builder objects • Object IDs........................................................................................................................................................................................... Summary Use the following to write flexible code: • System variables: ....To avoid hard-coding object names ......Summary ................

...Lesson 21: Writing Flexible Code ............................ 2000....... All rights reserved................... “Practice Solutions................................................................................................. see Practice 21 in Appendix A............................. 21-28 Oracle Forms Developer: Build Internet Applications I ............... Practice 21 Overview This practices covers the following topics: • Populating product images only when the image item is displayed • Modifying the When-Button-Pressed trigger of the Image_Button in order to use object IDs instead of object names Copyright  Oracle Corporation................................................................” ........................... Note For solutions to this practice..................

............................................Practice 21 Overview ............................................................................... • Populating product images only when the image item is displayed • Modifying the When-Button-Pressed trigger of the Image_Button in order to use object IDs instead of object names ................ Practice 21 Overview In this practice...... you use properties and variables in the ORDGXX form to provide flexible use of its code..................................................................................................... Oracle Forms Developer: Build Internet Applications I 21-29 ....... You also make use of object IDs...................................................

... Use the GET_ITEM_PROPERTY built-in function.... Practice 21 1 In the ORDGXX form.... Perform the trigger actions only if the image is currently displayed. Add a test in the code to check Product_Image.......... alter the triggers that populate the Product_Image item when the image item is displayed.................. Use a FIND_object function to obtain the IDs of each item referenced by the trigger..................... Declare variables for these IDs......................... 2 Alter the When-Button-Pressed trigger on the Image_Button so that object IDs are used.............. 3 Save................................ and run the form to test these features........................................................... ...................................Lesson 21: Writing Flexible Code ....................................... compile.......................... and use them in each item reference in the trigger........ 21-30 Oracle Forms Developer: Build Internet Applications I ..............

.......................... Sharing Objects and Code .22 ......

............................................. Objectives After completing this lesson........................................................................ All rights reserved........ you should be able to do the following: • Describe the various methods for reusing objects and code • • • • Inherit properties from property classes Group related objects for reuse Reuse objects from an object library Reuse PL/SQL code Copyright  Oracle Corporation..........................................Lesson 22: Sharing Objects and Code ............................. Schedule Topic Lecture Practice Total Timing 50 minutes 30 minutes 80 minutes .................... 22-2 Oracle Forms Developer: Build Internet Applications I ................................................ 2000.........................................

.......... Oracle Forms Developer: Build Internet Applications I 22-3 ...................................................................... Introduction Overview Form Builder includes some features specifically for object and code reuse...................................Introduction ....................................... you learn how to share objects between form modules using the Object Library..... You also learn how to share code using the PL/SQL Library...................................................... .................................................... In this lesson........................................

......................................................................................................................... 22-4 Oracle Forms Developer: Build Internet Applications I ................. All rights reserved..Lesson 22: Sharing Objects and Code ........................ .................................................. 2000............................................................... Sharing and Reusing Code • • • • Increases productivity Decreases maintenance Increases modularity Maintains standards Copyright  Oracle Corporation...........................

.......................................... In fact.. Oracle Forms Developer: Build Internet Applications I 22-5 ................... Decrease Maintenance By creating applications that use or call the same object or piece of code several times.......................................Reusable Objects and Code Overview ................................. you should share and reuse objects and code wherever possible in order to: • Increase productivity • Decrease maintenance • Increase modularity • Maintain standards Increase Productivity You can develop applications much more effectively and efficiently if you are not trying to “start over” each time you write a piece of code.... you do not run the risk of introducing minor changes....... Reusable Objects and Code Overview When you are developing applications..... you can create a set of standard objects and some pieces of standard code and use them as a starting point for all of your new form modules........................ If you create an object once and copy it again and again..... By sharing and reusing frequently used objects and code..... Maintain Standards You can maintain standards by reusing objects and code.......................... you can decrease maintenance time............... you can cut down development time and increase productivity.... ............................ Increase Modularity Sharing and reusing code increases the modularity of your applications.......................................................

............................................Lesson 22: Sharing Objects and Code ......................................................................... 22-6 Oracle Forms Developer: Build Internet Applications I ............... ........... All rights reserved.......................... Property Classes Canvas Relation properties properties Block Item properties properties LOV properties Copyright  Oracle Corporation.......................................................... 2000.............................................................................

............................. Oracle Forms Developer: Build Internet Applications I 22-7 ............................................... Why Use Property Classes? Use property classes to increase productivity by setting standard or frequently used values for common properties and associating them with several Form Builder objects.. ......... but for several at a time............................................................................................................... Property classes enable you to define standard properties not just for one particular object................... because it eliminates the time spent on setting identical properties for several objects.................................. Property Class What Is a Property Class? A property class is a named object that contains a list of properties and their settings..... This results in increased productivity.....Property Class ..............................................

............. Property Class Icons Add Property Inherit Property Delete Property Property Class Copyright  Oracle Corporation.............Lesson 22: Sharing Objects and Code ........... • Associate a property class with an object.................................. Instructor Note • Create a property class in the Property Palette........................................ All rights reserved.................................. 22-8 Oracle Forms Developer: Build Internet Applications I ............................. • Create a property class in the Object Navigator.............. 2000........ ...................................................... • Include properties for different objects..........................................................

Deleting a Property You can remove properties from a property class using the Delete Property button........ and click the Property Class icon........... You choose the properties and their values for the property class................. Creating a Property Class When you create a property class..... An information alert is displayed.......................................Creating a Property Class .............. Set the value for that property using the Property Palette..... You can create a property class in two ways: • Using the Create button in the Object Navigator • Using the Create Property Class button How to Create a Property Class from the Object Navigator 1 Click the Property Class node........... 2 Move to the Property Palette..... you have all the properties from every Form Builder object available...................... click the object whose properties you want to copy into a property class. Oracle Forms Developer: Build Internet Applications I 22-9 .. A new property class entry displays................. 2 Click Create.............................. How to Create a Property Class from the Property Palette 1 In the Object Navigator........... 3 Use the Object Navigator to locate the property class and change its name........... ..... you can add a property by clicking the Add Property button and selecting a property from the list.................. select the properties you want to copy into a property class....................................... 3 Add the required properties and their values using the Add Property button in the Property Palette............................. Adding a Property Once you create a property class...................

22-10 Oracle Forms Developer: Build Internet Applications I .............. All rights reserved......... ........................ All rights reserved. Inheriting Properties • • • Set the Subclass Information property...................................................................... Convert an inherited property to a variant property.......Lesson 22: Sharing Objects and Code ....... Copyright  Oracle Corporation............................................... Inherited and Variant Properties Property palette Property palette Default property Default property Default property Default property Default Default property property Change Changed property Property palette Inherited property Variant property Inherited property Inherited property Property class Apply Property palette Change Inherit Inherited property Inherited property Inherited property Copyright  Oracle Corporation......................................... 2000..... Convert a variant property to an inherited property.................................................... 2000.................................

.

.............................................................................................................................................................Lesson 22: Sharing Objects and Code .............. 22-12 Oracle Forms Developer: Build Internet Applications I ......................................................................................... Object Group • • Is a logical container Enables you to: – Group related objects – Copy multiple objects in one operation Copyright  Oracle Corporation.... .... 2000............................... All rights reserved.....

.

......... canvas-view.................................... 2000................................................. Instructor Note • Create an object group....................................Lesson 22: Sharing Objects and Code .................................. • Drag the object group and drop it into a second form module.... • Point out that the objects in the object group are still visible in their respective positions in the Object Navigator. 22-14 Oracle Forms Developer: Build Internet Applications I ............... • Include a block................... .......................... and form-level trigger.................. Using Object Groups • Blocks include: – Items – Item-level triggers – Block-level triggers – Relations • • Object groups cannot include other object groups Deleting: – An object group does not affect the objects – An object affects the object group Copyright  Oracle Corporation........... All rights reserved....................................................

.

............................... All rights reserved........... Copying Objects Company Name: Company Code: Balance: Ability to make exact copy of object Company Name: Company Code: Balance: Copyright  Oracle Corporation............................................................. What Is Subclassing? Company Name: Company Code: Balance: Ability to add to object Ability to make exact copy of object Company Name: Company Name: Company Code: Company Code: Balance: Balance: Address: Code: Copyright  Oracle Corporation. 2000.............. 22-16 Oracle Forms Developer: Build Internet Applications I ............. All rights reserved....................................Lesson 22: Sharing Objects and Code ........................................................................................................ ................................ 2000....

.

.......... and later decide to subclass the object.... All rights reserved.... 2000................................................Lesson 22: Sharing Objects and Code ...... it never inherits those overridden properties from the parent.............................. 22-18 Oracle Forms Developer: Build Internet Applications I ................ This conforms to the inheritance model above................................................ Subclassing Company Name: Company Code: Balance: Ability to add to object Ability to make exact copy of object Ability to alter properties Company Name: Company Name: Company Name: Company Code: Company Code: Company Code: Balance: Balance: Balance: Address: Code: Copyright  Oracle Corporation...................... then change the properties from the default values....................... but it is not always well understood............................................................... Instructor Note If you create an object without subclassing it.. ..................................

............. if the parent and child objects are in the same form • When you reload the form containing a child object . the changes also apply to the properties of the subclassed object that you have not altered............ Ability to Alter Properties With subclassing........... Property Palette Icon Meaning Circle The value for the property is the default...... you can add additional items to a subclassed block............ This provides a powerful object inheritance model.............................. as with referencing.......... Arrow The value for the property was inherited......... For example.......... you can identify inherited or overridden properties........ but you can add to the subclassed object................................................ and this severely limited the usefulness of the reference mechanism..................... Arrow with a red cross over it The value for the property was inherited but overridden (variant property).... Subclassing an Object Earlier versions of Form Builder provided only the ability to inherit from a base class..... The child inherits changes: • Immediately. However. If you change the parent class. Oracle Forms Developer: Build Internet Applications I 22-19 . With Property Palette..................... Ability to Inherit Changes When you change the properties of a parent object.... any properties that you override remain overridden........ Subclassing is similar to referencing in Oracle Forms Developer Release 1.............. you can make an exact copy and then alter the properties of some objects...... Ability to Add to an Object You can still create an exact copy of an object.................. Square The value for the property was changed from the default..........Copying and Subclassing Objects and Code ............. but is more powerful and reflects true object subclassing.............. all child objects inherit those properties if they are not already overridden..............

..................................... .......................................................................................................................................................... All rights reserved....... 22-20 Oracle Forms Developer: Build Internet Applications I ................................................ Inheriting Changes Make changes to parent Company Name: Company Code: Balance: Ability to inherit changes Ability to inherit changes Ability to inherit changes Company Name: Company Name: Company Name: Company Code: Company Code: Company Code: Balance: Balance: Balance: Address: Code: Copyright  Oracle Corporation......................Lesson 22: Sharing Objects and Code .................. 2000..................

.

. and personal standards Copyright  Oracle Corporation...............Lesson 22: Sharing Objects and Code ......................... An Object Library • • • Is a convenient container of objects for reuse • Simplifies the sharing of reusable components Simplifies reuse in complex environments Supports corporate.......... ................................................................................... 22-22 Oracle Forms Developer: Build Internet Applications I .................................................................... project......................................................... All rights reserved......................... 2000......................

.

22-24 Oracle Forms Developer: Build Internet Applications I .............. All rights reserved.................................................... 2000.........................olb file or to database Copyright  Oracle Corporation....... All rights reserved........................................................................................................................... Benefits of the Object Library • • • Simplifies the sharing and reuse of objects Provides control and enforcement of standards Eliminates the need to maintain multiple referenced forms Copyright  Oracle Corporation......................... ........... 2000..........Lesson 22: Sharing Objects and Code ............................ Object Libraries • • • Appear in the Navigator if they are open Are used with a simple tabbed interface Are saved to .............

............... 2 Drag objects from the Object Navigator into the object library............. Oracle Forms Developer: Build Internet Applications I 22-25 .......................................... This interface has Add and Remove tab pages that help you to create your own groups................ press [Shift] and drag the object............... You can save object libraries to a file system as .. To create a copy of the object...... The descriptive comment comes from the object Comment property.........................olb files......................... Benefits of the Object Library There are several advantages to using object libraries to develop applications: • Simplifies the sharing and reuse of objects • Provides control and enforcement of standards • Eliminates the need to maintain multiple referenced forms ................. Double-clicking on the tab and dragging an object to it from the object library creates a subclassed object.. Working with Object Libraries Object libraries appear in the Navigator if they are open.. open.. and close object libraries like other modules......................Working with Object Libraries ...... How to Populate an Object Library 1 Select Tools—>Object Library to display the object library................ Object libraries are automatically reopened when you start up Form Builder................... To move the object out of the object library and into a form........ You can create. press [Control] and drag the object................... or to the database......... It is easy to use object libraries with a simple tabbed interface..................... making your reusable objects immediately accessible....... but it can be edited independently of that property...........

............ All rights reserved...... 22-26 Oracle Forms Developer: Build Internet Applications I ............ Working with SmartClasses 1........................................................... 3............... 2000....... 2000........................... You can have many SmartClasses of a given object type................... Copyright  Oracle Corporation........................ select SmartClasses..Lesson 22: Sharing Objects and Code .... 2................. Select an object in the Layout Editor or Navigator... From the pop-up menu....... . All rights reserved.. A SmartClass • Is an object in an object library that is frequently used as a class • Can be applied easily and rapidly to existing objects • Can be defined in many object libraries Check indicates a SmartClass......................... Copyright  Oracle Corporation. Select a class from the list.........................................................................

................. You can see its details in the Subclass Information dialog box................................. date items.. When you select a class for the object............... 2 From the pop-up menu.......................... .... Object Library members which are not SmartClasses can only be used to create new objects in form modules into which they are added................. select SmartClasses.. If you frequently use certain objects as standards............... just like any other subclassed object........................ and alerts.. Oracle Forms Developer: Build Internet Applications I 22-27 ........................ What Is a SmartClass? A SmartClass is a special member of an Object Library............What Is a SmartClass? . This mechanism makes it very easy to apply classes to existing objects.......... it can be used to subclass existing objects in a form using the SmartClass option from the right mouse button popup menu............... The SmartClasses pop-up menu lists all the SmartClasses from all open object libraries that have the same type as the object................ such as standard buttons......................... you can mark them as SmartClasses by selecting each object in the object library and choosing Object—>SmartClass......................... Unlike other Object Library members............ for example: • Wide_Button • Narrow_Button • Small_Iconic_Button • Large_Iconic_Button How to Work with SmartClasses 1 Select an object in the Layout Editor or Navigator......... You can also have many SmartClasses of a given object type.... You can mark many different objects that are spread across multiple object libraries as SmartClasses... it becomes the parent class of the object........

................................................Lesson 22: Sharing Objects and Code .................................................. ........ 2000................................................................................................................. Reusing PL/SQL • Triggers: – Copy and paste text – Copy and paste within a module – Copy to or subclass from another module – Move to an object library • PL/SQL program units: – Copy and paste text – Copy and paste within a module – Copy to or subclass in another module – Create a library module – Move to an object library Copyright  Oracle Corporation............................ All rights reserved.... 22-28 Oracle Forms Developer: Build Internet Applications I .....................................................

.. using drag and drop in the Object Navigator • Moving the trigger to an object library PL/SQL Program Units Although triggers are the primary way to add programmatic control to a Form Builder application.. You can reuse PL/SQL program units by: • Copying and pasting................................................................... using drag and drop in the Object Navigator • Creating a library module • Moving the program unit to an object library ........................................................ Oracle Forms Developer: Build Internet Applications I 22-29 ...Reusing PL/SQL ............ using PL/SQL program units supplement triggers.. using the Edit menu • Copying or subclassing to another form module............ using the Edit menu • Copying to another area of the current form module.................................... you can reuse code without having to retype it.......... which decrease the need to hard-code object names within the procedure body.. Reusing PL/SQL PL/SQL in Triggers You can reuse the PL/SQL in your triggers by: • Copying and pasting.............. using Copy and Paste on the menu of the right mouse button • Copying to or subclassing from another form module..................... you can create PL/SQL program units to hold commonly used code.................................... With Form Builder................................. These PL/SQL program units can use parameters.....

.................................... to return values.....pll or Database Packages Library Copyright  Oracle Corporation..... ............................. PL/SQL Libraries Applications Procedures Functions Form modules Menu modules Report modules Graphic modules ......... All rights reserved................. All rights reserved.................. where appropriate.................. holding procedures..... and packages.Lesson 22: Sharing Objects and Code ..................................... • • Direct references to bind variables are not allowed......................... 22-30 Oracle Forms Developer: Build Internet Applications I ....................... • Use functions.......................................... Writing Code for Libraries • A library is a separate module.......... 2000..... 2000.... functions.................... Copyright  Oracle Corporation....... Use subprogram parameters for passing bind variables.

......... ...... menus........... including procedures.. END........... Example Consider the second method listed above in the following library subprogram: FUNCTION locate_emp(bind_value IN NUMBER) RETURN VARCHAR2 IS v_ename VARCHAR2(15).... You can then pass the names of bind variables as parameters when calling the library program units from your Oracle Forms Developer applications...PL/SQL Libraries ................. functions........... reports.............. and displays are outside the scope of the library...................... A library: • Is produced as a separate module and stored in either a file or the database • Provides a convenient means of storing client-side code and sharing it among applications • Means that a single copy of program units can be used by many form................................ This means that you cannot directly refer to variables that are local to another module.............. There are two ways to avoid direct references to bind variables: • You can refer to global variables and system variables in forms indirectly as quoted strings by using certain built-in subprograms..... bind variables in forms...................................... • Write program units with IN and IN OUT parameters that are designed to accept references to bind variables.. BEGIN SELECT ename INTO v_ename FROM emp WHERE empno = bind_value...... and packages...................... report......... PL/SQL Libraries A library is a collection of PL/SQL program units... RETURN(v_ename)..... because the compiler does not know about them when you compile the library program units............................... A single library can contain many program units that can be shared among the Oracle Forms Developer modules and applications that need to use them............................... menu.... Oracle Forms Developer: Build Internet Applications I 22-31 .... or graphic modules • Supports dynamic loading of program units Scoping of Objects Because libraries are compiled independently of the Oracle Forms Developer modules that use them.......

........ 22-32 Oracle Forms Developer: Build Internet Applications I ........................................................ 2000................................................................................................................................... All rights reserved..Lesson 22: Sharing Objects and Code ...... Creating Library Program Units Copyright  Oracle Corporation............. Attach Library Dialog Box Copyright  Oracle Corporation.. 2000...... ...................................................................... All rights reserved.............

.. the Attach Library dialog box appears............. or graphics module.. Working with PL/SQL Libraries Creating a Library You must first create libraries in the builder before you add program units..................... 4 Click Attach..... select the Save option in Form Builder.................. Detaching a Library To later detach a library.. specify the library’s name and select File System or Database......Working with PL/SQL Libraries ..... From this node............. in the Navigator................ ..... and specifications in the same way as in other modules.... 2 Expand the module and select the Attached Libraries node in the Navigator............. report............. simply delete the library entry from the list of Attached Libraries for that module. 2 Select the destination for the library (file system or database)... and the name by which the library is to be saved............ you can create procedures............ package bodies. To do this....... menu.. report. This permanently records the library attachment in the definition of this module.............. you can either: • Select File—>New—>Library from the menus (An entry for the new library then appears in the Navigator) • Select the Libraries node in the Navigator..... if required. When you select Create.......... menu.... That module will then no longer be able to reference the library program units............ and select the Create tool from the tool bar There is a Program Units node within the library’s hierarchy in the Navigator.... functions.......... or graphics..................... 3 In the Attach Library dialog box.. This may be a form........ Oracle Forms Developer: Build Internet Applications I 22-33 ........................ How to Save the Library 1 With the context set on the library............. either in the designer or at run time....... To attach a library to a module: 1 Open the module that needs to be attached to the library........ or another library module... you must attach the library to the modules........... 5 Save the module to which you have attached the library... How to Attach a Library Before you can refer to a library program unit from a form..

.................. )........ 2000................. Calls and Searches Calls procedure procedure (( )........................ ................................... 22-34 Oracle Forms Developer: Build Internet Applications I ..............................call (( )........... package.....Lesson 22: Sharing Objects and Code ................ All rights reserved.....................................call package................................................................. ).......... ......function... Searches •Program Units PROCA PROCB •Attached Libraries •Database Copyright  Oracle Corporation..function...................... .............

............... If two program units of the same name and type occur in different libraries in the attachment list......PLX Files The library ................ Example The following command creates a run-time library named runlib1.............. Oracle Forms Developer: Build Internet Applications I 22-35 ......................pll: GENERATE LIB mylib FILE runlib1..................... . Creating ........ how_many_people.plx based on the open library mylib................................................ or stored in the database.... Program units are searched for first in the calling module.................. without any source.. References are resolved by searching through libraries in the order in which they occur in the attachment list......... and pack5...... you will probably want to generate a version of your library that contains only the compiled p-code.........PLX file is a platform-specific executable that contains no source............................del_emps. then in the libraries that are attached to the calling module......... the one in the “higher” library will be executed....... Referencing Attached Library Program Units You refer to library program units in the same way as those that are defined locally. Remember that objects declared in a package must be referenced with the package name as a prefix. Example Assume that the program units report_totals...........................Working with PL/SQL Libraries ....del_emps are defined in an attached library: report_totals(:sub1).............. --library function pack5. --library package procedure When Several Libraries Are Attached You can attach several libraries to the same Oracle Forms Developer module............. since it is located first.... whether or not they are part of a library......... You can generate a ... When you are ready to deploy your application. --library procedure v_sum := how_many_people....PLX file from Form Builder or from the command line...

................ 2000............................. All rights reserved......Lesson 22: Sharing Objects and Code ........................................................ 22-36 Oracle Forms Developer: Build Internet Applications I ........... All rights reserved............................. Summary • Methods of sharing objects and code: – Using property classes – Using object groups – Copying – Subclassing – Creating a library module – Using object libraries Copyright  Oracle Corporation................................ 2000.......................................... Summary • Reasons to share objects and code: – Increased productivity – Increased modularity – Decreased maintenance – Maintaining standards Copyright  Oracle Corporation.................................................. ....................................

.............. extends referencing to include object-oriented capabilities • Creating a library module • Using object libraries: Enables drag and drop reuse........Summary ..................................... This lesson described how to use these methods... Summary Forms provides a variety of methods for reusing objects and code.............. and provides SmartClasses for default objects ... Reasons to share objects and code: • Increased productivity • Increased modularity • Decreased maintenance • Maintaining standards Methods of sharing objects and code: • Using property classes: Defines standard properties for several objects at a time • Using object groups: Bundles numerous objects into higher-level building blocks that can be used again in another application • Copying: Exports the definition of an object to another module • Subclassing: Creates an object in one module and then subclasses the current definition of that object in any number of target modules at build time................. Oracle Forms Developer: Build Internet Applications I 22-37 .................................................................................................................................................................................................................

............ Note For solutions to this practice....... Practice 22 Overview This practice covers the following topics: • Creating an object group and using this object group in a new form module • • Using property classes • Setting and using SmartClasses Creating an object library and using this object library in a new form module Copyright  Oracle Corporation............... 22-38 Oracle Forms Developer: Build Internet Applications I ........... “Practice Solutions.............................................. All rights reserved................. see Practice 22 in Appendix A................................................................................................. 2000..........................” .........................................................Lesson 22: Sharing Objects and Code ...................

.............................. • Creating an object group and using this object group in a new form module • Using property classes • Creating an object library and using this object library in a new form module • Setting and using SmartClasses .................................................... You set SmartClasses in the object library and use these classes in the form module...........................Practice 22 Overview ............................................. you use an object group and an object library to copy Form Builder objects from one form to another. You will also create a property class and use it to set multiple properties for several objects........................ Practice 22 Overview In this practice..................................................................... Oracle Forms Developer: Build Internet Applications I 22-39 .........................................................

. .....Restock_Date to MM/DD/YYYY.............. compile.... and WIN_INVENTORY window.... the Toolbar.......... Include the following properties and settings: Property Setting Font Name Arial Format Mask 99.. run the form..... 22-40 Oracle Forms Developer: Build Internet Applications I ........ consisting of the S_INVENTORY block................... and run the form again..... Save...... Create two tabs in the object library called Personal and Corporate. Save the object library as summit.... and the Question_Alert to the personal tab of the object library......fmb...................999 Font Size 8 Justification Right Delete Allowed No Background Color DarkRed 5 Apply ClassA to CV_INVENTORY.....................olb.. the Restock_Date item and the 6 7 8 9 Max_In_Stock item. 2 Save the form. Save the form module as STOCKXX....... Save. compile.. 4 In the new form module..... Make the Restock_Date format mask a variant property.......... 3 Create a new form module and copy the Stock_Objects object group into it...... compile................ Correct the error.......... and note the error........ create an object group. and run the form.Lesson 22: Sharing Objects and Code ........................................... called Stock_Objects...... Create an object library and name it summit......... CV_INVENTORY canvas.. Add the CONTROL block.................................. create a property class called ClassA... Practice 22 1 In the ORDGXX form............................. Change the format mask for S_INVENTORY.....

... CONTROL block.................................... the S_DEPT block must be before the CONTROL block in the Object Navigator.............. Some items are not applicable to this form................... 11 Try to delete items on the Null canvas.................. Hide_Help_Button...... Mark these items as SmartClasses.... Set the Window property to WINDOW1 for the Toolbar canvas.... compile........... Apply these SmartClasses in your form.............. Create a new form and a new data block in the form..................... Set the Horizontal Toolbar Canvas property to TOOLBAR for the window.......... Set the Canvas property for the following items to NULL: Image_Button..... Create a sample date field..... Product_Lov_Button..................... and run the form to test it. For proper behavior...................... Use Toolbar as the form horizontal toolbar canvas for this form.. Save this form as DEPTGXX. and create a data block based on the S_DEPT table... Drag the Toolbar canvas..... Stock_Button.................................... Show_Help_Button............. .. Set the width and the format mask to your preferred standard....Practice 22 ............ by means of width.. one for wide buttons and one for medium buttons................ Oracle Forms Developer: Build Internet Applications I 22-41 ........... Drag these items into your object library.. Place the Toolbar canvas in the new form. Practice 22 (continued) 10 Create a new form.. and Question_Alert from the object library into the new form. What happens and why? 12 Create two sample buttons.. Subclass the objects...

......................................................................................... 22-42 Oracle Forms Developer: Build Internet Applications I ..................................................Lesson 22: Sharing Objects and Code ..................................................................................................................... .............................................

.....23 ..... Introducing Multiple Form Applications .......................

...................... Objectives After completing this lesson......................................... 23-2 Oracle Forms Developer: Build Internet Applications I ................................................................................................... Schedule Topic Lecture Practice Total Timing 50 minutes 30 minutes 80 minutes .. All rights reserved............... you should be able to do the following: • • Call one form from another form module Define multiple form functionality Copyright  Oracle Corporation...................................Lesson 23: Introducing Multiple Form Applications ........ 2000...................................................................................

..................Introduction ..................... .............................................................................................. Introduction Overview Oracle Forms Developer applications rarely consist of a single form document............ Oracle Forms Developer: Build Internet Applications I 23-3 ............................................. This lesson introduces you to the ways in which you can link two or more forms.................................................................................................................

....... Multiple Form Applications • Behavior: – Flexible navigation between windows – Single or multiple database connections – Transactions may span forms...................................................................... if required – Commits in order of opening forms............................................... 2000... 23-4 Oracle Forms Developer: Build Internet Applications I .. starting with current form • Links: – Data is exchanged by global variables or parameter lists – Code is shared as required................................. Multiple Form Session Forms Runtime Form C Open Open Form A Form B Open Form D Global variables Copyright  Oracle Corporation.......... through libraries and the database Copyright  Oracle Corporation........................................................ 2000................. All rights reserved.. All rights reserved.Lesson 23: Introducing Multiple Form Applications ............................................ ..................

........ The commit sequence starts from the current form and follows the opening order of forms.................................. using Forms Runtime... by attaching them to each form as required • Stored program units in the database ......... You can design forms to appear in separate windows....... Multiple Form Applications At the beginning of the course.... producing a modular structure......... Users can then navigate between visible blocks of different forms.................. This chain of control is used when you exit a form or commit transactions...................... much as they can in a single form........ and Form Builder remembers the form that invoked each additional form........ we discussed the ability to design Form Builder applications where blocks are distributed over more than one form... • Form Builder provides the same menus across the application..................................... as required.................. • Database transactions are continued across forms. for passing values between specific forms Code can be shared through the following: • Library modules........... • One form can be called from another.Multiple Form Applications .......... You can design forms for a Forms Runtime session according to the following conditions: • Forms share the same database session............... or each form provides its own separate menus when it becomes the active form......... Oracle Forms Developer: Build Internet Applications I 23-5 . A modular structure indicates the following: • Component forms are only loaded in memory if they are needed............... which span sessions • Through parameter lists........................... providing flexible combinations...... Data can be exchanged between forms as follows: • Through global variables..................... Other form modules can be opened in the session by calling built-ins from triggers.. or ended before control is passed to another form. or open their own separate sessions......... How Does the Application Behave? The first form module to run is specified before the Form Builder session begins..... so the user can work with several forms concurrently in a session (when forms are invoked by the OPEN_FORM builtin). What Links the Forms Together? Each form runs within the same Forms Runtime session.....

.................................................................... 23-6 Oracle Forms Developer: Build Internet Applications I .............................. OPEN_FORM MDI MDI FORM A FORM A OPEN_FORM FORM B Modeless Copyright  Oracle Corporation... ......................... now considered the primary method for providing multiple form applications..................................... This course concentrates mainly on OPEN_FORM. 2000........................... Use of the other two built-ins is discussed further in the course Oracle Forms Developer: Build Internet Applications II............................................................................ All rights reserved.......................... Instructor Note The broken line indicates that control need not pass immediately to the opened form (depending on the Activate_Mode argument)........Lesson 23: Introducing Multiple Form Applications .......

.................................. it can provide the user with facilities for starting additional forms.... activate_mode...How to Start Another Form Module .... OPEN_FORM enables you to start another form in a modeless window..... CALL_FORM.... OPEN_FORM This is a restricted procedure................... Oracle Forms Developer: Build Internet Applications I 23-7 ............) Paramlist Either the name (in quotes) or internal ID of a parameter list ........ This built-in is normally the preferred way of providing multiple form applications..... Parameter Description Form_Name Filename of the executable module (without the ..................................... paramlist).............................. data_mode................................................ if required........ This can be done by one of two methods: • Calling a built-in procedure from a trigger in the form • Calling a built-in procedure from a menu item in an attached menu In either case................... session_mode....... You can start another form using OPEN_FORM without passing control to it immediately.. and NEW_FORM............ or NO_ACTIVATE Session_Mode Either NO_SESSION (the default) or SESSION Data_Mode Either NO_SHARE_LIBRARY_DATA (the default) or SHARE_LIBRARY_DATA (Use this parameter to enable Form Builder to share data among forms that have identical libraries attached.... How to Start Another Form Module When the first form in a Forms Runtime session has started. so the user can work in other running forms at the same time.. and cannot be called in Enter Query mode. OPEN_FORM(’form_name’...... the available built-ins are those described below...... This built-in also gives you the option to begin a separate database session for the new form.................................FMX suffix) Activate_Mode Either ACTIVATE (the default)..... Built-in Procedures for Starting Another Form There are three procedures that you can use to start another form module from one that is already active: OPEN_FORM.....

........ You can make changes in the same transaction across forms.................................. navigating freely between them....................... Copyright  Oracle Corporation.... 2000...... 3....................................... Plan global variables and their names............................................... 23-8 Oracle Forms Developer: Build Internet Applications I ..................... ..... 2...... 2000........ All forms are visible together.. OPEN_FORM and the Summit Application • Scenario: Run the CUSTOMERS and ORDERS forms in the same session............................. All rights reserved.........................................Lesson 23: Introducing Multiple Form Applications .................. Define windows and positions for each form................ All rights reserved..... Implement triggers to: – Open other forms – Initialize globals from calling forms – Use globals in opened forms Copyright  Oracle Corporation... OPEN_FORM and the Summit Application • Actions: 1.

updated... Plan where the windows of each module will appear in relation to those of other modules.Initialize global variables in calling forms (This is so that values such as unique keys are accessible to other forms when they open....................... if the reference value changes in the calling form.. or from a Key.. and freely navigate between them to apply changes......................... Oracle Forms Developer: Build Internet Applications I 23-9 ..........trigger that fires on a keystroke or equivalent menu selection.................. 3 Plan and implement triggers to: ........ such as When-Button-Pressed......................................) .... Defining Multiple Form Functionality Using OPEN_FORM to Provide Forms in Multiple Windows You can use OPEN_FORM to link form modules in an application and enable the user to work in them concurrently....... Note that each form must reference a global variable by the same name.. You need one for each item of data that is to be accessible across all the forms in the application......Open another form (You can do this from item interaction triggers.......Make use of received global variables in opened forms (For example.............................) .............. or from When-New-Object-Instance triggers... • The user can see all open forms at the same time...Defining Multiple Form Functionality .............. perform the following steps: 1 Create each of the form modules............ inserted............ a Pre-Query trigger can use the global variable’s contents of the global variable as query criteria.. 2 Plan names for global variables.. and deleted.......................) ..... To provide this kind of functionality. • Changes in all forms can be saved together................ This might need to be done in more than one trigger.................. and orders for the current customer can be viewed....... Consider these requirements for the Summit application: • The CUSTOMERS form must provide an option to start the ORDERS form in the same transaction............

...................... Linking by Global Variables CUSTOMERS Customer ID ORDERS Order Customer_ID GLOBAL............................................................... 2000... 23-10 Oracle Forms Developer: Build Internet Applications I ................................................ unless the application does appropriate tests before calling this builtin....... .......... which the opened form could reset on exit...................... For example.............. All rights reserved.................. Defining Multiple Form Functionality Note: It is possible to start up several instances of the same form............... test a flag (global variable) set by an opened form at startup. using OPEN_FORM...............CUSTOMERID Copyright  Oracle Corporation........... or use the FIND_FORM built-in....................................Lesson 23: Introducing Multiple Form Applications ...........................

....................................... Planning Global Variables and Their Names You need a global variable for each item of data that is used across the application. or by the DEFAULT_VALUE built-in.........................................Orders_Button opens the ORDERS form.....CUSTOMERID ensures that orders queried at the startup of the ORDERS form apply to the current customer................... Opening the ORDERS Form from the CUSTOMERS Form This When-Button-Pressed trigger on :CONTROL.. ..........................................customerid := :S_CUSTOMER.......... • Global variables can be created by a PL/SQL assignment....................id..................... which has no effect if the variable already exists...................................... with a maximum of 255 characters. The scenario in the slide on the opposite page shows one global variable: GLOBAL.Defining Multiple Form Functionality ............. Reminders: • Global variables contain character data values......... and passes control immediately to it................ Oracle Forms Developer: Build Internet Applications I 23-11 ....... • Each global variable is known by the same name to each form in the session. OPEN_FORM(’ORDERS’)... • Reading from a nonexistent global variable causes an error..... ORDERS will use the same database session and transaction.................. :GLOBAL.......

............. All rights reserved...id..........Lesson 23: Introducing Multiple Form Applications ................................................... 2000.. Notes • Control passes immediately to the ORDERS form—no statements after OPEN_FORM are processed.....................................customerid... . All rights reserved.customerid := := :S_CUSTOMER..customerid.......... Restricted Query at Startup When-New-Form-Instance Execute_Query.......... • The transaction continues unless it was explicitly committed before... :S_CUSTOMER......................id... :GLOBAL. you retain control in the current form...customer_id := := :GLOBAL..... Execute_Query......... Pre-Query :S_ORD....................... Copyright  Oracle Corporation..............customerid :GLOBAL.............. OPEN_FORM(’ORDERS’)................. Opening Another Form Example: :GLOBAL. Copyright  Oracle Corporation.........customer_id :S_ORD....... 2000. • If the Activate_Mode argument is set to NO_ACTIVATE............... 23-12 Oracle Forms Developer: Build Internet Applications I .. OPEN_FORM(’ORDERS’)...................................

...... This trigger is on the S_ORD block of the ORDERS form: :S_ORD...Defining Multiple Form Functionality ...... it can populate items with values from global variables..........customer_id := :GLOBAL...... This trigger is in the ORDERS form: EXECUTE_QUERY.......... call the COMMIT_FORM built-in before OPEN_FORM....... and any remaining statements after OPEN_FORM are not executed....................... Oracle Forms Developer: Build Internet Applications I 23-13 ..... although the specified form starts up and the rest of the trigger is processed... • Pre-Query: This is usually on the master block of the opened form.... which are then used as query criteria....................) Performing a Restricted Query on Startup To display a query automatically in the opened form........ . This. This restriction applies for every other query performed on the block thereafter...................................... then open the next form in the same transaction........... fires a Pre-Query trigger if one is defined. Because this trigger fires in Enter Query mode..................... (Alternatively........ • If you want to end the current transaction before opening the next form.... in turn....................... you produce two triggers: • When-New-Form-Instance: This form-level trigger fires when the form is opened (regardless of whether control is passed to this form immediately or not).... Users can then navigate to the other form when they choose.. • If you set Activate_Mode to NO_ACTIVATE.... A query can be initiated by the EXECUTE_QUERY built-in procedure................. you can just post changes to the database with POST.................... with data in context to the calling form..customerid.............. control is passed immediately to the specified form.................... Opening Another Form • When you default the Activate_Mode argument in OPEN_FORM... control remains in the calling form........................

....................... Conditional Opening Example: :GLOBAL....customerid’).................... ’GLOBAL........................... END IF... Copyright  Oracle Corporation............................. IF ID_NULL(FIND_FORM(’ORDERS’)) THEN OPEN_FORM(’ORDERS’)..... All rights reserved... DEFAULT_VALUE(’’.. ELSE GO_FORM(’ORDERS’).................... Assigning Global Variables in the Opened Form • DEFAULT_VALUE ensures the existence of globals. All rights reserved...customerid’)......id......Lesson 23: Introducing Multiple Form Applications . Copyright  Oracle Corporation........................................ 2000. 23-14 Oracle Forms Developer: Build Internet Applications I ....................................... Pre-Form example: DEFAULT_VALUE(’’...................... ......... ’GLOBAL.customerid := :S_CUSTOMER. • You can use globals to communicate that the form is running.......... 2000.............................................

..... DEFAULT_VALUE(’’............................. ELSE GO_FORM(’ORDERS’)... for some reason..customerid’)................ it simply passes control to it................ If the ORDERS form is already running... :GLOBAL................................................. and before all of the When-New-Object-Instance triggers....... END IF.......... Example This Pre-Form trigger in the ORDERS form assigns a NULL value to GLOBAL................ . an error is reported: FRM-40815: Variable GLOBAL.. You can provide independence.....Defining Multiple Form Functionality ... The ORDERS form can now potentially be called without the CUSTOMERS form.. it ensures existence of global variables at the earliest point....................... a global variable has not been initialized before it is referenced in a called form............. and ensure that global variables exist by using the DEFAULT_VALUE built-in when the form is opening.id................................ ’GLOBAL............. IF ID_NULL(FIND_FORM(’ORDERS’)) THEN OPEN_FORM(’ORDERS’)...... Assigning Global Variables in the Opened Form If.............. using GO_FORM......productid does not exist.......CUSTOMERID if it does not exist when the form starts... Oracle Forms Developer: Build Internet Applications I 23-15 .... Because the Pre-Form trigger fires before record creation...................customerid := :S_CUSTOMER............... Conditional Opening Here is a variation of the When-Button-Pressed trigger on Orders_Button in the CUSTOMERS form..

.................. )........... ENTER............ Closing the Session Form C Form B Runtime Form A “Will the last one out please turn off the lights” Copyright  Oracle Corporation........................ • The Commit_Mode argument defines action on uncommitted changes.......... 2000.............. All rights reserved....................... Copyright  Oracle Corporation........ ELSE ELSE EXIT_FORM( EXIT_FORM( NO_COMMIT NO_COMMIT )............................FORM_STATUS :SYSTEM.... ENTER......Lesson 23: Introducing Multiple Form Applications ................ All rights reserved............................................FORM_STATUS == ’CHANGED’ ’CHANGED’ THEN THEN EXIT_FORM( EXIT_FORM( DO_COMMIT DO_COMMIT )............................... .................................. Closing a Form with EXIT_FORM • The default functionality is the same as for the Exit key...... END IF...... IF IF :SYSTEM........ 2000... END IF..... ). 23-16 Oracle Forms Developer: Build Internet Applications I .......

• DO_COMMIT posts and commits changes across all forms for the current transaction. When a multiple form session involves the OPEN_FORM built-in.... the session will end as a result..................... make the decision to commit (save) or roll back through the EXIT_FORM built-in....................... If there are............... EXIT_FORM(commit_mode) Parameter Description Commit_Mode Defines what to do with uncommitted changes in the current form: • ASK_COMMIT gives the decision to the user (the default)......... the default functionality is the same as described above........... • NO_COMMIT validates and rolls back uncommitted changes in the current form.................. you might use this built-in from a Key-Exit or When-Button-Pressed trigger...... Closing Forms and Forms Runtime Sessions A form may close down and pass control back to its calling form under the following conditions: • The user presses Exit or selects Exit from the Action menu......... Typically....................................................... • The EXIT_FORM built-in is executed from a trigger.................... Oracle Forms Developer: Build Internet Applications I 23-17 .......................... Closing a Form with EXIT_FORM When a form is closed... Form Builder checks to see whether there are any uncommitted changes... If the closing form is the only form still running in the Forms Runtime session......................... so the user is not asked..... • NO_VALIDATE is the same as NO_COMMIT. however.............Defining Multiple Form Functionality . it is possible that the last form to close is not the one that began the session................. You can........................... .. the user is prompted with the standard alert: Do you want to save the changes you have made? If you are closing a form with EXIT_FORM.. but without validation......

........................................... 2000.............. All rights reserved................................... ............................... You can use this variable to decide whether to attempt a commit in a trigger...........................Lesson 23: Introducing Multiple Form Applications . Note The system variable SYSTEM............ Other Useful Triggers Maintain referential links between forms through global variables: • In the parent form: – When-Validate-Item – When-New-Record-Instance • In opened forms: When-Create-Record Copyright  Oracle Corporation.................................................................................... 23-18 Oracle Forms Developer: Build Internet Applications I ....................FORM_STATUS contains the value CHANGED if there are uncommitted changes in the current form........................................

........ the record status remains NEW............. Other Useful Triggers When Using OPEN_FORM Because OPEN_FORM enables the user to navigate among open forms............... Example In the opened form (ORDERS)........................ so that the user can leave the record without completing it..... :GLOBAL... in case the user navigates to a line item record for a different customer................customerid := :S_CUSTOMER............. When items are assigned from this trigger.............. ..... The statement can also be issued from a When-New-Record-Instance trigger on the S_CUSTOMER block...........Defining Multiple Form Functionality .............id. this assignment to GLOBAL............CUSTOMERID as their default................. Oracle Forms Developer: Build Internet Applications I 23-19 ......................... :S_ORD.......Id.............. these triggers can help keep referential key values in step across forms........... potentially changing and inserting records...............customerid......CUSTOMERID can be performed in a When-Validate-Item trigger on :S_CUSTOMER....... Example In the parent form (CUSTOMERS). so that the global variable is kept up-to-date with an applied change by the user................customer_id := :GLOBAL... a When-Create-Record trigger on the S_ORD block ensures that new records use the value of GLOBAL................................................

............................................................................................. 23-20 Oracle Forms Developer: Build Internet Applications I . 2000................ • Forms communicate through global variables: – Load key values in the parent form – Use global values in opened forms for When-New-Form-Instance and Pre-Query Copyright  Oracle Corporation............................................................................... All rights reserved.........Lesson 23: Introducing Multiple Form Applications ........... ...................................................................................... Summary • The OPEN_FORM built-in provides multiple concurrent forms in a session..........

. there is another lesson that covers this subject in detail............ In this lesson........................... • The OPEN_FORM built-in provides multiple concurrent forms in a session......................... and how to pass information among forms............ NEW_FORM built-ins ........Form parameters ............................ The course Oracle Forms Developer: Build Internet Applications II covers the following topics in the lesson “Building Multiple Form Applications”: • Relevant details of calling and opening forms: ..............Summary ............... • Close a form by using the EXIT_FORM buildt-in... CALL_FORM................................Closing forms ...... In the course Oracle Forms Developer: Build Internet Applications II............... .... Oracle Forms Developer: Build Internet Applications I 23-21 . Summary This lesson is an introduction lesson to multiple form applications..Use global values in opened forms.........Navigating between forms • Passing data between forms: ...............Load key values in the parent form......................... you should have learned how to open more than one form module in a Forms Runtime session...........OPEN_FORM.......................Parameter lists • Multiple form transactions ............. • Forms communicate through global variables: . particularly for When-New-Form-Instance and Pre-Query...................

..................................................... 2000............................................ “Practice Solutions..” .. 23-22 Oracle Forms Developer: Build Internet Applications I ... see Practice 23 in Appendix A................................................Lesson 23: Introducing Multiple Form Applications ........................................... Practice 23 Overview This practice covers the following topics: • Linking ORDERS and CUSTOMERS forms by using a global variable • Using built-ins to check whether the ORDERS form is running • Using global variables to restrict a query in the ORDERS form Copyright  Oracle Corporation........................... All rights reserved................................................ Note For solutions to this practice.....................................

...................... Practice 23 Overview In this practice.................... Oracle Forms Developer: Build Internet Applications I 23-23 .....................................................................................Practice 23 Overview .......................................................................... • Linking ORDERS and CUSTOMERS forms by using a global variable • Using built-ins to check whether the ORDERS form is running • Using global variables to restrict a query in the ORDERS form .......................... you produce a multiple form application by linking the CUSTGXX and the ORDGXX form modules............................................................................

............. Run the CUSTGXX form... Customer_Id is updated when the current Customer_Id changes....... Write a When-Create-Record trigger on the S_ORD block that uses the value of GLOBAL........................ Remember that you need to use the module name in the GO_FORM built-in..... Add a trigger to ensure that queries on the S_ORD block are restricted by the value of GLOBAL.. Define a trigger for CONTROL................. passing control to it............ Are the relative positions of the two forms adequate? Change the window location of the ORDGXX form............ Use the FIND_FORM built-in for this purpose.................... then open the ORDGXX form from the new button.... compile........ Save and compile each form.. and the filename in the OPEN_FORM built-in..............Customer_Id as the default value for S_ORD....... Use OPEN_FORM.... Add code to the CUSTGXX form so that GLOBAL........Lesson 23: Introducing Multiple Form Applications . Alter the Orders_Button trigger in CUSTGXX so that it uses GO_FORM to pass control to ORDGXX if the form is already running............ then opens the ORDGXX form.........Orders_Button that initializes GLOBAL.. Deploy the application to the Web. 23-24 Oracle Forms Developer: Build Internet Applications I .................. Make sure that the internal name of the ORDGXX form (in the Object Navigator) matches the filename of the form..... ...... if required............................... and run the form to test that it works as a stand-alone.... create a CONTROL block button called Orders_Button..... and set the variable to NULL if it does not yet exist.................. create a Pre-Form trigger to ensure that a global 2 3 4 5 6 7 8 9 10 variable called Customer_Id exists.......Customer_Id.... Write a Pre-Query trigger on the S_ORD block that assigns the value of the global variable to the Customer_Id item..................... Save.............Customer_Id. In the CUSTGXX form......... Use the DEFAULT_VALUE built-in.. Practice 23 1 In the ORDGXX form..Customer_Id with the current customer’s ID..

........................A .... Practice Solutions .....

..................... Select Tools—>Preferences from the default menu system.. Click OK........................ Select Tools—>Preferences from the default menu system.. No formal solution.. Form Builder gives you the option of saving the file to the file system or the database............... If you cannot expand the node........ No formal solution..... . Collapse the Data Blocks node................................................. connect to the database and try again....................... Expand the Data Blocks node.. No formal solution. Click Cancel........... No formal solution.............. Change your preferences so that when you open or save a file. Click the Access tab in the Preferences dialog box.Appendix A: Practice Solutions ...fmb form module.. Try to open the Customers... Click the Access tab in the Preferences dialog box............ Modify your preferences so that Form Builder will access the file system only.......... Click OK.... Open the Orders...... Click the File option................... Notice that the module access dialog box is displayed.........fmb form module from the Open Dialog window...... Close the ORDERS form...... and select “Open an existing form” from the 2 3 4 5 6 7 8 9 Welcome page.fmb form module................ No formal solution............... Expand the Database Objects node....... A-2 Oracle Forms Developer: Build Internet Applications I ....... No formal solution..... What do you see below this node? No formal solution.......... Practice 1 Solutions 1 Invoke Form Builder.. Click the Ask option... Open the Summit.......

...................... With the rectangle still selected...................................... Select the Rectangle tool from the Tool Palette and draw a rectangle around the three summit shapes........ d Draw a box with no fill around the summit shapes......................... Invoke the Layout Editor.. Align the objects along the bottom edge..... Shift-click each of the three shapes to select them together.................................................. and exit Form Builder. Select the middle summit shape........... Move them to the top-right corner of the layout............ a ......... At the end...................... Oracle Forms Developer: Build Internet Applications I A-3 ... b Move the three summit shapes to the top-right corner of the layout..........Practice 1 Solutions .......................... Select Tools—>Layout Editor from the default menu system........... and select Arrange—>Send to Back...... click the Fill Color tool and select No Fill......fmb form module to match the screenshot shown below.. save your changes...................... c Select the summit shape in the middle and place it behind the other two shapes...... 10 Change the layout of the Summit......................

.......... i Save the form module.......... h Resize the scroll bar to make it the same height as the three records in the Emp block....................... Select the text tool from the Tool Palette and enter the text above the rectangle....................... and exit Form Builder... Add the text Summit Sporting on top of the box... Select the scroll bar and resize it with the mouse.... Select the First_Name and Last_Name items together............................Appendix A: Practice Solutions .... and click the Align Top button............................................ Select and move the Id item up...... Choose a suitable font size and style.. f Move the Name.................. and Region_Id items to match the screenshot.......... Shift-click the Id and Region_Id items to select them together............... Id.. e ....... g Move the First_Name item up to align it at the same level as the Last_Name item..... In the Object Navigator... A-4 Oracle Forms Developer: Build Internet Applications I ..... select File—>Save and then File—>Exit.......................................... Select and move the Name item to the right with the mouse.......... Click the Align Left button to align these two items...........................................

......... Move to the Name item and enter the search value Womansport................. No formal solution................................ set the Runform parameter Look and Feel to Oracle......... No formal solution...... Notice that the status line displays the words ENTER-QUERY.... No formal solution.. 4 Execute a restricted query to retrieve information about the customer with the ID of 212.............. Execute the query (press [Ctrl] + [F11] or select Query—>Execute from menu)........................... Select Query—>Execute.. Notice that the status line displays the words ENTER-QUERY.......... or press [Execute Query].......... Enter the Runform parameters and run the Customers form. Put the form module in Enter Query mode (press [F11] or select Query—>Enter from menu)............... Oracle Forms Developer: Build Internet Applications I A-5 ... Put the form module in Enter Query mode (press [F11] or select Query—>Enter from menu)......... 2 Select Help—>Keys from the menu............... Notice the different appearance of the user interface.............. Press [Up] and [Down] to browse through the records returned.. Notice that only one record is retrieved... No formal solution.... 5 Exit this run-time session... 6 Start another run-time session on the Web using the form module Customers........... ......... Double-click the shortcut on your desktop for Run a Form on the Web............ For this session........... Practice 2 Solutions Running a Forms Application on the Web 1 Run the form module Customers on the Web............................. 3 Execute an unrestricted query.............. Notice that only one record is retrieved...... Execute the query (press [Ctrl] + [F11] or select Query—>Execute from menu)....... or click the Execute Query toolbar button.... Move to the Id item and enter the search value 212.... 7 Execute a restricted query to retrieve the “Womansport” record....Practice 2 Solutions .........

........ Select the Credit radio button.......................... ... Click the Image Off button and notice that the image item is no longer displayed.............. The Inventory block is displayed in a separate window. Query only those orders with a payment type of Credit. No formal solution......... Try each of these restricted queries: ............. Running a Forms Session in Client-Server 1 Start a Forms run-time session by using the form module Customers........Retrieve all customers based in the USA with a credit rating of Excellent....... Enter Excellent in the Credit Rating item........... Click the Orders button......... Type San% in the City item. No formal solution.. Select Query—>Execute. Put the form module in Enter Query mode.........Retrieve all cities starting with San........ Select Query—>Enter..... Select Query—>Enter.. Exit the run-time session......... Click the Image On button and notice that the image item is displayed........... Execute a query to get stock information... ........ Click the Billing tab to move to the Sales_Rep_ID item and enter the search criteria >13.... Select Query—>Enter.Appendix A: Practice Solutions . No formal solution..... 8 Execute a restricted query to retrieve customers with a sales rep ID 9 10 11 12 13 14 greater than 13............................................ Select Query—>Execute............................... Execute the query...................... Display the customer details for Big John’s Sports Emporium and click the Orders button to move to the Orders form module. Move to the first record in the Item block and click the Stock button.......... Enter USA in the County item. Press [Next Record] until you see Big John’s Sports Emporium...... A-6 Oracle Forms Developer: Build Internet Applications I ................. Select Query—>Execute.....................

. Delete the line item for your order and save the change................................ Now attempt to delete your order and save the change. Notice that the function keys are defined differently in a client-server environment than they are for Web deployment...................................... What happens? Move to the ORDER block and select Record—>Remove............. Notice that some items are already populated with default values....... Exit the run-time session. Click the Save button.. 2 Select Help—>Keys from the menu... Move to the ORDER block and select Record—>Insert..................... . Oracle Forms Developer: Build Internet Applications I A-7 .. No formal solution........ Update the order that you have just placed and save the change............ or press the Insert button on the toolbar............ Move to the ITEM block and enter the following: Item Product ID Quantity Value 50530 2 5 Save the new records.. No formal solution... 6 7 8 9 10 Select Action—>Save or click the Save button.. Enter the following: Item Date Shipped Payment Type Order Filled Value Today’s date (DD-MON-YYYY) Cash (radio group button) No (unchecked) 4 Insert a new record in the ITEM block.... Click the Save button........ insert a new record in the ORDER block...... Move to the Item block and select Record—>Remove...... Change the Date Shipped to next Monday and save the change....... 3 For the customer Big John’s Sports Emporium. as detailed below......................................................................... Attempt to delete the order that you have just placed................. Move to the ORDER block and select Record—>Remove.................................Practice 2 Solutions .........

.. Edit the name............. select a new canvas and make sure the Type field is set to “Content........ No formal solution.......................... 2 Save the new module to a file called CUSTGXX.... and click Finish.... then create a new form module by selecting File—>New—>Form or by clicking the Create Toolbar button... .... In the Layout Wizard................. Practice 4-1 Solutions 1 Create a new form module............... If you are not already in Form Builder.......... Run your form module and execute a query.. Set the Table or View field to S_CUSTOMER...Appendix A: Practice Solutions .... Set the frame title to Customers..... edit the name.......... Select the form module....... Use Tools—>Data Block Wizard to create a block. run Form Builder and create a new form module by using the Welcome Wizard.. The cursor changes to an I-beam.. where XX is the group number that your instructor has assigned to you....... and then press [Return]................... ...Click the name....... Base it on the S_CUSTOMER table and include all columns.......... then call the Layout Wizard” option........ rename the canvas as CV_CUSTOMER: .... Create a new single block by using the Data Block Wizard.. Set the Style to Form...The cursor changes to an I-beam................ Set the Frame Title to Customers.......... A-8 Oracle Forms Developer: Build Internet Applications I ..................... If you are already in Form Builder....... Click the name....Press [Return].. .... Navigate through the fields..” Include all items.... Exit the run-time session and return to Form Builder..... 3 Change the form module name in the Object Navigator to CUSTOMERS..... Select the block type as Table or View..... Click the Next button........... Click the Refresh button and click the >> button to include all columns....... ..... and select “Create the data block.... and click the Finish button.......... Display the S_CUSTOMER block on a new content canvas called CV_CUSTOMER and show just one record at a time...............Select the canvas.. In Object Navigator..

........................................................Practice 4-1 Solutions .................. Reposition the items by dragging and dropping them....... No formal solution...... Deploy your form module on the Web and execute a query.................. .................. Oracle Forms Developer: Build Internet Applications I A-9 ........ 4 In the Layout Editor....................................................................................................................................... 5 Save and compile the form module................ reposition the items so that the canvas resembles the following screenshot............ Hint: First resize the canvas and the frame..............

.. Use a tabular style layout and include a scroll bar......................... Use Tools—>Data Block Wizard to create a block....... and click Finish.... Use a form style layout..... Include all columns....... Display all items except ORD_ID on the CV_ORDER canvas...... 2 Create a new block by using the Data Block Wizard................. Set Style to Form...... Select block type as Table or View..... Practice 4-2 Solutions 1 Create a new form module...... Click the Create Relationship button. select a new canvas and make sure the Type field is set to “Content. In the Layout Wizard. Set the Table or View field to S_ORD...... .. Base the block on the S_ITEM table and include all columns.. Display six records in this detail block on the same canvas as the master block........... then call the Layout Wizard” option.. In the Object Navigator... Select S_ORD block as the master block. Base it on the S_ORD table and include all columns except TOTAL.........Appendix A: Practice Solutions ..... In the same module........... Set the frame title to Items............... Set the frame title to Orders........ Select Canvas as CV_ORDER.................. A-10 Oracle Forms Developer: Build Internet Applications I ............. moving the S_ITEM block after the S_ORD block......... Click the Refresh button and include all columns except Total...... Change the order of the blocks in the Object Navigator.............. Set Frame Title to Orders.. create a new block by using Tools—>Data Block Wizard............. Create a new block by using the Data Block Wizard............. Use the Layout Wizard to create a layout.... Set the Base Table to S_ITEM......... Click the Next button............................. select “Create the data block...... Create a new form module by selecting File—>New—>Form or by clicking the Create Toolbar button... and click Finish..” Include all items............. Create a relationship and select the master block as S_ORD....... rename the canvas as CV_ORDER.. Select the block type as Table or View.. Display the S_ORD block on a new content canvas called CV_ORDER and show just one record at a time.........

... In the Object Navigator..... move the S_INVENTORY block after the S_ITEM block... In the same module.... Include all columns except the OUT_OF_STOCK_EXPLANATION column..... rename the canvas to CV_INVENTORY................. Include all items............ Do not change any prompts.. 4 Create a new block based on S_INVENTORY (do not create any relationships with other blocks at this time) to display on a different canvas. Set the Base Table to S_INVENTORY...... Do not change any prompts... Oracle Forms Developer: Build Internet Applications I A-11 . move the S_INVENTORY block after the S_ITEM block..... and exclude the OUT_OF_STOCK_EXPLANATION column from the definition........ In the Object Navigator... drag and drop the S_ITEM block to a position below the S_ORD block... In the Object Navigator...... Do not create any relationships between blocks at this stage.. In the Object Navigator... Use the Layout Wizard to create a layout............. Set the Records Displayed to 6................... Base it on the S_INVENTORY table......... where XX is the group number that your instructor has assigned to you...... Include all items except ORD_ID.......... create a new block by using Tools—>Data Block Wizard..Practice 4-2 Solutions ............................................. Set the Style to Tabular......... Select block type as Table or View...... Set the frame title to Stock......... No formal solution...... Select a New Canvas......... Select the Display Scrollbar check box..... Use a tabular style layout...... Set the Frame Title to Items.............. This step may only be necessary if you created the block manually............. Set the Displayed Records to 4....... and include a scroll bar........ Display four records in this block and ensure that they are displayed on a new content canvas called CV_INVENTORY.... Set the Style to Tabular... Select the Display Scrollbar check box........................ ................ Set the Frame Title to Stock.... 3 Save the new module to a file called ORDGXX.

.product_id and click the OK button... Select the Deferred check box............ and then uncheck the Auto Query check box.......................... Select the frame for the S_ITEM block under the CV_ORDER canvas in the Object Navigator or in the Layout Editor........ and click Finish............... select the frame that is associated with the S_INVENTORY data block..... First select the relevant frame in the Layout Editor............. Change the prompt for the Quantity Shipped item to Shipped.................. In the Object Navigator or in the Layout Editor.......... Navigate through the blocks so that you see the S_INVENTORY block......... Create the relation by selecting the word “RELATIONS” in the S_ITEM block in the Object Navigator and clicking the Create button............. Ensure that line item records can be deleted independently of any related inventory............. Select the Items tab page........ change the prompt for Amount in Stock to In Stock by using the Layout Wizard....... In the S_INVENTORY data block. . and return to Form Builder... and click Finish. Select the Isolated radio button......... Enter the join condition s_item........ Select the Items tab page and change the prompt for Amount in Stock to In Stock.product_id = s_inventory. and select Tools—>Layout Wizard from the menu... No formal solution.. change the prompt for the Quantity Shipped item to Shipped by using the reentrant Layout Wizard.Appendix A: Practice Solutions ................. A-12 Oracle Forms Developer: Build Internet Applications I ..... Save and compile your form module... Exit the run-time session............. 5 Create a relation called S_Item_S_Inventory explicitly between the 6 7 8 9 S_Item and S_Inventory blocks.............. and then use the Layout Wizard................ Select Tools—>Layout Wizard from the menu....................... Change the form module name in the Object Navigator to ORDERS and save......... On the S_ITEM block.. Select S_INVENTORY as the detail block......................... close Netscape Communicator. Run your form module on the Web. The New Relation dialog box appears. No formal solution......... Set the coordination so that the Inventory block is not queried until you explicitly execute a query. Execute a query.......

.. Insert Allowed... Set the Database Data Block..... Set the Query Data Source Type property to None............ Select Data Blocks node in the Object Navigator....Practice 5 Solutions .. Select the “Build a new data block manually” option...................................... Rename this new data block as CONTROL... Set the Query Data Source Type property to None....... Create a new block manually........ Remove the Title property value and set the Update Layout property to Manually..... and Delete Allowed properties to No... Query Allowed.............. and open the Property Palette......... select the frame that covers the S_CUSTOMER block and open the Property Palette................. Practice 5 Solutions CUSTGXX Form 1 Create a control block in the CUSTGXX form................. 4 Save and run the CUSTGXX form.. or select Navigator—>Create option from menu to create a new data block.. Move the CONTROL block after the S_CUSTOMER block........... Test the effects of the properties that you have set. Note: The Compilation Errors window displays a warning that advises you that the CONTROL block has no items.. Oracle Forms Developer: Build Internet Applications I A-13 ......... and set the Update Layout property to Manually....... Set the Database Data Block............... In the Property Palette for the S_CUSTOMER block...... Find the Database category in the Property Palette... ....... Query Allowed............. Click the right mouse button on this block. Leave other properties as default....... This is expected (until you add some items to the CONTROL block in a later lesson)......... Update Allowed......... Update Allowed......... and rename this block CONTROL..... No formal solution... and Delete Allowed Database properties to No.. Leave other properties as default. Click the Create icon in the Object Navigator.......... Insert Allowed..... In the Object Navigator......... In the Layout Editor..... set the ORDER BY Clause property to ID.. move the CONTROL block after the S_CUSTOMER block................. 3 Set the frame properties for the S_CUSTOMER block as follows: Remove the frame title........... 2 Ensure that the records retrieved in the S_CUSTOMER block are sorted by the customer’s ID..........

.. Using the Font Picker. Set the Database Data Block.................. Query Allowed........ set the font to MS Serif italic 10 point...... In the Property Palette. Insert Allowed......) Use the multiple selection feature on both data blocks to set the relevant block property to use this visual attribute... Select the Data Blocks node in the Object Navigator. Click the right mouse button on this block.. (If that font is not available on your window manager...... and create a new visual attribute.. Leave other properties as default. Create a new block manually........ Create a visual attribute called Current_Record.. Query Allowed.. Set the Query Data Source Type property to None........................ In the Object Navigator.... Using the Color Picker......... Set the Database Data Block................ and Delete Allowed database properties to No.. 6 Ensure that the current record is displayed differently from the others in both the S_ITEM and S_INVENTORY blocks..... In the Object Navigator. Update Allowed............ A-14 Oracle Forms Developer: Build Internet Applications I .... Find the Database category in the Property Palette... Rename this new data block CONTROL..................... Click the Create icon in the Object Navigator........... (If these colors are not available on your window manager........... and rename this block CONTROL......... Select the Foreground Color property and press the button.... The ..................... Leave other properties as default... set the foreground color to white and the background color to dark cyan...) Using the Pattern Picker.............. move the CONTROL block after the S_INVENTORY block.. Position the CONTROL block after the S_INVENTORY block in the Object Navigator......... use other colors instead... select the Visual Attributes node.... or select the Navigator—>Create option from the menu to create a new data block..... use any available font. choose any fill pattern...... and Delete Allowed properties to No.. Update Allowed..Appendix A: Practice Solutions ......... Set the Query Data Source Type property to None..... Insert Allowed.... ORDGXX Form 5 Create a CONTROL block in the ORDGXX form....... set the Name property to CURRENT_RECORD........... and open the Property Palette.... Select the “Build a new data block manually” option............................

... 7 8 9 10 11 Color Picker dialog box is displayed... Select MS Serif italic 10 point............. select the Font category heading.... and then open the Property Palette.... select the S_ITEM block and open the Property Palette.. In the Property Palette. Repeat the process to set the Background Color to Dark Cyan.................. No formal solution...... select frames under the Canvases node and open the Property Palette..............) Click the More button and the Font dialog box appears.. For the S_ITEM block.......... change the number of records displayed to 4 and resize the scroll bar accordingly. The Pattern Picker dialog box is displayed....... For the S_ITEM data block..... Set the property that causes automatic navigation to Next Record...... set the ORDER By Clause property to ITEM_ID............................................... Deploy your form on the Web.... Select any pattern........ Select the Fill Pattern property and press the button... In the Object Navigator....................... Set Foreground Color to White...... Ensure that the records retrieved in the S_ITEM block are sorted by the ITEM_ID........ Oracle Forms Developer: Build Internet Applications I A-15 ... In the Object Navigator..................Practice 5 Solutions ..... (Do not select any of the properties under the Font category heading........... set the Navigation Style to Change Record............ For the S_ITEM block.... Set the Number of Records Displayed property to 4.................. and click the OK button............ ...... Set the Current Record Visual Attribute Group property to CURRENT_RECORD... when the user uses [Next Item] to exit the last item of a record in the S_ITEM block....... Test the effects of the properties that you have set.................... to use the multiple selection feature.. Save and compile the ORDGXX form. select both of the S_ITEM and the S_IVENTORY blocks by pressing the [Shift] key and the left mouse button... Remove the Title property value and set the Update Layout property to Manually........ In the Object Navigator.. Set the frame properties for all blocks as follows: Remove the frame title and set the Update Layout property to Manually.....

......... resize and reposition the items.........s_customer_id....... For ID... Use the S_CUSTOMER_ID sequence....................... Use the screenshot and the following table as a guide.................. set Multi-line to Yes and set Height to 65.......... 4 In the CUSTGXX form.... Resize items by setting the width according to the following property table.................... select and delete the Region_Id item.............................................nextval... set Initial Value to :sequence............... In the Layout Editor........... 2 Make sure that the Comments item accepts multiline text to display........ For the Comments item................................................................................ Reorder the items in the Object Navigator... new customer number for each new record and ensure that it cannot be changed......... Practice 6 Solutions CUSTGXX Form 1 Remove the Region_Id item. A-16 Oracle Forms Developer: Build Internet Applications I .......... Item ID NAME ADDRESS CITY STATE COUNTRY ZIP_CODE PHONE CREDIT_RATING SALES_REP_ID COMMENTS Suggested Width 60 195 195 195 130 195 85 160 65 65 236 ...............Appendix A: Practice Solutions .............. 3 Automatically display a unique..

............... Oracle Forms Developer: Build Internet Applications I A-17 ...................................................................................................................................................... 5 Save and compile your form.............................. No formal solution............................ This will be addressed in a later lesson........ .... Deploy the form on the Web to test the changes....................... Note: The entire form may not be visible at this time................................Practice 6 Solutions ................

.. or query operations on this item and make sure that navigation is possible only by means of the mouse. Set the Prompt text to Sales Rep Name. Create a text item and name it Sales_Rep_Name......... Query Allowed... Set the Database Item........ Ensure that Item_Total is not associated with the S_ITEM table.. Allow numeric data only and display it by using a format of 999G990D99. Create a text item and name it Customer_Name... Insert Allowed........ Item Type should be set to Text Item..... Query ......... 7 In the S_ORD block.... Update Allowed.............. 8 Set the relevant property for Date_Ordered........... create a new text item called Item_Total........ For Date_Ordered. and Keyboard Navigable properties to No........ Insert Allowed.. Display this item on CV_ORDER canvas.... and Keyboard Navigable properties to No.... Set the Prompt to Sales Rep Name......... Item Type should be set to Text Item. Update Allowed....Appendix A: Practice Solutions ...... ORDGXX Form 6 In the S_ORD block... create a new text item called Customer_Name................... Set the Prompt text to Customer Name................. Ensure that Sales_Rep_Name is not associated with the S_ORD table.... 9 In the S_ITEM block............. A-18 Oracle Forms Developer: Build Internet Applications I . Display this item on the CV_ORDER canvas.. update.... Insert Allowed.. set Initial Value to $$date$$..... Set the Prompt text to Item Total........ Do not allow insert.............................. Query Allowed. update.. Set the Prompt to Customer Name.. Item Type should be set to Text Item............... or query operations on this item and make sure that navigation is possible only by means of the mouse... Ensure that Customer_Name is not associated with the S_ORD table...... Do not allow insert..... Create a text item and name it Item_Total. create a new text item called Sales_Rep_Name........ Do not allow insert........... Update Allowed............. Set the Database Item. Display this item on the CV_ORDER canvas.... Set the Canvas property to CV_ORDER............................ update. and make sure that navigation is possible only by means of the mouse... Set the Canvas property to CV_ORDER....... or query operations on this item.. so that it displays the current date whenever a new record is entered. Set the Database Item....

.. resize and reposition the items according to the screenshot and the following table....................................... 12 In the ORDGXX form...........................Practice 6 Solutions .. ....... set Justification to Right................. 10 Justify the values of Price..................... For each of the items......... For Quantity_Shipped.. Set the Prompt to Item Total.... Oracle Forms Developer: Build Internet Applications I A-19 ............. Display items use less memory than text items......... They could also be created as display items..... Set the Format Mask to 999G990D99................. Quantity...... Set the Data Type to Number........ so that navigation is possible only by means of the mouse. set Keyboard Navigable and Update Allowed to No. 11 Alter the Quantity_Shipped item................... Set the Canvas property to CV_ORDER........ S_ORD Block Items ID DATE_ORDERED CUSTOMER_ID CUSTOMER_NAME SALES_REP_ID SALES_REP_NAME DATE_SHIPPED PAYMENT_TYPE ORDER_FILLED Suggested Width 40 66 66 116 66 116 66 48 18 S_ITEM Block Items ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED ITEM_TOTAL Suggested Width 20 40 42 26 26 86 Instructor Note Customer_Name and Sales_Rep_Name are created as text items in this course......... Drag and drop items to reposition in navigation order.... and updates are not allowed............................ and Keyboard Navigable properties to No................................... Resize items by setting the width in the corresponding property palette.... and Quantity_Shipped to the right......................... Allowed..

..................................................... ................................. A-20 Oracle Forms Developer: Build Internet Applications I ....... In the property palette for Product_ID.......................... 13 In the S_INVENTORY block. alter the number of instances of the Product_ID................................................... set Number of Items Displayed to 1........................................................ so that it is displayed just once..........................................................................Appendix A: Practice Solutions .....

............ and run the form to test the changes...................... ........... Oracle Forms Developer: Build Internet Applications I A-21 ..................................................................................................... so that it resembles the screenshot...... No formal solution............ Hint: Set the Update Layout property for the frame to Manually......................... 14 Arrange the items and boilerplate on CV_INVENTORY..................... compile........................................... 15 Save.... No formal solution.......................Practice 6 Solutions .............................

........ Select the “New Record Group based on a query” radio button....... Change the name of the LOV to PRODUCTS...........Appendix A: Practice Solutions ... .. click the “Look up return item” button.................. Assign a title of Products to the LOV.......... 2 Save and compile your form.... Click the Next button.....PRODUCT_ID and click the OK button......... Click the Next button to accept the default advanced properties. set the return item to S_ITEM. and assign the LOV a width of 200 and a height of 250.. Set the display width for ID to 25 and click the Next button.... Assign the LOV a width of 200 and a height of 250.. Click the OK button to use the LOV Wizard.........PRODUCT_ID...... Select the “No....... With the ID column selected.............. change the name of the new LOV to PRODUCTS_LOV.. Create a new LOV......... Attach the LOV to the Product_Id item in the S_ITEM block.......... Practice 7 Solutions 1 In the ORDGXX form........ In the SQL Query Statement....... For the ID column...................... name s_product name and click the Next button... Enter the title Products......... create an LOV to display product numbers and descriptions to be used with the Product_Id item in the S_ITEM block. Deploy the form on the Web to test the changes.. enter: SELECT FROM ORDER BY id..... Click the >> button and then the Next button to select both of the record group values..... Use the S_PRODUCT table............... A-22 Oracle Forms Developer: Build Internet Applications I ....... and Name columns. Id... In the Object Navigator........ and click the Next button... Select S_ITEM............................... Position the LOV 30 pixels below and to the right of the upper-left corner......... and set both Left and Top to 30.................... Click the > button and then the Finish button to create the LOV and attach it to the Product_Id item.... No formal solution... I want to position it manually” radio button........... Assign a column width of 25 for ID....................

and click the Next button....... first_name || ’ ’ || last_name Name From s_emp Where title = ’Sales Representative’ Order By last_name and click the Next button.....SALES_REP_ID and click the OK button. Assign the LOV a width of 200 and a height of 250........ Enter the title Sales Representatives. In the SQL Query Statement............ Click the Next button. For the ID column. and assign the LOV a width of 200 and a height of 250. 3 In the CUSTGXX form........ Assign a title of Sales Representatives to the LOV. change the name of the new LOV to SALES_REP_LOV........ Create a new LOV..... Click the >> button and then the Next button to select both of the record group values..................... .............................. and Last_Name columns.................. Select S_CUSTOMER......... enter: Select id.. Attach the LOV to the Sales_Rep_Id item in the S_CUSTOMER block......... click the “Look up return item” button....................... Oracle Forms Developer: Build Internet Applications I A-23 .. Click the Next button to accept the default advanced properties.Practice 7 Solutions ................... Position the LOV 30 pixels below and to the right of the upper-left corner..... Set the display width for ID to 20 and click the Next button....... Assign a column width of 20 for ID...... Change the name of the LOV to SALES_REP_LOV...... Click the OK button to use the LOV Wizard..... and set both Left and Top to 30......SALES_REP_ID.. Select the “No... First_Name. using the LOV Wizard.................... Click the > button and then the Finish button to create the LOV and attach it to the Sales_Rep_Id item.. With the ID column selected.... I want to position it manually” radio button................... Select the “New Record Group based on a query” radio button.... Concatenate the First_Name and the Last_Name columns and give an alias such as Name................ In the Object Navigator..... Id........... Use the S_EMP table....... set the return item to S_CUSTOMER............ create an LOV to display sales representatives’ numbers and their names.......

........ In the Property Palette of the Comments item.. ...... Change the name to Comments_Editor.... create an editor and attach it to the Comments item.............. and run the form to test the changes.. and the Foreground Color property to yellow................. Background Color property to gray........... compile.................................... Resize the window if necessary........ set the Editor property to Comments_Editor...... 4 In the CUSTGXX form................. No formal solution.............. Set the X Position and Y Position properties to 175............ and the foreground color to yellow................... Set the Width property to 450 and the Height property to 250. the background color to gray.........Appendix A: Practice Solutions ... Set the title to Comments...... A-24 Oracle Forms Developer: Build Internet Applications I .............................................. Create a new editor........... Set the title to Comments........ 5 Save............................................................

.................. Enter the corresponding database values in the List Item Value box........ Deploy your form on the Web to test the changes......... Set the Mapping of Other Values to POOR............... Oracle Forms Developer: Build Internet Applications I A-25 . Display any other values as POOR............ so that the elements do not truncate at run time........ set the Label property to Order Filled................ No formal solution...... Ensure that new records display the initial value GOOD. set Item Type to Check Box.... convert the Order_Filled text item to a check box....... Select the Elements in List property and click the More button to invoke the List Elements dialog box.. Practice 8 Solutions 1 In the CUSTGXX form........ Allow only records with Order_Filled values of Y or N to be displayed.... Ensure that new records are automatically assigned the value N... Good.. Set the Check Box Mapping of Other Values to Not Allowed....... Enter the elements Poor... Set the Initial Value to GOOD........................ Set the Initial Value to N....... Open the Layout Editor and resize the item so that elements do not truncate.... In the Layout Editor..... convert the Credit_Rating text item into a pop-up list item..... 3 In the ORDGXX form.............. resize the check box so that its label is displayed to the right.. and Excellent...... Open the Layout Editor and resize the check box so that its label is displayed to the right................... and EXCELLENT... Good............. Remove the existing prompt and set label as Order Filled..........Practice 8 Solutions .......... GOOD..... Set the Value when Checked to Y and Value when Unchecked to N.... Click OK to accept and close the dialog... Delete the Prompt property... ..... Resize the poplist in the Layout Editor......... Set the checked state to represent the base table value of Y and the unchecked state to represent N........... Set the List Style to Poplist... set Item Type to List Item.. For Credit_Rating........... 2 Save and compile the form................ and Excellent to represent database values of POOR. Add list elements of Poor........ For Order_Filled......

... name them Cash_Button and Credit_Button.................... and run the form to test the changes.. For the second button.... Add text Payment type to describe the radio group’s purpose........ Ensure that new records display the default of Cash.......................Appendix A: Practice Solutions ... Use the order of the items in the Layout Editor as a guide. Label to Credit...... compile......... 6 Save..... A-26 Oracle Forms Developer: Build Internet Applications I ...... Drag the items of the S_ORD block according to the visual order of this block..... set Item Type to Radio Group................. For the first button.... create boilerplate text to identify radio buttons as Payment Type............... In the Layout Editor......... ............. and Radio Button Value to CASH............... 4 Convert the Payment_Type text item into a radio group............. For Payment_Type.... Define access keys of S for cash and T for credit........... Create two buttons.... Expand the Payment_Type node....... and Radio Button Value to CREDIT..... Label to Cash... The Radio Buttons node is displayed... Add radio buttons for Cash and Credit to represent database values of CASH and CREDIT........ set Access Key to T.......................................... Set the Initial Value to CASH............. No formal solution..... Set Label to Cash for the Cash radio button and Credit for the Credit radio button...... Use the Layout Editor to position the radio buttons so that both can be seen... set Access Key to S.......................... 5 Reorder the items of the S_ORD block in the Object Navigator...........

.......... Set the Width to 133.............. in the S_ITEM block. create a display item called Description. Change the name to Product_Image... Keyboard Navigable: No.............. Ensure that the block is set to S_ITEM..................................... Image_Description.......................... This should synchronize with the Description item........ 3 Create another display item. Database Item: No........ Set the Name property to Description.................. Display the Layout Editor.......... Place the Display Item to the right of the Product_Id. Set the Maximum Length to 50........... Oracle Forms Developer: Build Internet Applications I A-27 .......... Set the Synchronize with Item to Description... and select the Display Item tool.. Set the Maximum Length property to the same value as the Description item..... 2 Create a single-record image item called Product_Image in the S_ITEM block of the ORDGXX form.. Set the Width to 133.......... Change the name to Image_Description. ensure that the block is set to S_ITEM..... Select the Display Item tool............................. Display the Property Palette for the image... Number of Items Displayed: 1..Practice 9 Solutions ............ Set the Number of Items Displayed to 1.. Ensure that the block is set to S_ITEM........... Select the Image Item tool. Sizing Style: Adjust............... Set the Database Item to No..... Include these properties for the image item: Bevel: Lowered........ Click and drag a box and place it so that it matches the screenshot below... Display the Layout Editor....... ......... Set the Prompt property to Description and the Prompt Attachment Edge property to Top. Place the Display Item to just below the Product_Image......... Set the Database Item to No......... Practice 9 Solutions 1 In the S_ITEM block of the ORDGXX form..... Set the Maximum Length property to 50.. Open the Layout Editor..... Set the Prompt property to Description and display the prompt above the item.

.............. Set the Justification property to Right.. In the Object Navigator..... Size...... Set the Mouse Navigate property to No..................total a summary item and display summaries of the item_total values in the S_ITEM block.............. Display the Layout Editor and ensure that the block is set to CONTROL................ Select the Push Button tool...... select the Item_Total item in the S_ITEM block......... and set the Icon File Name to List.....price..... ... 4 In the CONTROL block of the ORDGXX form..... Set the Keyboard Navigable property to No.. Set the Position...... Set the Number of Items Displayed property to 1.. Set the Keyboard Navigable property to No..... Set the Formula property to :S_ITEM......gif extension)........... Set the Justification property to Right..Appendix A: Practice Solutions ...... Set the Calculation Mode property to Formula....... Make S_ITEM..........ico or ..................... Set the Formula property to :S_ITEM.... A-28 Oracle Forms Developer: Build Internet Applications I ............. Set the Keyboard Navigable property and the Mouse Navigate property to No.................... Resize the push button............ 5 To display item total information..... Set the Calculation Mode property to Formula... Set the Keyboard Navigable property to No.... and open the Property Palette. Use the list file (do not include the ................ Set the Format Mask property to 9G999G990D99.. 6 To display the total of the item totals....... create a new nondatabase item in the S_ITEM block.... set the following properties for the Item_Total item in the S_ITEM block: Set the Justification property to right.quantity_shipped * :S_ITEM..price..... create an iconic button called Product_LOV_Button............... and Prompt properties according to the screenshot...... Ensure that you have set the Query All Records property to Yes for the S_ITEM block.quantity_shipped * :S_ITEM........... Set the Iconic property to Yes.... Create a push button and place it close to the Product_Id.......... Set the Name to Product_LOV_Button...........

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

Set the Keyboard Navigable property to No.
In the Object Navigator, create a new text item in the S_ITEM block.
Set the Name property to TOTAL, and the Prompt property to Order Total.
Set the X Position, Y Position, and Width properties according to the
screenshot.
Set the Canvas property to CV_ORDER.
Set the Data Type property to Number.
Set the Format Mask property to 9G999G990D99.
Set the Justification property to Right.
Set the Number of Items Displayed property to 1.
Set the Query All Records property to Yes for the S_ITEM block; that is
necessary for summary items.
For S_ITEM.total item, set Database Item property to No, Calculation Mode
property to Summary, and Summary Function property to Sum.
Set the Summarized Block property to S_ITEM and Summarized Item
property to item_total.
Set the Keyboard Navigable property to No.

7 Save, compile, and run the form to test the changes. Change the window

size if necessary.
No formal solution.

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

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

8 Perform a query in the ORDGXX form to ensure that the new items do

not cause an error. Did you remember to switch off the Database Item
property for items that do not correspond to columns in the base table?
No formal solution.

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

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

9 Create an iconic button similar to the one created in question 4, in the

CONTROL block of form CUSTGXX. Use the list file (do not include
the .ico or .gif extension). Name the push button
Sales_Rep_Lov_Button, and place it next to Sales_Rep_ID.
Display the Layout Editor and ensure that the block is set to
CONTROL.
Select the Push Button tool.
Create a push button and place it close to Sales_Rep_ID.
Resize the push button.
Set Name to Sales_Rep_LOV_Button.
Set Keyboard Navigable to No.
Set Mouse Navigate to No.
Set Iconic to Yes.
Set Icon File Name to List.
10 Save and compile the form. Deploy the form on the Web to test the
changes.
Note: When you test the form on the Web, the iconic button will have a
different image than the same iconic button in the client-server
environment. This is because the image stored in list.gif is different
from the image stored in list.ico.
No formal solution.

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

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

Practice 10 Solutions
1 Modify the window in the CUSTGXX form. Change the name of the

2
3

4

5

6

window to WIN_CUSTOMER, and change its title to Customer
Information. Check that the size and position are suitable.
In the Layout Editor, look at the lowest and rightmost positions of
objects on the canvas, and plan the height and width for the window.
Change the height, width, and title of the window in the Property
Palette.
Change the Title property to Customer Information.
The suggested size is Width 360, Height 360.
The suggested X, Y positions are 10, 10.
Save, compile, and run the form to test the changes.
No formal solution.
Modify the window in the ORDGXX form. Ensure that the window is
called WIN_ORDER. Also change its title to Orders and Items.
Set the Name property of the existing window to WIN_ORDER.
Set the Title property to Orders and Items.
In the ORDGXX form, create a new window called WIN_INVENTORY
suitable for displaying the CV_INVENTORY canvas. Use the rulers in
the Layout Editor to help you plan the height and width of the window.
Set the window title to Stock Levels and Hide on Exit property to Yes.
Place the new window in a suitable position relative to WIN_ORDER.
Create a new window called WIN_INVENTORY.
Set the size, position, and title in the Property Palette.
The suggested size is Width 460, Height 340.
The suggested position is X 60, Y 30.
Set Hide on Exit to Yes.
Associate the CV_INVENTORY canvas with the window
WIN_INVENTORY. Compile the form. Deploy the form on the Web
and ensure that the S_INVENTORY block is displayed in
WIN_INVENTORY when you navigate to this block.
Set the canvas Window property to WIN_INVENTORY.
Compile and run the form on the Web.
Save the form.
No formal solution.

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

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

Practice 11 Solutions
Toolbar Canvases
1 In the ORDGXX form, create a horizontal toolbar canvas called Toolbar
in the WIN_ORDER window, and make it the standard toolbar for that
window. Suggested height is 30.
Create a new canvas. Set Name to Toolbar and Height to 30. Set
Canvas Type to Horizontal Toolbar and Window to WIN_ORDER.
In the WIN_ORDER Property Palette of the window, set Horizontal
Toolbar Canvas to Toolbar.
2 Save, compile, and run the form to test.
Notice that the toolbar now uses part of the window space. Adjust the
window size accordingly.
No formal solution.
Create three push buttons in the CONTROL block, as detailed below, and place them
on the Toolbar canvas.
No formal solution.
Push Button Name
Stock_Button

Show_Help_Button

Exit_Button

Details
Label: Stock
Mouse Navigate: No
Keyboard Navigable: No
Canvas: Toolbar
Label: Show Help
Mouse Navigate: No
Keyboard Navigable: No
Canvas: Toolbar
Label: Exit
Mouse Navigate: No
Keyboard Navigable: No
Canvas: Toolbar

Suggested positions for the push buttons are shown in the following illustration:

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

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

Stacked Canvases
1 Create a stacked canvas named CV_HELP to display help in the
WIN_ORDER window of the ORDGXX form. Suggested visible size is
Viewport Width 270, Viewport Height 215 (points). Place some
application help text on this canvas.
Create a new canvas.
If the Property Palette is not already displayed, click the new canvas
object in the Object Navigator and select Tools—>Property Palette.
Set the Canvas Type to Stacked. Name the canvas CV_HELP.
Assign it to the WIN_ORDER window.
Display the stacked canvas in the Layout Editor, and create some
boilerplate text objects with help information about the form.
2 Position the view of the stacked canvas so that it appears in the center of
WIN_ORDER. Ensure that it will not obscure the first enterable item.
Do this by planning the top-left position of the view in the Layout
Editor, while showing CV_ORDER. Define the Viewport X and
Viewport Y Positions in the Property Palette. Do not move the view in
the Layout Editor.
In the Layout Editor, display the CV_ORDER canvas and select
View—>Stack Views from the menu, and select CV_HELP from the
list. You can see both canvases in this way. Change Viewport X and
Viewport Y properties in the Property Palette for CV_Help Canvas.
Suggested coordinates: 100, 100.
3 Organize CV_HELP so that it is the last canvas in sequence.
Do this in the Object Navigator. (This ensures the correct stacking order
at run time.)
Drag the Help_Canvas so that it is the last canvas displayed under
the Canvases node.
4 Save and compile the form. Deploy the form on the Web to test the
changes. Note that the stacked canvas is displayed all the time, providing
that it does not obscure the current item in the form.
No formal solution.

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

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

5 Switch off the Visible property of CV_HELP, and then create a push

button in the CONTROL block to hide the Help information when it is
no longer needed. You will add the code later. Display this push button
on the CV_HELP canvas.
Set the Visible Property to No for the CV_HELP.
Create a push button in the CONTROL block with the following
properties:
Push Button Name
Hide_Help_Button

Details
Label: Hide Help,
Canvas: CV_HELP
Mouse Navigate: No

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

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

Tab Canvases
Modify the CUSTGXX form in order to use a tab canvas:
1 In the Layout Editor, delete the frame object that covers the
S_CUSTOMER block. Create a tab canvas. In the Layout Editor, set the
Background Color property to gray, Tab style property to Square, and
Bevel property to None.
In the Layout Editor, select the frame that covers S_CUSTOMER
block and delete.
Click the Tab canvas button in the toolbar and create a tab canvas.
In the Property Palette, set the Background Color property to gray,
Corner Style property to Square, and Bevel property to None.
2 Rename the TAB_CUSTOMER tab canvas. Create three tab pages and
label them as Address, Billing, and Comments.
In the Object Navigator, select this tab canvas and open the
Property Palette. Set the Name property to TAB_CUSTOMER.
In the Object Navigator, expand this tab canvas and create three tab
pages.
Set the tab pages label properties as Address, Billing, and
Comments.
3 Design the tab pages according to the following screenshots. Set the item
properties to make them visible on the relevant tab pages.
In the Object Navigator, select NAME, ADDRESS, CITY, STATE,
COUNTRY, ZIP_CODE, and PHONE items of the S_CUSTOMER block and
open the Property Palette for this multiple selection.
Set the Canvas property to TAB_CUSTOMER.
Set the Tab Page property to the tab page that is labeled Address.
In the Layout Editor, arrange the items according to the following screenshot.

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

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

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
A-37

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

In the Object Navigator, select the CREDIT_RATING and SALES_REP_ID
items of the S_CUSTOMER block and the SALES_REP_LOV button of the
CONTROL block. Open the Property Palette for this multiple selection.
Set the Canvas property to TAB_CUSTOMER.
Set the Tab Page property to the tab page that is labeled Billing.
In the Layout Editor, arrange the items according to the screenshot.

......................................................................................................................................................
A-38
Oracle Forms Developer: Build Internet Applications I

............................. In the Object Navigator........ resize the COMMENTS item according to the screenshot...................................................................... Set the Tab Page property to the tab page that is labeled Comments.......Practice 11 Solutions ................. Set the Canvas property to TAB_CUSTOMER........... Oracle Forms Developer: Build Internet Applications I A-39 ....................................... ...................... In the Layout Editor......................................................................................... select the COMMENTS item of the S_CUSTOMER block.............. and open the Property Palette..

..... A-40 Oracle Forms Developer: Build Internet Applications I ....... Ensure that the user does not move from one tab page to another when tabbing through items........ Deploy the form on the Web..................................................................................................... 4 Reorder the items according to the tab page sequence............. No formal solution....... For example.................... 5 Save and compile the form... ............... Set the Next Navigation Item and Previous Navigation Item properties according to the order of items in the tab pages..................................................... Set the Previous Navigation Item and Next Navigation Items properties for items in the S_CUSTOMER block according to their order in the tab pages.... for the Phone item................ set the Previous Navigation Item property to ZIP_CODE and the Next Navigation Item property to NAME...............................................Appendix A: Practice Solutions ............

..................... 4 In the ORDGXX form..... END IF..................................... No formal solution... compile.............Sales_Rep_Lov_Button: IF SHOW_LOV(’sales_rep_lov’) THEN NULL.. To create the When-Button-Pressed trigger... 5 Write a trigger that exits the form when the Exit_Button is selected..........Exit_Button: EXIT_FORM.... and select the When-Button-Pressed trigger from the list...... Practice 13 Solutions 1 In the CUSTGXX form.... and use the “Paste Name and Arguments” feature................... END IF. use the Smart triggers feature........................ When-Button-Pressed on CONTROL...... Find the relevant built-in in the Object Navigator under built-in packages.... Oracle Forms Developer: Build Internet Applications I A-41 . When-Window-Closed at the form level: EXIT_FORM...........................Practice 13 Solutions .... . compile..................... No formal solution.... select Smart triggers in the pop-up menu.. 6 Save...............Products_Lov_Button: IF SHOW_LOV(’products_lov’) THEN NULL. and run the form...... Select the Sales_Rep_Lov_Button in the Object Navigator................. and run the form........ write a trigger to display the Sales_Rep_Lov when the Sales_Rep_Lov_Button is selected............... 2 Create a When-Window-Closed trigger at the form level in order to exit form........... write a trigger to display the Products_Lov when the Products_Lov_Button is selected...... 3 Save... press the right mouse button. When-Button-Pressed on CONTROL.................... When-Button-Pressed on CONTROL.......

..... When-Button-Pressed on CONTROL................................................................... 10 Create a When-Button-Pressed trigger on CONTROL........ of course............... if appropriate................... When-Button-Pressed on CONTROL.. or move the stacked canvas to a position that does not overlay enterable items........................ A-42 Oracle Forms Developer: Build Internet Applications I . Use the HIDE_VIEW built-in to achieve this................... The stacked canvas. could also be shown in its own window.Hide_Help_Button that hides the CV_HELP........Stock_Button that uses the GO_BLOCK built-in to display the S_INVENTORY block...... is displayed only if the current item will not be obscured............... When-Button-Pressed on CONTROL......................................... No formal solution...... CV_HELP........... that the first entered item in the form is one that will not be obscured by CV_HELP..Stock_Button: GO_BLOCK(’S_INVENTORY’). You might decide to advertise Help only while the cursor is in certain items.... .........Appendix A: Practice Solutions ........... The CV_HELP canvas. Deploy the ORDGXX form on the Web to test......Show_Help_Button: SHOW_VIEW(’CV_HELP’). at least.. 8 Create a When-Button-Pressed trigger on CONTROL........ 7 Create a When-Button-Pressed trigger on CONTROL.....Show_Help_Button that uses the SHOW_VIEW built-in to display the CV_HELP.. Ensure....Hide_Help_Button HIDE_VIEW(’CV_HELP’)..................... 9 Save and compile the form...

................ BEGIN v_lov:= SHOW_LOV(p_lov)......................................................................Sales_Lov_Button in order to call this procedure......... END.............................. Set a breakpoint in one of your triggers.... ELSE MESSAGE(’You have just cancelled the List of Values’).p_text in VARCHAR2) IS v_lov BOOLEAN........... .. When-Button-Pressed on CONTROL............. Try stepping through the code to monitor its progress... ’Sales Representative’).................................... create a procedure that is called List_Of_Values........ No formal solution.....Practice 14 Solutions .txt file: PROCEDURE list_of_values(p_lov in VARCHAR2............. Oracle Forms Developer: Build Internet Applications I A-43 ..FMB file................ You can use CUSTWK14. 2 Modify the When-Button-Pressed trigger of CONTROL............ Practice 14 Solutions 1 Open your CUSTGXX....................... END IF. 3 Compile and run your form in Debug mode. and investigate the call stack.fmb for the completed form........ IF v_lov = TRUE THEN MESSAGE(’You have just selected a ’||p_text).................... Import code from the pr14_1....Sales_Lov_Button: LIST_OF_VALUES(’SALES_REP_LOV’............. In this form.

............payment_type = ’CREDIT’ THEN SELECT credit_rating INTO v_credit FROM S_CUSTOMER WHERE :S_ORD..................... When-Radio-Changed on S_ORD........................’EXCELLENT’) THEN :S_ORD... Set the Label property to Image Off............. Create a button and place it on the toolbar...... write a trigger that fires when the payment type changes... Display the Layout Editor.. END.......... Set the Canvas property to Toolbar.. 2 In the CONTROL block... Set the Label property to Image Off. Practice 15 Solutions 1 In the ORDGXX form............ Set the Keyboard Navigable property to No................ create a new button called Image_Button and position it on the toolbar........... MESSAGE(’This customer must pay cash’).Appendix A: Practice Solutions ... BEGIN IF :S_ORD. END IF. Set the Mouse Navigate property to No.............Payment_Type: DECLARE v_credit s_customer...................................................customer_id = id................txt file.. END IF............ Select the Button tool.payment_type := ’CASH’... You can import the pr15_1........................... . IF v_credit NOT IN(’GOOD’................ Open the PL/SQL Editor and select File—>Import Text................... A-44 Oracle Forms Developer: Build Internet Applications I ...credit_rating%type............... Set the Name to Image_Button..... allowing only those customers with a good or excellent credit rating to pay for orders on credit..

.... SET_ITEM_PROPERTY(’CONTROL...... VISIBLE)=’TRUE’ THEN SET_ITEM_PROPERTY(’S_ITEM. PROPERTY_TRUE)....... 3 Import the pr15_3. ...... the visible property toggles to True for both the Product Image item and the Image Description item........... PROPERTY_FALSE). Finally..’Image On’)....... If the current value is True............Practice 15 Solutions .......... LABEL. the visible property toggles to False for both the Product Image item and the Image Description item............. 4 Save and compile the form..image_button’...... SET_ITEM_PROPERTY(’S_ITEM.................. VISIBLE.... SET_ITEM_PROPERTY(’S_ITEM... ELSE SET_ITEM_PROPERTY(’S_ITEM.. SET_ITEM_PROPERTY(’CONTROL...... The file contains code that determines the current value of the visible property of the Product Image item........image_button’..... VISIBLE................product_image’.. Oracle Forms Developer: Build Internet Applications I A-45 ...........product_image’............ the label changes on the Image_Button to reflect its next toggle state.... VISIBLE.. LABEL........ PROPERTY_FALSE)........................... No formal solution....image_description’........ PROPERTY_TRUE)...... ’Image Off’)......................... Open the PL/SQL Editor and select File—>Import Text...Image_Button: IF GET_ITEM_PROPERTY(’S_ITEM.... END IF.......... When-Button-Pressed on Control.......image_description’. However................txt file into a trigger that fires when the Image_Button is clicked.... VISIBLE... Deploy the form on the Web.. if the visible property is currently False..........................product_image’......

..............Payment_Type: DECLARE n NUMBER................................customer_id = id..... END....................... 2 Alter the When-Radio-Changed trigger on Payment_Type to show the Payment_Type_Alert instead of the message when a customer must pay cash....... Set Alert Style to Caution.......... Set Button1 Label to OK........payment_type = ’CREDIT’ THEN SELECT credit_rating INTO v_credit FROM S_CUSTOMER WHERE :S_ORD.......... Set Title to Question.................. END IF................................. Practice 16 Solutions 1 Create an alert in ORDGXX called Payment_Type_Alert with a single OK button. Set Name to PAYMENT_TYPE_ALERT...... Set Message to “This customer must pay cash!” Remove the labels for the other buttons........ BEGIN IF :S_ORDER........... A-46 Oracle Forms Developer: Build Internet Applications I ...... Set Alert Style to Stop. ........ Set Button1 Label to Yes.......................... Set Button2 Label to No.................. v_credit S_CUSTOMER. When-Radio-Changed on S_ORD. 3 Create a generic alert called Question_Alert that allows Yes and No replies. IF v_credit not in(’GOOD’.... Set Name to QUESTION_ALERT.......Appendix A: Practice Solutions ...payment_type := ’CASH’...........credit_rating%type.... END IF.... Set Title to Payment Type... n := SHOW_ALERT(’payment_type_alert’)..................................’EXCELLENT’) THEN :S_ORD.... Create an alert... The message should read “This customer must pay cash!” Create an alert.....

............. Deploy the form on the Web to test............................. IF SHOW_ALERT(’Question_Alert’) = ALERT_BUTTON1 THEN EXIT_FORM............ ..........Practice 16 Solutions ...... No formal solution.................... END IF.......................... ’Do you really want to leave the form?’).... 4 Alter the When-Button-Pressed trigger on CONTROL....................................... When-Button-Pressed on CONTROL............................................ Oracle Forms Developer: Build Internet Applications I A-47 ......... 5 Save and compile the form................... ALERT_MESSAGE_TEXT...........Exit_Button: SET_ALERT_PROPERTY(’Question_Alert’.................................Exit_Button that uses Question_Alert to ask the operator to confirm that the form should terminate.....................................

................ A-48 Oracle Forms Developer: Build Internet Applications I ....... 3 Ensure that the Exit_Button has no effect in Enter Query mode..................... Post-Query on S_ORD block: SELECT C....... Post-Query on S_ITEM block: SELECT name INTO :S_ITEM...................... Set Fire in Enter Query Mode property to No for the When-Button-Pressed trigger......id = C........... ......customer_name....Appendix A: Practice Solutions ........................ write a trigger that populates the Customer_Name and the Sales_Rep_Name for every row fetched by a query on the S_ORD block..... :S_ORD..........................name......customer_id = C.........id.. S_EMP E WHERE E...sales_rep_name FROM S_CUSTOMER C..........description FROM S_PRODUCT WHERE :S_ITEM.............. Practice 17 Solutions 1 In the ORDGXX form..last_name INTO :S_ORD.. 2 Write a trigger that populates the Description for every row fetched by a query on the S_ITEM block........product_id = id.......... Ensure that the When-Radio-Changed trigger has no effect in Enter Query mode........................ Set Fire in Enter Query Mode property to No for the When-RadioChanged trigger.......................... E..............................sales_rep_id AND :S_ORD......................

......txt file into the Pre-Query Trigger.............. 5 Add a check box called CONTROL.. END IF.Case_Sensitive as shown below) to it........ Set the Mouse Navigate property to No.............exact_match... Add another check box (called CONTROL........... Set the initial value property to Y... When-Checkbox-Changed trigger on the CONTROL.........Case_Sensitive to the form so that the user can specify whether or not a query for a customer name should be case sensitive..... END IF..... and create the following trigger................ add a check box (called CONTROL.............. You can import the pr17_4......Exact_Match as shown below) to the CONTROL block and create the following trigger........) You can import the pr17_5.. 4 Adjust the default query interface.. (If a nonexact match is allowed........ Add a check box called CONTROL........ ’Y’ ) = ’N’ THEN :S_CUSTOMER....CASE_INSENSITIVE_QUERY.......................... ELSE SET_ITEM_PROPERTY(’S_CUSTOMER.. CASE_INSENSITIVE_QUERY..name’....... the search value can be part of the table value...........case_sensitive....... In the CONTROL block..name := ’%’ || :S_CUSTOMER...........Case_Sensitive item (checkbox): IF NVL(:CONTROL.. PROPERTY_TRUE)....... Open the CUSTOMERS form module................. Pre-Query trigger on the S_CUSTOMER block: IF NVL( :CONTROL...... Set the Mouse Navigate property to No................txt file into the When-Checkbox-Changed trigger... PROPERTY_FALSE)..... Set the initial value property to “Y”..name’... Oracle Forms Developer: Build Internet Applications I A-49 .........Practice 17 Solutions ............ ......... ’Y’) = ’Y’ THEN SET_ITEM_PROPERTY(’S_CUSTOMER...........name || ’%’.....................Exact_Match to the form so that the user can specify whether or not a query condition for a customer name should exactly match the table value..

................. and Sales_Rep_Id items whenever validation occurs on Customer_Id..... END IF.............sales_rep_id............................customer_name............................. EXCEPTION WHEN NO_DATA_FOUND THEN MESSAGE(’Invalid Customer Id’).. create a trigger to write the correct values to the Customer_Name.. 3 In the ORDGXX form.....id = C... Practice 18 Solutions 1 In the CUSTGXX form..................... Set the Validate from List property to Yes for the Sales_Rep_Id item in the S_CUSTOMER block.. E.id. S_EMP E WHERE E..........Customer_Id: SELECT C..........sales_rep_id...date_shipped < :S_ORD.....date_ordered THEN MESSAGE(’Ship date is before order date!’)........... .......... RAISE form_trigger_failure. 2 Save and compile the form... Deploy the form on the Web to test. :S_ORD... No formal solution.......................... cause the Sales_Rep_Lov to be displayed whenever the user enters a Sales_Rep_Id that does not exist in the database..Appendix A: Practice Solutions .name....customer_id = C........... RAISE form_trigger_failure....... C. When-Validate-Record on S_ORD block: IF :S_ORD... write a validation trigger to check that the Date_Shipped is not before the Date_Ordered.. 4 In the ORDGXX form............ A-50 Oracle Forms Developer: Build Internet Applications I ....last_name INTO :S_ORD.... :S_ORD.sales_rep_id AND :S_ORD. Sales_Rep_Name.................... When-Validate-Item on S_ORD..........sales_rep_name FROM S_CUSTOMER C................................ Fail the trigger if the customer is not found...........

..........Product_Id to derive the name of the product and suggested wholesale price................... Fail the trigger and display a message if the product is not found...................... EXCEPTION WHEN NO_DATA_FOUND THEN MESSAGE(’Invalid Product Id!’).......... ......... Oracle Forms Developer: Build Internet Applications I A-51 .... suggested_whlsl_price INTO :S_ITEM..............................Product_Id: SELECT name.. :S_ITEM............................................................................. When-Validate-Item on S_ITEM........ 5 Create another validation trigger on S_ITEM......... and write them to the Description item and the Price item............product_id = id......................price FROM S_PRODUCT WHERE :S_ITEM......................... RAISE form_trigger_failure.Practice 18 Solutions ....................description..................................

.....................image_id AND s_product.................... BEGIN filename := GET_PRODUCT_IMAGE(:S_ITEM.product_image’).. EXCEPTION WHEN no_data_found THEN return(’No file’)..........’S_ITEM................. IF filename = ’No file’ THEN null...........Appendix A: Practice Solutions ... When-New-Form-Instance at form level: EXECUTE_QUERY.... This function returns the image filename for the given product number................... Practice 19 Solutions 1 Write a When-New-Form-Instance trigger on the ORDGXX form to execute a query at form startup... and populate the Product_Image item with a picture of the product..id = product_number............... END IF...... ELSE READ_IMAGE_FILE(filename................ if one exists............filename INTO v_filename FROM s_image.............. A-52 Oracle Forms Developer: Build Internet Applications I ............product_id). FUNCTION get_product_image (product_number IN NUMBER) RETURN VARCHAR2 IS v_filename VARCHAR2(20)...id = s_product..’tiff’...................... RETURN v_filename... END......... 2 Write a trigger that fires as the cursor arrives in each record of the S_ITEM block..... . Get_Product_Image function is already created for you. BEGIN SELECT s_image........................................... END.... IF v_filename is null THEN v_filename := ’No file’............ END IF............... When-New-Record-Instance on S_ITEM block: DECLARE filename VARCHAR2(20)....... s_product WHERE s_image..............

....... Use the same code above...................... Oracle Forms Developer: Build Internet Applications I A-53 .. ....... When-New-Record-Instance on S_ORD block................................................................. 4 Is there another trigger where you might also want to place this code? When-Validate-Item on S_ITEM................ No formal solution.................................................... You could use a procedure to avoid duplicating the trigger code...Product_Id is a candidate for the code............... 3 Define the same trigger type and code on the S_ORD block........................... Deploy the form on the Web to test.........Practice 19 Solutions ................................................................................ 5 Save and compile the form.....

... and run the form to test.. The better solution is to keep the total number of rows in another table that you can lock... Practice 20 Solutions 1 In the ORDGXX form....................................... Set the Required and Enabled properties to No for S_ITEM... set Enabled property to No for S_ORD.........Id with the next value from the S_ORD_ID sequence.............item_id FROM S_ITEM WHERE :S_ITEM.....DUAL..... Deploy the form on the Web to test.. ....................... A-54 Oracle Forms Developer: Build Internet Applications I ........... Pre-Insert on S_ORD block: SELECT S_ORD_ID.. compile............. 2 In the S_ORD block.. set the Enabled property for the ID item to No.... Pre-Insert on S_ITEM block: SELECT NVL(MAX(item_id)......................id FROM SYS.............Item_Id............Id....................... In the Property Palette.... 5 Save and compile the form.. RAISE form_trigger_failure... but this solution is too advanced at this stage... EXCEPTION WHEN OTHERS THEN MESSAGE(’Failed to assign Order Id’)... 4 Create a similar trigger on the S_ITEM block that assigns the Item_Id when a new record is saved........................nextval INTO :S_ORD... 3 Save..... write a transactional trigger on the S_ORD block that populates S_ORD...................... Instructor Note Solution 20-4 is not the safest way.....................ord_id = ord_id.0) + 1 INTO :S_ITEM................... No formal solution. No formal solution..Appendix A: Practice Solutions ..........

.. and deletes........ Post-Update....................update’)....update := TO_CHAR( TO_NUMBER( :GLOBAL.................. GLOBAL.. and Post-Delete triggers to initialize and increment the value of each global variable........Practice 20 Solutions ... .. ’GLOBAL... :GLOBAL....... :GLOBAL........... Post-Delete at form level: DEFAULT_VALUE(’0’. Create three global variables called GLOBAL................delete ) + 1 ).... You need to write Post-Insert............. and GLOBAL.............................................. ’GLOBAL.INSERT........................... Post-Update at form level: DEFAULT_VALUE(’0’. updates...................delete’)......DELETE.. 6 Open the CUSTGXX form module............insert := TO_CHAR( TO_NUMBER( :GLOBAL... Post-Insert at form level: DEFAULT_VALUE(’0’........ Oracle Forms Developer: Build Internet Applications I A-55 .UPDATE..................insert’)....... ’GLOBAL............. These variables indicate respectively the number of inserts............. :GLOBAL........update ) + 1 ).....delete := TO_CHAR( TO_NUMBER( :GLOBAL................insert ) + 1 )....

DEFAULT_VALUE( ’0’.................. IS_ERROR IN BOOLEAN ) IS BEGIN IF message_number IN ( 40400........ Pass the error code and TRUE...delete’ )...update’ )................... ’GLOBAL. ELSE MESSAGE( MESSAGE_TEXT ). ..insert’ ). END IF.......... 40407 ) THEN DEFAULT_VALUE( ’0’.............. On-Error at form level: handle_message( error_code.......................... DEFAULT_VALUE( ’0’.............. This procedure receives two arguments.................. Call the procedure when a message occurs.. Import the pr20_10................................. ’GLOBAL.Appendix A: Practice Solutions .. ’ || :GLOBAL....................... ’ || :GLOBAL.........update || ’ records updated........ On-Message at form level: handle_message( message_code. FALSE )....... END ......................insert || ’ records inserted....... TRUE )...... 40406..... Pass the message code and FALSE. PROCEDURE handle_message( message_number IN NUMBER. ’GLOBAL.. The first one is a message number........................... MESSAGE(’Save Ok: ’ || :GLOBAL... Call the procedure when an error occurs........ This procedure uses the three global variables to display a customized commit message and then erases the global variables..... A-56 Oracle Forms Developer: Build Internet Applications I ...delete || ’ records deleted !!!’ )..... 7 Create a procedure called HANDLE_MESSAGE. ELSIF is_error = TRUE THEN MESSAGE(’ERROR: ’ || ERROR_TEXT )............. and the second is a Boolean error indicator....txt file.

FALSE )......................... pw VARCHAR2(30)...... ’DEFAULT’).................... Write an On-Logon trigger to control the number of connection tries.......txt file......................... un VARCHAR2(30)..... cs := GET_APPLICATION_PROPERTY( CONNECT_STRING )......................... IF NOT CONNECTED THEN MESSAGE(’Too many tries!’)... END LOOP............ WHILE connected = FALSE and tries > 0 LOOP LOGON_SCREEN...... END................. On-Logon at form level: DECLARE connected BOOLEAN := FALSE......Practice 20 Solutions ............ BEGIN SET_APPLICATION_PROPERTY(CURSOR_STYLE............. IF FORM_SUCCESS THEN connected := TRUE .............................. RAISE FORM_TRIGGER_FAILURE..... tries NUMBER := 3....... Use the LOGON_SCREEN built-in to simulate the default login screen and LOGON to connect to the database.... END IF.......... ... pw || ’@’ || cs. tries := tries ..... un := GET_APPLICATION_PROPERTY( USERNAME )............... You can import the pr20_11......... 8 Open the CUSTGXX form module........ LOGON( un. cs VARCHAR2(30).............. pw := GET_APPLICATION_PROPERTY( PASSWORD )......1......... Oracle Forms Developer: Build Internet Applications I A-57 .............. END IF......

............ END IF. ELSE READ_IMAGE_FILE(filename............ Practice 21 Solutions 1 In the ORDGXX form........................Appendix A: Practice Solutions ........ ................... IF filename = ’No file’ THEN null. END............................ BEGIN IF GET_ITEM_PROPERTY(’S_ITEM........................................................ END IF................... When-New-Record-Instance on S_ORD and S_ITEM blocks: DECLARE filename VARCHAR2(20)............VISIBLE)=’TRUE’ THEN filename := GET_PRODUCT_IMAGE(:S_ITEM............................ Add a test in the code to check Product_Image............................... ’S_ITEM.................product_image’)........product_id)...... Perform the trigger actions only if the image is currently displayed..... Use the GET_ITEM_PROPERTY built-in function. alter the triggers that populate the Product_Image item when the image item is displayed......’tiff’.....product_image’........ A-58 Oracle Forms Developer: Build Internet Applications I ............

........................LABEL... VISIBLE)=’TRUE’ THEN SET_ITEM_PROPERTY(product_image_id.................. VISIBLE.........PROPERTY_TRUE). compile....................... image_desc_id ITEM := FIND_ITEM(’S_ITEM....... 3 Save.......... ’Image On’). Use a FIND_object function to obtain the IDs of each item referenced by the trigger..... ’Image Off’)....... When-Button-Pressed on CONTROL............ SET_ITEM_PROPERTY(image_desc_id... PROPERTY_FALSE). SET_ITEM_PROPERTY(image_button_id........................... 2 Alter the When-Button-Pressed trigger on the Image_Button so that object IDs are used.............product_image’)... Oracle Forms Developer: Build Internet Applications I A-59 ... END.image_button: DECLARE product_image_id ITEM := FIND_ITEM(’S_ITEM...... SET_ITEM_PROPERTY(image_button_id....... ............ PROPERTY_TRUE)......................Practice 21 Solutions ............................ BEGIN IF GET_ITEM_PROPERTY(product_image_id..PROPERTY_FALSE)............. and use them in each item reference in the trigger....LABEL. image_button_id ITEM := FIND_ITEM(’CONTROL.. Declare variables for these IDs. ELSE SET_ITEM_PROPERTY(product_image_id.. VISIBLE. SET_ITEM_PROPERTY(image_desc_id.............. and run the form to test these features....... No formal solution. VISIBLE......VISIBLE........................image_button’).....image_description’)... END IF.....

.. Drag the S_INVENTORY block......................... and click the More button... and WIN_INVENTORY window under the Object Group Children entry.. In the Subclass Information dialog box..... create an object group.. 5 Apply ClassA to CV_INVENTORY........................... CV_INVENTORY canvas.Appendix A: Practice Solutions .... create a property class called ClassA.......... Practice 22 Solutions 1 In the ORDGXX form........... select the Subclass Information property.................. Select the Copy options...... No formal solution.... Drag Stock_Objects from the ORDERS form to your new module under the Object Groups node................ In the Property Palette for the property class....... set the Name to ClassA. select the Property Class radio button and set the Property Class Name list item to ClassA. In the Property Palette for each of the items............ the Restock_Date item................ Set the properties to the values listed above.. Add the properties listed by clicking the Add Property icon and selecting from the list displayed..... 4 In the new form module......................... .......... 2 Save the form............ Select the Forms node and click the Create icon...... A-60 Oracle Forms Developer: Build Internet Applications I ......... and the Max_In_Stock item.................. Select the Object Groups node and click the Create icon.............. CV_INVENTORY canvas..... consisting of the S_INVENTORY block.. 3 Create a new form module and copy the Stock_Objects object group into it... and WIN_INVENTORY window...........999 8 Right No DarkRed Select the Property Classes node and click the Create icon.................... called Stock_Objects............... Include the following properties and settings: Property Font Name Format Mask Font Size Justification Delete Allowed Background Color Setting Arial 99...

...........Practice 22 Solutions .... Make the Restock_Date format mask a variant property.. Select the Object Libraries node in the Object Navigator. Save................ Add the CONTROL block.. Some items are not applicable to this form... Follow the practice steps... For proper behavior. Create a new form..................fmb....... You should receive the following error: Cannot resolve reference item reference s_ITEM......... Set the Window property to WINDOW1 for the Toolbar canvas. Set the Horizontal Toolbar Canvas property to TOOLBAR for the window...... 6 Save the form module as STOCKXX.. the Toolbar... Set the Canvas property for the following items to NULL: Image_Button. and run the form again............. Use Toolbar as the Horizontal Toolbar canvas for this form..... Drag the Toolbar canvas... Subclass the objects......... Oracle Forms Developer: Build Internet Applications I A-61 ..............olb.. see the DEPTWK22 file for a solution. and Question_Alert from the object library into the new form. Change the Format Mask for S_INVENTORY....... and the Question_Alert to the Personal tab of the object library........ Hide_Help_Button..... Save the summit object library................ compile. and click the Create button....... Create two tabs in the object library called Personal and Corporate........... Save this form as DEPTGXX......... and run the form 7 8 9 10 and note the error............... Rename this object library summit... You should receive the following error: Invalid format mask for given datatype for S_INVENTORY......Restock_Date to MM/DD/YYYY. and the Question_Alert to the personal tab of the object library. Expand the Library Tabs node in the Object Navigator....Product_Id Delete s_ITEM. Set their label properties as Personal and Corporate.. Show_Help_Button......... the S_DEPT block must be before the CONTROL block in the Object Navigator.. and run the form to test it.Product_Id From the Copy Value From Item property.......... Stock_Button. Product_Lov_Button..... Save the object library as summit. compile................. the Toolbar.... compile................ Drag the CONTROL block.... Correct the error............... Create an object library and name it summit... compile........ and run the form...... Save...Restock_Date. CONTROL block......... . and create a data block based on the S_DEPT table.......

.......... Create a new form and a new data block in the form........... 12 Create two sample buttons. Drag these items into your object library.. Place the Toolbar canvas in the new form. one for wide buttons and one for medium buttons..................................... No formal solution................... What happens and why? You cannot delete the objects because the toolbar and contents are subclassed from another object.................... Create a sample date field...................... ..................................... A-62 Oracle Forms Developer: Build Internet Applications I ............ Apply these SmartClasses in your form...................... by means of width....................... Mark these items as SmartClasses............................................................. 11 Try to delete items on the Null canvas.......... Set the width and the format mask to your preferred standard...Appendix A: Practice Solutions .......................

.... Practice 23 Solutions 1 In the ORDGXX form.......... Deploy the application to the Web....... passing control to it........ Pre-Form at form level: DEFAULT_VALUE(’’........ No formal solution............’GLOBAL................ ..Orders_Button that initializes GLOBAL...... 7 Change the window location of the ORDGXX form...................................... OPEN_FORM(’ordgxx’)... When-Button-Pressed on CONTROL...id.... Set Label to Orders...................customer_id’)..Orders_Button: :GLOBAL...customer_id := :GLOBAL......... and run the form to test that it works as a stand-alone.... No formal solution...customer_id........Customer_Id Pre-Query on S_ORD block: :S_ORD...................................................... if required........ create a Pre-Form trigger to ensure that a global variable called Customer_Id exists. 4 In the CUSTGXX form.............................. and then opens the ORDGXX form....Practice 23 Solutions ....... Oracle Forms Developer: Build Internet Applications I A-63 ..... Create a button........customer_id := :S_CUSTOMER. 2 Add a trigger to ensure that queries on the S_ORD block are restricted by the value of GLOBAL. 6 Save and compile each form.. No formal solution................ 3 Save......... 5 Define a trigger for CONTROL..... compile...Customer_Id with the current customer’s ID. create a CONTROL block button called Orders_Button..... Set the Name to ORDERS_BUTTON......

When-Button-Pressed on Orders_Button: :GLOBAL.............Appendix A: Practice Solutions .... 10 Add code to the CUSTGXX form so that GLOBAL..................................... When-Create-Record on S_ORD block: :S_ORD............................... 8 Alter the Orders_Button trigger in CUSTGXX so that it uses GO_FORM to pass control to ORDGXX if the form is already running......................customer_id := :GLOBAL.................. ELSE GO_FORM(’ORDERS’).......Customer_Id is updated when the current Customer_Id changes........................... Use the FIND_FORM built-in for this purpose.......... When-Validate-Item on S_CUSTOMER...Customer_Id.................customer_id := :S_CUSTOMER..............id........ 9 Write a When-Create-Record trigger on the S_ORD block that uses the value of GLOBAL...id.. .... Remember that you need to use the module name in the GO_FORM built-in.................customer_id := :S_CUSTOMER.... END IF... IF ID_NULL(FIND_FORM(’ORDERS’))THEN OPEN_FORM(’ORDGXX’)... and the filename in the OPEN_FORM built-in.....Customer_Id as the default value for S_ORD...........Id: :GLOBAL.................................................customer_id... A-64 Oracle Forms Developer: Build Internet Applications I ........

.B .................... Table Descriptions and Data ............

.................................................................. Summit Sporting Goods Database Diagram ORD_ID ID S_ITEM PRODUCT_ID S_ORD CUSTOMER_ID SALES_REP_ID * S_INVENTORY PRODUCT_ID ID ID ID S_CUSTOMER S_PRODUCT SALES_REP_ID IMAGE_ID ID S_IMAGE ID ID S_EMP DEPT_ID ID S_DEPT *Unique occurrences are identified by PRODUCT_ID and WAREHOUSE_ID........................................................................ ...............................................Appendix B: Table Descriptions and Data ............................................................. B-2 Oracle Forms Developer: Build Internet Applications I .......................................................

....--------ID NAME PHONE ADDRESS CITY STATE COUNTRY ZIP_CODE CREDIT_RATING SALES_REP_ID REGION_ID COMMENTS Null? ------------NOT NULL NOT NULL Datatype ----------------NUMBER(7) VARCHAR2(50) VARCHAR2(25) VARCHAR2(400) VARCHAR2(30) VARCHAR2(20) VARCHAR2(30) VARCHAR2(75) VARCHAR2(9) NUMBER(7) NUMBER(7) VARCHAR2(255) ....................S_CUSTOMER Description ....................................... S_CUSTOMER Description Column Name -------------........................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I B-3 ...................................................................................

............... B-4 Oracle Forms Developer: Build Internet Applications I ..... ........................................Appendix B: Table Descriptions and Data .......... Id Name Phone Address ----------------------.....-------------------------Zip_code Credit_ra Sales_rep_id Region_id ----------------------------.................................................................. 202 Osaka Oj Athletics 81-20101 6741 Takashi Blvd....................................----------City State Country -----------------....--------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...............-----------....... S_CUSTOMER Data SQL> SELECT * FROM s_customer............ 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...... This is okay as long as the credit rating remains excellent...................................................................................

.............................................................................................. Likes to order accessories in bright colors........--------Comments -------------------------------------------------204 Womansport 1-206-104-0103 281 King Street Seattle Washington USA 98101 EXCELLENT 11 1 205 Hong Kong Kam’s Sporting Goods 852-3692888 15 Henessey Road EXCELLENT 15 4 206 Cannes Sportique 33-2257201 172 Rue de Rivoli France EXCELLENT 15 5 Customer specializes in soccer....................-------------------------Zip_code Credit_ra Sales_rep_id Region_id ----------------------------..........................----------City State Country -----------------................................................ S_CUSTOMER Data (continued) Id Name Phone Address ----------------------............................................................................... Oracle Forms Developer: Build Internet Applications I B-5 ............-----------...S_CUSTOMER Data ............ 207 Lagos Sweet Rock Sports 234-603620 6 Saint Antoine Nigeria ....

................ 211 Prague Kuhn’s Sports EXCELLENT 42-111292 15 7 Modrany Czechoslovakia 5 .............-----------................-------------------------Zip_code Credit_ra Sales_rep_id Region_id ----------------------------.................. 209 Beisbol Si! San Pedro de Macon’s EXCELLENT 809-352689 11 789 Playa Del Mar Dominican Republic 1 210 Futbol Sonora 52-404562 3 Via Saguaro Nogales EXCELLENT 12 2 Customer is difficult to reach by phone.................................... S_CUSTOMER Data (continued) Id Name Phone Address ----------------------.............................................----------City State Country -----------------.............--------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......................................Appendix B: Table Descriptions and Data ................... B-6 Oracle Forms Developer: Build Internet Applications I ....................................... Try mail......................................................

... Oracle Forms Developer: Build Internet Applications I B-7 ....................-------------------------Zip_code Credit_ra Sales_rep_id Region_id ----------------------------............................................................................. Insist upon cash............... but has difficulty paying bills......................... Note: This display has been formatted..............--------Comments -------------------------------------------------212 Hamada Sport 20-1209211 57A Corniche Alexandria Egypt EXCELLENT 13 3 Customer orders sea and water equipment........................................ ..................................... 214 Ojibway Retail Buffalo NY 14202 POOR 1-716-555-7171 415 Main Street USA 11 1 215 Sporta Russia 7-3892456 6000 Yekatamina St................----------City State Country -----------------..S_CUSTOMER Data .............. S_CUSTOMER Data (continued) Id Name Phone Address ----------------------...........-----------........... 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..................... Petersburg Russia POOR 15 5 This customer is very friendly.....

................................................................................................................Appendix B: Table Descriptions and Data .................... .... S_DEPT Description and Data Column Name ---------------------ID NAME REGION_ID Null? ------------NOT NULL NOT NULL Datatype -------------NUMBER(7) VARCHAR2(25) NUMBER(7) SQL> SELECT * FROM s_dept................................................................................. B-8 Oracle Forms Developer: Build Internet Applications I ......................................................................... ID -----10 31 32 33 34 35 41 42 43 44 45 50 NAME ---------------Finance Sales Sales Sales Sales Sales Operations Operations Operations Operations Operations Administration REGION_ID ----------------1 1 2 3 4 5 1 2 3 4 5 1 12 rows selected............

...........2) NUMBER(4.......... S_EMP Description Column Name -----------------------ID LAST_NAME FIRST_NAME USERID START_DATE COMMENT MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCT Null? -------------NOT NULL NOT NULL Datatype -------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE VARCHAR2(255) NUMBER(7) VARCHAR2(25) NUMBER(7) NUMBER(11.........................................................2) ...........S_EMP Description ................................................................................................................................................................................... Oracle Forms Developer: Build Internet Applications I B-9 ..................................

........................................................Appendix B: Table Descriptions and Data .........----------------........... Finance mquickto 07-APR-90 10 1450 5 Ropeburn Audry 1 VP............----------------------.................. ID LAST_NAME FIRST_NAME USERID START_DAT ---......---------------------------------........................ Operations 41 1450 3 Nagayama 1 VP........................ B-10 Oracle Forms Developer: Build Internet Applications I ..............--------COMMENTS -------------------------------------------------------------MANAGER_ID TITLE DEPT_ID SALARY ---------. Administration aropebur 04-MAR-90 50 1550 6 Urguhart Molly 2 Warehouse Manager murguhar 18-JAN-91 41 1200 7 Menchu Roberta 2 Warehouse Manager Biri Ben 2 Warehouse Manager rmenchu 14-MAY-90 42 1250 bbiri 07-APR-90 43 1100 Catchpole Antoinette 2 Warehouse Manager acatchpo 09-FEB-92 44 1300 8 9 Midori mnagayam 17-JUN-91 31 1400 .....-----COMMISSION_PCT --------------1 Velasquez Carmen cvelasqu 03-MAR-90 President 50 2500 2 Ngao LaDoris lngao 08-MAR-90 1 VP...................................................................... Sales 4 Quick-To-See Mark 1 VP............. S_EMP Data SQL> SELECT * FROM s_emp...............................................

...........--------COMMENTS -------------------------------------------------------------MANAGER_ID TITLE DEPT_ID SALARY ---------................................................................................. Oracle Forms Developer: Build Internet Applications I B-11 ...............................----------------.......................................................................5 hgiljum 18-JAN-92 32 1490 13 Sedeghi Yasmin 3 Sales Representative 10 ysedeghi 18-FEB-91 33 1515 14 Nguyen Mai 3 Sales Representative 15 mnguyen 22-JAN-92 34 1525 15 Dumas Andre 3 Sales Representative 17...----------------------......................................... S_EMP Data (continued) ID LAST_NAME FIRST_NAME USERID START_DAT ---.---------------------------------............................-----COMMISSION_PCT --------------10 Havel Marta mhavel 27-FEB-91 2 Warehouse Manager 45 1307 11 Magee Colin 3 Sales Representative 10 cmagee 14-MAY-90 31 1400 12 Giljum Henry 3 Sales Representative 12.S_EMP Data .........................5 adumas 09-OCT-91 35 1450 16 Maduro Elena 6 Stock Clerk emaduro 07-FEB-92 41 1400 ..............

.............--------COMMENTS -------------------------------------------------------------MANAGER_ID TITLE DEPT_ID SALARY ---------..........................................Appendix B: Table Descriptions and Data .......................................---------------------------------....... B-12 Oracle Forms Developer: Build Internet Applications I .......-----COMMISSION_PCT --------------17 Smith George gsmith 08-MAR-90 6 Stock Clerk 41 940 18 Nozaki Akira 7 Stock Clerk anozaki 09-FEB-91 42 1200 19 Patel Vikram 7 Stock Clerk vpatel 06-AUG-91 42 795 20 Newman Chad 8 Stock Clerk cnewman 21-JUL-91 43 750 21 Markarian Alexander 8 Stock Clerk amarkari 26-MAY-91 43 850 22 Chang Eddie 9 Stock Clerk echang 30-NOV-90 44 800 23 Patel Radha 9 Stock Clerk rpatel 17-OCT-90 34 795 24 Dancs Bela 10 Stock Clerk bdancs 17-MAR-91 45 860 25 Schwartz Sylvie 10 Stock Clerk sschwart 09-MAY-91 45 1100 Note: This display has been formatted................................ ..............................................................................................----------------------..... S_EMP Data (continued) ID LAST_NAME FIRST_NAME USERID START_DAT ---.........----------------..........................................................

.............tif chaphelm............tif himbike...tif safthelm...................tif stglove......tif alglove..............tif probar.tif baseball....................... S_IMAGE Description and Data Name Null? Type -----------------------------...........tif gpbike....... Oracle Forms Developer: Build Internet Applications I B-13 ............................ Note: The above output has been formatted.S_IMAGE Description and Data ................tif pucbat........tif acepole..tif cabbat... ........................................tif bunpole............tif curlbar................tif proboot.tif grglove....................-------.............tif 19 rows selected.tif propole.....bunboot. ID ----1001 1002 1003 1011 1012 1013 1291 1296 1829 1381 1382 1119 1223 1367 1368 1369 1480 1482 1486 FORMAT ----------------------JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF JTIFF U Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y FILENAME I ---------------------------.........tif aceboot.....tif winbat...........................---ID NOT NULL NUMBER(7) FORMAT VARCHAR2(25) USE_FILENAME VARCHAR2(1) FILENAME VARCHAR2(255) IMAGE LONG RAW SQL> SELECT * FROM s_image........

..........--------..........................--------20108 101 700 700 1225 20201 101 802 800 1400 20510 101 1389 850 1400 20512 101 850 850 1450 30321 101 2000 1500 2500 30326 101 2100 2000 3500 ..................--------.....-----------........Appendix B: Table Descriptions and Data ........................................................--------....................................-----------OUT_OF_STOCK RESTOCK_D ------------------------..............--------10011 101 650 625 1100 10012 101 600 560 1000 10013 101 400 400 700 10021 101 500 425 740 10022 101 300 200 350 10023 101 400 300 525 20106 101 993 625 1000 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------......-----------OUT_OF_STOCK RESTOCK_D ------------------------......-----------........................................................... B-14 Oracle Forms Developer: Build Internet Applications I ............................. PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------....... S_INVENTORY Description and Data Name --------------------------------PRODUCT_ID WAREHOUSE_ID AMOUNT_IN_STOCK REORDER_POINT MAX_IN_STOCK OUT_OF_STOCK_EXPLANATION RESTOCK_DATE Null? -------NOT NULL NOT NULL Type ---NUMBER(7) NUMBER(7) NUMBER(9) NUMBER(9) NUMBER(9) VARCHAR2(255) DATE SQL> SELECT * FROM s_inventory...................--------............

..............--------.......................... 12-APR-93 ......-----------OUT_OF_STOCK RESTOCK_D ------------------------....--------30421 101 1822 1800 3150 30426 101 2250 2000 3500 30433 101 650 600 1050 32779 101 2120 1250 2200 32861 101 505 500 875 40421 101 578 350 600 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------............................................-----------...-----------.....--------..................... Oracle Forms Developer: Build Internet Applications I B-15 ..--------50273 101 233 200 350 50417 101 518 500 875 50418 101 244 100 275 50419 101 230 120 310 50530 101 669 400 700 50532 101 0 100 175 Wait for Spring......................--------....................--------.................--------.............................S_INVENTORY Description and Data ............................-----------........ S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------............................-----------OUT_OF_STOCK RESTOCK_D ------------------------..-----------OUT_OF_STOCK RESTOCK_D ------------------------....... 08-FEB-93 41010 101 250 250 437 41020 101 471 450 750 41050 101 501 450 750 41080 101 400 400 700 41100 101 350 350 600 50169 101 2530 1500 2600 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------..--------.....--------40422 101 0 350 600 Phenomenal sales..........................

...............-----------....--------..--------..........................-----------OUT_OF_STOCK RESTOCK_D ------------------------...................................--------.................-----------...................-----------OUT_OF_STOCK RESTOCK_D ------------------------...................--------............--------30321 201 96 80 140 30326 201 147 120 210 30421 201 102 80 140 30426 201 200 120 210 30433 201 130 130 230 32779 201 180 150 260 32861 201 132 80 140 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------.....--------50169 201 225 220 385 50273 201 75 60 100 50417 201 82 60 100 50418 201 98 60 100 50419 201 77 60 100 50530 201 62 60 100 .....................--------......................... S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------........ B-16 Oracle Forms Developer: Build Internet Applications I ..............Appendix B: Table Descriptions and Data .............--------50536 101 173 100 175 20106 201 220 150 260 20108 201 166 150 260 20201 201 320 200 350 20510 201 175 100 175 20512 201 162 100 175 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------..........-----------OUT_OF_STOCK RESTOCK_D ------------------------.............................................--------..-----------.......................

.--------..--------...................................-----------...........................--------.............................................--------30433 301 35 20 35 32779 301 102 95 175 32861 301 57 50 100 40421 301 70 40 70 40422 301 65 40 70 41010 301 59 40 70 41020 301 61 40 70 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------..............................--------50532 201 67 60 100 50536 201 97 60 100 20510 301 69 40 100 20512 301 28 20 50 30321 301 85 80 140 30421 301 102 80 140 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------.. Oracle Forms Developer: Build Internet Applications I B-17 ..-----------OUT_OF_STOCK RESTOCK_D ------------------------........--------.....-----------.........-----------OUT_OF_STOCK RESTOCK_D ------------------------............--------........................--------........... S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------...S_INVENTORY Description and Data ...............--------41050 301 49 40 70 41080 301 50 40 70 41100 301 42 40 70 20510 401 88 50 100 20512 401 75 75 140 30321 401 102 80 140 ........-----------OUT_OF_STOCK RESTOCK_D ------------------------.................-----------...........................................................

...-----------OUT_OF_STOCK RESTOCK_D ------------------------..-----------.....-----------..--------30326 401 113 80 140 30421 401 85 80 140 30426 401 135 80 140 30433 401 0 100 175 A defective shipment was 07-SEP-92 sent to Hong Kong and nee ded to be returned.....--------..........................--------32861 401 250 150 250 40421 401 47 40 70 40422 401 50 40 70 41010 401 80 70 220 41020 401 91 70 220 41050 401 169 70 220 ..........................--------..........................Appendix B: Table Descriptions and Data .................................--------............. B-18 Oracle Forms Developer: Build Internet Applications I .........................................................................................--------..................-----------OUT_OF_STOCK RESTOCK_D ------------------------....................... The s oonest ACME can turn this around is early February 32779 401 135 100 175 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------...... S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------..................................

..--------41080 401 100 70 220 41100 401 75 70 220 50169 401 240 200 350 50273 401 224 150 280 50417 401 130 120 210 50418 401 156 100 175 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------......................................................-----------............... S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------.......................................S_INVENTORY Description and Data ..........--------...--------.........--------.......--------......--------50419 401 151 150 280 50530 401 119 100 175 50532 401 233 200 350 50536 401 138 100 175 10012 10501 300 300 525 10013 10501 314 300 525 10022 10501 502 300 525 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------.......-----------OUT_OF_STOCK RESTOCK_D ------------------------.................-----------.........--------.-----------OUT_OF_STOCK RESTOCK_D ------------------------......................................................................--------............-----------.--------10023 10501 500 300 525 20106 10501 150 100 175 20108 10501 222 200 350 20201 10501 275 200 350 20510 10501 57 50 87 20512 10501 62 50 87 .................. Oracle Forms Developer: Build Internet Applications I B-19 ..............-----------OUT_OF_STOCK RESTOCK_D ------------------------.....................

...-----------.--------32861 10501 288 200 350 40421 10501 97 80 140 40422 10501 90 80 140 41010 10501 151 140 245 41020 10501 224 140 245 41050 10501 157 140 245 41080 10501 159 140 245 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------....... Note: The above output has been formatted.................................--------.....--------...............--------30321 10501 194 150 275 30326 10501 277 250 440 30421 10501 190 150 275 30426 10501 423 250 450 30433 10501 273 200 350 32779 10501 280 200 350 PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------.................Appendix B: Table Descriptions and Data ........--------..................-----------OUT_OF_STOCK RESTOCK_D ------------------------.....--------41100 10501 141 140 245 114 rows selected............................. .....................................--------.................... S_INVENTORY Description and Data (Continued) PRODUCT_ID WAREHOUSE AMT_IN_STOCK REORD_PT MAX_IN_STOCK ---------...--------..................................................-----------OUT_OF_STOCK RESTOCK_D ------------------------...-----------....... B-20 Oracle Forms Developer: Build Internet Applications I ..-----------OUT_OF_STOCK RESTOCK_D ------------------------..--------.................................................-----------...

......................................................................................S_ITEM Description .... S_ITEM Description Column Name ------------------------ORD_ID ITEM_ID PRODUCT_ID PRICE QUANTITY QUANTITY_SHIPPED Null? -------------NOT NULL NOT NULL NOT NULL Datatype ---------NUMBER(7) NUMBER(7) NUMBER(7) NUMBER(11...................................................... Oracle Forms Developer: Build Internet Applications I B-21 ...........................................................................................................................................2) NUMBER(9) NUMBER(9) ..................

............................. B-22 Oracle Forms Developer: Build Internet Applications I .................................................-------...........8 16 16 47 28 28 80 13 13 ..................................................................Appendix B: Table Descriptions and Data .......... S_ITEM Data SQL> SELECT * FROM s_item.. ORD_ID -----100 100 100 100 100 100 100 101 101 101 101 101 101 101 102 102 103 103 104 104 104 104 105 105 105 ITEM_ID -------1 2 3 5 7 6 4 1 3 5 6 7 4 2 1 2 1 2 1 4 2 3 1 3 2 PRODUCT_ID ----------10011 10013 10021 30326 41010 30433 10023 30421 41010 50169 50417 50530 41100 40422 20108 202011 30433 32779 20510 30421 20512 30321 50273 50532 50419 PRICE QUANTITY QUANTITY_SHIPPED -----....----------------135 500 500 380 400 400 14 500 500 582 600 600 8 250 250 20 450 450 36 400 400 16 15 15 8 20 20 4..................................................29 40 40 80 27 27 45 50 50 45 35 35 50 30 30 28 100 100 23 45 45 20 15 15 7 11 11 9 7 7 16 35 35 8 12 12 1669 19 19 22....................................................................................

..........................................S_ITEM Data ....................................... ..........95 300 300 22.................................. Note: This display has been formatted................ S_ITEM Data (continued) ORD_ID ------106 106 106 106 106 106 107 107 107 107 107 108 108 108 108 108 108 108 109 109 109 109 109 109 109 110 110 111 111 97 97 98 99 99 99 99 112 ITEM_ID ------1 4 5 6 2 3 1 3 5 4 2 1 6 7 5 2 4 3 1 5 7 6 4 2 3 1 2 1 2 1 2 1 1 2 3 4 1 PRODUCT_ID ----------20108 50273 50418 50419 20201 50169 20106 20201 30421 30321 20108 20510 41080 41100 32861 20512 32779 30321 10011 30426 50418 32861 30326 10012 10022 50273 50536 40421 41080 20106 303211 404218 20510 20512 50417 50530 20106 PRICE QUANTITY QUANTITY_SHIPPED -----...........89 75 75 75 98 98 80 27 27 123 21 21 4..........25 500 500 75 43 43 60 50 50 582 1500 1500 175 600 600 21................................. Oracle Forms Developer: Build Internet Applications I B-23 ....................................................................89 17 17 50 23 23 65 27 27 35 29 29 9 1000 1000 500 50 50 5 7 7 9 18 18 8 25 25 80 53 53 45 69 69 11 50 50 62 rows selected...29 125 125 11 50 50 115 130 130 16 55 55 1669 75 75 28 22 22 9 9 9 35 50 50 45 42 42 60 57 57 8 18 18 7 60 60 1669 85 85 140 150 150 18...-------............----------------28 46 46 22............................

.................... ID CUSTOMER_ID DATE_ORDE DATE_SHIPSALES_REP_IDTOTAL PAYMEN ORDER_F --.............................. S_ORD Description and Data Column Name -----------------------ID CUSTOMER_ID DATE_ORDERED DATE_SHIPPED SALES_REP_ID TOTAL PAYMENT_TYPE ORDER_FILLED Null? -----NOT NULL NOT NULL Datatype --------------------NUMBER(7) NUMBER(7) DATE DATE NUMBER(7) NUMBER(11.....................................24 15634 142171 149570 1020935 1539.................................................Appendix B: Table Descriptions and Data ........................................ B-24 Oracle Forms Developer: Build Internet Applications I .....................................................................6 8335 377 32430 2722......................13 2770 84000 595 7707 550 CREDIT CREDIT CREDIT CASH CREDIT CREDIT CREDIT CREDIT CREDIT CREDIT CASH CASH CREDIT CASH CREDIT CREDIT 16 rows selected.................----------- --------- ---------------------------------- ------ 100 101 102 103 104 105 106 107 108 109 110 111 97 98 99 112 31-AUG92 31-AUG-92 01-SEP-92 02-SEP-92 03-SEP-92 04-SEP-92 07-SEP-92 07-SEP-92 07-SEP-92 08-SEP-92 09-SEP-92 09-SEP-92 28-AUG-92 31-AUG-92 31-AUG-92 31-AUG-92 10-SEP-9211 15-SEP-9214 08-SEP-9215 22-SEP-9215 23-SEP-9215 18-SEP-9211 15-SEP-9212 21-SEP-9215 10-SEP-9213 28-SEP-9211 21-SEP-9211 21-SEP-9211 17-SEP-9212 10-SEP-9214 18-SEP-9214 10-SEP-9212 Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y Y 204 205 206 208 208 209 210 211 212 213 214 204 201 202 203 210 601100 8056.....2) VARCHAR2(6) VARCHAR2(1) SQL> SELECT * FROM s_ord.. ................

................................... S_PRODUCT Description Column Name Null? ---------------------------------ID NOT NULL NAMENOT NULL SHORT_DESC LONGTEXT_ID IMAGE_ID SUGGESTED_WHLSL_PRICE WHLSL_UNITS Datatype ----------------NUMBER(7) VARCHAR2(50) VARCHAR2(255) NUMBER(7) NUMBER(7) NUMBER(11......................................................................................................................... Oracle Forms Developer: Build Internet Applications I B-25 ...........................................................................................................................S_PRODUCT Description ..........2) VARCHAR2(25) ............

...........................................................................................Appendix B: Table Descriptions and Data ............... S_PRODUCT Data SQL> SELECT * FROM s_product..................................................95 20106 Junior Soccer BallJunior soccer ball613 11 520 530 20108 World Cup Soccer BallWorld cup soccer ball615 28 20201 World Cup NetWorld cup net 123 708 ........................... ID ---IMAGE_ID -------10011 1001 NAME SHORT_DESC LONGTEXT_ID -----------------------------------SUGGESTED_WHLSL_PRICEWHLSL_UNITS -------------------------------Boot Beginner’s ski boot 518 150 10012 1002 Ace Ski BootIntermediate ski boot519 200 10013 1003 Pro Ski BootAdvanced ski boot 410 10021 1011 Bunny Ski PoleBeginner’s ski pole528 16..........25 10022 1012 Ace Ski PoleIntermediate ski pole529 21........................................... B-26 Oracle Forms Developer: Build Internet Applications I ..............................................................95 10023 1013 Pro Ski PoleAdvanced ski pole 40......

........ S_PRODUCT Data (continued) ID NAME SHORT_DESC LONGTEXT_ID ---......................................................S_PRODUCT Data ............................................. Oracle Forms Developer: Build Internet Applications I B-27 ...............................................................--------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS ---------------------------------------20510 Black Hawk Knee pads............ pair 1017 Knee Pads 9 20512Black Hawk Elbow pads.....................................................................25 30433New Air PumpTire pump 20 940 32779 Slaker Water Water bottle Bottle 7 1286 32861 Safe-T HelmetBicycle helmet 1829 60 1368 40421 Alexeyer ProStraight bar Lifting Bar 1381 65 928 40422 Pro Curling BarCurling bar 1382 50 929 ..................... pair Elbow Pads 8 1019 30321 Grand Prix Bicycle Road bicycle828 1291 1669 30326 Himalaya BicycleMountain bicycle833 1296 582 30421 Grand Prix Road bicycle tires927 Bicycle Tires16 30426 Himalaya TiresMountain bicycle tires933 18................................

........................................................................29 929 676 .................. B-28 Oracle Forms Developer: Build Internet Applications I ...............................................Appendix B: Table Descriptions and Data ............................................................................................................................................ S_PRODUCT Data (continued) ID ---IMAGE_ID -------40421 1381 NAME SHORT_DESC LONGTEXT_ID --------------------------------------SUGGESTED_WHLSL_PRICEWHLSL_UNITS -------------------------------Alexeyer ProStraight bar 928 Lifting Bar 65 40422 1382 Pro Curling BarCurling bar 50 41010 Prostar 10 Ten pound weight 517 Pound Weight 8 41020 Prostar 20 Twenty pound weight527 Pound Weight 12 41050 Prostar 50 Fifty pound weight557 Pound Weight 25 41080 Prostar 80 Eighty pound weight587 Pound Weight 35 41100 Prostar 100 One hundred pound 607 Pound Weightweight 45 50169 1119 Major League Baseball Baseball 4........................

.........................................................................89 50417 Griffey GloveOutfielder’s glove 924 1367 80 50418 Alomar GloveInfielder’s glove 1368 75 925 50419 Steinbach GloveCatcher’s glove 1369 80 926 50530Cabrera Bat Thirty inch bat 1480 45 1037 50532 Puckett Bat Thirty-two inch bat 1039 1482 47 50536 Winfield BatThirty-six inch bat 1043 1486 50 Note: This display has been formatted...........S_PRODUCT Data ........................................................................----------------------------------------IMAGE_IDSUGGESTED_WHLSL_PRICEWHLSL_UNITS ---------------------------------------50273Chapman HelmetBatting helmet 780 1223 22........................ S_PRODUCT Data (continued) ID NAME SHORT_DESC LONGTEXT_ID ---............................................................................................ ........ Oracle Forms Developer: Build Internet Applications I B-29 .......................

.......................................................Appendix B: Table Descriptions and Data .......................... S_REGION Description and Data Column Name Null? -----------------------------ID NOT NULL NAME NOT NULL Datatype ---------------NUMBER(7) VARCHAR2(50) SQL> SELECT * FROM s_region............................................. ID --1 2 3 4 5 NAME -------------------------North America South America Africa / Middle East Asia Europe ........................................................................................................................................ B-30 Oracle Forms Developer: Build Internet Applications I .......................................

............ ...... TITLE -----------------------President Sales Representative Stock Clerk VP....................................................... Oracle Forms Developer: Build Internet Applications I B-31 ................... Administration VP......................---------------TITLE NOT NULL VARCHAR2(25) SQL> SELECT * FROM s_title....................................................... Finance VP................................................................ Operations VP.................................................................... S_TITLE Description and Data Column Name Null? Datatype ---------------------------------. Sales Warehouse Manager 8 rows selected.S_TITLE Description and Data ....

.............................................. Tables emp_type_ObjCol Name Null? -------------------... Oracle8 Objects: Types.......................................................................................................................2) NUMBER(4................2) emp_type_RefCol Name Null? -------------------........... B-32 Oracle Forms Developer: Build Internet Applications I ..........................------------ID LAST_NAME FIRST_NAME USERID START_DATE MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCT Type ---------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE NUMBER(7) VARCHAR2(25) REF OF DEPT_TYPE NUMBER(11................------------ID LAST_NAME FIRST_NAME USERID START_DATE MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCT Type ---------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE NUMBER(7) VARCHAR2(25) DEPT_TYPE NUMBER(11...2) dept_type --------------------------------ID NAME REGION_ID ---------------NUMBER VARCHAR2(25) NUMBER(7) ....Appendix B: Table Descriptions and Data .........2) NUMBER(4......................................................

.. 1) 1450 LaDorislngao 1 VP Operations 3Nagayama 17-JUN-91 DEPT_TYPE(31... 1) 2500 2Ngao 08-MAR-90 DEPT_TYPE(41....................... ’Sales’..Oracle8 Objects: Types.......---------------------------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. Oracle Forms Developer: Build Internet Applications I B-33 ..............................-------START_DAT MANAGER_ID TITLE --------........-------------1Velasquez Carmencvelasqu 03-MAR-90 President DEPT_TYPE(50..................................................... Tables oo_emp_Table_ObjCol Name Null? Type -------------------...................2) ID LAST_NAME FIRST_NAME USERID --------....................2) COMMISSION_PCT NUMBER(4...................... 1) 1400 ID LAST_NAME Midorimnagayam 1 VP Sales FIRST_NAME USERID ......------------------------DEPT_ID(ID.................---------........................... NAME... REGION_ID) ----------------------------------------------------------SALARY COMMISSION_PCT ---------........................................... Tables ..................... ’Administration’. ’Operations’........----------------------------------.

.............................................-------- ... 4) 1300 ID LAST_NAME FIRST_NAME USERID ---------.......... ’Operations’............................. 1) 1550 6 Urguhart Molly murguhar 18-JAN-91 2 Warehouse Manager DEPT_TYPE(41................. 3) 1100 9 Catchpole Antoinette acatchpo 09-FEB-92 2 Warehouse Manager DEPT_TYPE(44.........-----------------------------........................ REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------............. NAME........................ ’Operations’.. B-34 Oracle Forms Developer: Build Internet Applications I ......Appendix B: Table Descriptions and Data ........-------------4 Quick-To-See Mark mquickto 07-APR-90 1 VP Finance DEPT_TYPE(10....................................................... 1) 1200 7 Menchu Roberta rmenchu 14-MAY-90 2 Warehouse Manager DEPT_TYPE(42..... 2) 1250 8 Biri Ben bbiri 07-APR-90 2 Warehouse Manager DEPT_TYPE(43......-------START_DAT MANAGER_ID TITLE --------. -------------------------------------............ ’Operations’........ 1) 1450 5 Ropeburn Audry aropebur 04-MAR-90 1 VP Administration DEPT_TYPE(50........ ’Administration’........... ’Finance’... ’Operations’..............---------------------------------DEPT_ID(ID......

......................................................... ’Operations’.................... Tables ................ 2) 1490 13 13 Sedeghi Yasmin ysedeghi 18-FEB-91 3 Sales Representative DEPT_TYPE(33.... ’Sales’....------------------------DEPT_ID(ID............. 3) 1515 10 14 Nguyen Mai mnguyen 22-JAN-92 3 Sales Representative DEPT_TYPE(34... 5) 145018 ID LAST_NAME FIRST_NAME USERID ----------------------..--------------......................-------------10 Havel Marta mhavel 27-FEB-91 2 Warehouse Manager DEPT_TYPE(45........... ’Sales’...........-------START_DAT MANAGER_ID TITLE ....... ’Sales’... Oracle Forms Developer: Build Internet Applications I B-35 .....................---------.... NAME................................... ’Sales’.......... 4) 1525 15 15 Dumas Andre adumas 09-OCT-91 3 Sales Representative DEPT_TYPE(35.. ’Sales’............ START_DAT MANAGER_ID TITLE --------............................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.. 1) 1400 10 12 Giljum Henry hgiljum 18-JAN-92 3 Sales Representative DEPT_TYPE(32.........Oracle8 Objects: Types................ 5) 1307 11 Magee Colin cmagee 14-MAY-90 3 Sales Representative DEPT_TYPE(31.....

..............................------------------------DEPT_ID(ID..... 2) 1200 anozaki 19 Patel Vikram 06-AUG-91 7 Stock Clerk DEPT_TYPE(42...... ’Operations’.............................. ’Operations’....-----------------------------..... --------..Appendix B: Table Descriptions and Data ........................ 3) 850 ID LAST_NAME FIRST_NAME USERID ---------............ 3) 750 cnewman 21 Markarian Alexander amarkari 26-MAY-91 8 Stock Clerk DEPT_TYPE(43. ’Operations’............-------------16 Maduro Elena emaduro 07-FEB-92 6 Stock Clerk DEPT_TYPE(41............................. 1) 940 gsmith 18 Nozaki Akira 09-FEB-91 7 Stock Clerk DEPT_TYPE(42............---------------------------------- ..... ’Operations’.........---------.............. ’Operations’... 1) 1400 17 Smith George 08-MAR-90 6 Stock Clerk DEPT_TYPE(41................ REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------........................................................... 2) 795 vpatel 20 Newman Chad 21-JUL-91 8 Stock Clerk DEPT_TYPE(43................... ’Operations’... B-36 Oracle Forms Developer: Build Internet Applications I .......... NAME........-------START_DAT MANAGER_ID TITLE --------..

............................................................. Oracle Forms Developer: Build Internet Applications I B-37 ... 5) 1100 sschwart oo_emp_Table_RefCol Name Null? -----------------------------ID LAST_NAME FIRST_NAME USERID START_DATE MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCTNUMBER(4.... ’Operations’.................................. ’Operations’..............................-------------22 Chang Eddie echang 30-NOV-90 9 Stock Clerk DEPT_TYPE(44. DEPT_ID(ID. 5) 860 bdancs 25 Schwartz Sylvie 09-MAY-91 10 Stock Clerk DEPT_TYPE(45..........Oracle8 Objects: Types... 4) 800 23 Patel Radha 17-OCT-90 9 Stock Clerk DEPT_TYPE(34...................................................2) Type ---------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE NUMBER(7) VARCHAR2(25) REF OF DEPT_TYPE NUMBER(11.... NAME.... 4) 795 rpatel 24 Dancs Bela 17-MAR-91 10 Stock Clerk DEPT_TYPE(45.............. Tables ..............................2) .................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------............................ ’Operations’......... ’Sales’.......

.......... ID LAST_NAME FIRST_NAME USERID ---------........................... B-38 Oracle Forms Developer: Build Internet Applications I ...................-------------1 Velasquez Carmen cvelasqu 03-MAR-90 President 0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 2500 2 Ngao LaDoris lngao 08-MAR-90 1 VP Operations 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 3 Nagayama Midori mnagayam 17-JUN-91 1 VP Sales 0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 4 Quick-To-See Mark mquickto 07-APR-90 1 VP Finance 0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 5 Ropeburn Audry aropebur 04-MAR-90 1 VP Administration 0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1550 .....................................................................-------START_DAT MANAGER_ID TITLE --------................Appendix B: Table Descriptions and Data .................................................. REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.. NAME.....................................................--------------------------------...............................................---------.------------------------DEPT_ID(ID.............

...........Oracle8 Objects: Types............ ID LAST_NAME FIRST_NAME USERID ---------.............---------................................................-----------------...........------------------------DEPT_ID(ID.......... NAME............................-------------6 Urguhart Molly murguhar 18-JAN-91 2 Warehouse Manager 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1200 9 Catchpole Antoinette acatchpo 09-FEB-92 2 Warehouse Manager 0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1300 10 Havel Marta mhavel 27-FEB-91 2 Warehouse Manager 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1307 11 Magee Colin cmagee 14-MAY-90 3 Sales Representative 0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 10 13 Sedeghi Yasmin ysedeghi 18-FEB-91 3 Sales Representative 0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1515 10 ...........-------START_DAT MANAGER_ID TITLE --------... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------................... Tables ..................................................... Oracle Forms Developer: Build Internet Applications I B-39 ...............................--------------...........................................................

.......................................................... ID LAST_NAME FIRST_NAME USERID ---------................................................-------------14 Nguyen Mai mnguyen 22-JAN-92 3 Sales Representative 0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1525 15 15 Dumas Andre adumas 09-OCT-91 3 Sales Representative 0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 18 16 Maduro Elena emaduro 07-FEB-92 6 Stock Clerk 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 17 Smith George gsmith 08-MAR-90 6 Stock Clerk 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 940 18 Nozaki Akira anozaki 09-FEB-91 7 Stock Clerk 0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1200 ...-------START_DAT MANAGER_ID TITLE --------................................ B-40 Oracle Forms Developer: Build Internet Applications I .......---------..................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------........................................... NAME...............................--------------............................------------------------DEPT_ID(ID.........................Appendix B: Table Descriptions and Data .........-----------------...

..................................-------------19 Patel Vikram vpatel 06-AUG-91 7 Stock Clerk 0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 795 20 Newman Chad cnewman 21-JUL-91 8 Stock Clerk 0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 750 21 Markarian Alexander amarkari 26-MAY-91 8 Stock Clerk 0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 850 22 Chang Eddie echang 30-NOV-90 9 Stock Clerk 0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 800 23 Patel Radha rpatel 17-OCT-90 9 Stock Clerk 0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 795 ................................................. Tables ...........Oracle8 Objects: Types..........................................................................................------------------------DEPT_ID(ID........... NAME.-------START_DAT MANAGER_ID TITLE --------.......................--------------------------------...........................---------........... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.......................... ID LAST_NAME FIRST_NAME USERID ---------..................... Oracle Forms Developer: Build Internet Applications I B-41 ....

........-------START_DAT MANAGER_ID TITLE --------.............................................................................Appendix B: Table Descriptions and Data .............................................................------------------------DEPT_ID(ID...-------------24 Dancs Bela bdancs 17-MAR-91 10 Stock Clerk 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 860 25 Schwartz Sylvie sschwart 09-MAY-91 10 Stock Clerk 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1100 oo_dept_table Name -------------------ID NAME REGION_ID Null? ------------- Type ---------------NUMBER VARCHAR2(25) 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 44 Operations 4 45 Operations 5 50 Administration 1 ...................... NAME...... ID LAST_NAME FIRST_NAME USERID ---------................... B-42 Oracle Forms Developer: Build Internet Applications I ........................---------........... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.......................--------------------------------.....................................................

.. Tables .......................................-------START_DAT MANAGER_ID TITLE --------... 1) 1400 mnagayam ... ’Operations’... Oracle Forms Developer: Build Internet Applications I B-43 ........... 1) 2500 2 Ngao LaDoris 08-MAR-90 1 VP Operations DEPT_TYPE(41................................................................------------------------DEPT_ID(ID........Oracle8 Objects: Types......................2) ID LAST_NAME FIRST_NAME USERID ---------......................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.....--------------------------------.............---------........ ’Sales’..........-------------1 Velasquez Carmen cvelasqu 03-MAR-90 President DEPT_TYPE(50....2) NUMBER(4..................................... 1) 1450 lngao 3 Nagayama Midori 17-JUN-91 1 VP Sales DEPT_TYPE(31........ NAME... ’Administration’..................... rel_emp_Table_Objcol Name -------------------ID LAST_NAME FIRST_NAME USERID START_DATE MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCT Null? ------------- Type ---------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE NUMBER(7) VARCHAR2(25) DEPT_TYPE NUMBER(11...........................

....................... ’Finance’............... ’Administration’........................ ’Operations’.... 2) 1250 8 Biri Ben bbiri 07-APR-90 2 Warehouse Manager DEPT_TYPE(43......................................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------....................... ID LAST_NAME FIRST_NAME USERID ---------.......-------START_DAT MANAGER_ID TITLE --------.......... 3) 1100 9 Catchpole Antoinette acatchpo 09-FEB-92 2 Warehouse Manager DEPT_TYPE(44.--------------------------------... ’Operations’................... 4) 1300 ......................................................... ’Operations’.............. NAME...........---------............ B-44 Oracle Forms Developer: Build Internet Applications I ....... 1) 1450 5 Ropeburn Audry aropebur 04-MAR-90 1 VP Administration DEPT_TYPE(50..........-------------4 Quick-To-See Mark mquickto 07-APR-90 1 VP Finance DEPT_TYPE(10. 1) 1550 6 Urguhart Molly murguhar 18-JAN-91 2 Warehouse Manager DEPT_TYPE(41.....Appendix B: Table Descriptions and Data ............ 1) 1200 7 Menchu Roberta rmenchu 14-MAY-90 2 Warehouse Manager DEPT_TYPE(42. ’Operations’..................------------------------DEPT_ID(ID.

..... 1) 1400 10 12 Giljum Henry hgiljum 18-JAN-92 3 Sales Representative DEPT_TYPE(32............ Tables ............... 2) 1490 13 13 Sedeghi Yasmin ysedeghi 18-FEB-91 3 Sales Representative DEPT_TYPE(33. ’Sales’....... ID LAST_NAME FIRST_NAME USERID ---------..... Oracle Forms Developer: Build Internet Applications I B-45 ..... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------............................... 3) 1515 10 14 Nguyen Mai mnguyen 22-JAN-92 3 Sales Representative DEPT_TYPE(34......Oracle8 Objects: Types.....-------START_DAT MANAGER_ID TITLE --------.......... ’Sales’.......... ’Sales’..--------------------------------...........................------------------------DEPT_ID(ID.... ’Sales’............. ’Operations’...............---------..-------------10 Havel Marta mhavel 27-FEB-91 2 Warehouse Manager DEPT_TYPE(45.. 5) 1450 18 ............................................................ 5) 1307 11 Magee Colin cmagee 14-MAY-90 3 Sales Representative DEPT_TYPE(31....................... NAME.............. ’Sales’....... 4) 1525 15 15 Dumas Andre adumas 09-OCT-91 3 Sales Representative DEPT_TYPE(35.......................................

.........------------------------DEPT_ID(ID..---------....... ’Operations’..................................... NAME...................... B-46 Oracle Forms Developer: Build Internet Applications I ..--------------------------------..... 1) 940 gsmith 18 Nozaki Akira 09-FEB-91 7 Stock Clerk DEPT_TYPE(42.. 3) 750 cnewman 21 Markarian Alexander 26-MAY-91 8 Stock Clerk DEPT_TYPE(43............... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------......................... ID LAST_NAME FIRST_NAME USERID ---------....... 2) 795 vpatel 20 Newman Chad 21-JUL-91 8 Stock Clerk DEPT_TYPE(43............... 3) 850 amarkari ................. 2) 1200 anozaki 19 Patel Vikram 06-AUG-91 7 Stock Clerk DEPT_TYPE(42...... ’Operations’.........................-------START_DAT MANAGER_ID TITLE --------.... ’Operations’.... ’Operations’........................................ 1) 1400 17 Smith George 08-MAR-90 6 Stock Clerk DEPT_TYPE(41................ ’Operations’..................................-------------16 Maduro Elena emaduro 07-FEB-92 6 Stock Clerk DEPT_TYPE(41..........Appendix B: Table Descriptions and Data .......... ’Operations’.....

........................ Oracle Forms Developer: Build Internet Applications I B-47 .---------.................................... ’Operations’..................................... ’Operations’....------------------------DEPT_ID(ID....... ’Sales’..... Tables ....-------------22 Chang Eddie echang 30-NOV-90 9 Stock Clerk DEPT_TYPE(44............. ID LAST_NAME FIRST_NAME USERID ---------........................ 4) 800 23 Patel Radha 17-OCT-90 9 Stock Clerk DEPT_TYPE(34............ NAME. 5) 860 bdancs 25 Schwartz Sylvie 09-MAY-91 10 Stock Clerk DEPT_TYPE(45.................. 4) 795 rpatel 24 Dancs Bela 17-MAR-91 10 Stock Clerk DEPT_TYPE(45...-------START_DAT MANAGER_ID TITLE --------..... ’Operations’............. REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.......Oracle8 Objects: Types................. 5) 1100 sschwart ..................................................................--------------------------------...................

.....................................2) .......................................................................Appendix B: Table Descriptions and Data ..... rel_emp_Table_RefCol Name -------------------ID LAST_NAME FIRST_NAME USERID START_DATE MANAGER_ID TITLE DEPT_ID SALARY COMMISSION_PCT Null? ------------- Type ---------------NUMBER(7) VARCHAR2(25) VARCHAR2(25) VARCHAR2(8) DATE NUMBER(7) VARCHAR2(25) REF OF DEPT_TYPE NUMBER(11.. B-48 Oracle Forms Developer: Build Internet Applications I ..........2) NUMBER(4.................................................................................................................................................................................

............--------------------------------............... Oracle Forms Developer: Build Internet Applications I B-49 ............ ID LAST_NAME FIRST_NAME USERID ---------.................................................................................------------------------DEPT_ID(ID.................---------................. NAME...................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------......................................-------------1 Velasquez Carmen cvelasqu 03-MAR-90 President 0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 2500 2 Ngao LaDoris lngao 08-MAR-90 1 VP Operations 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 3 Nagayama Midori mnagayam 17-JUN-91 1 VP Sales 0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 4 Quick-To-See Mark mquickto 07-APR-90 1 VP Finance 0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 5 Ropeburn Audry aropebur 04-MAR-90 1 VP Administration 0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1550 ...............................................................................Oracle8 Objects: Types.......-------START_DAT MANAGER_ID TITLE --------.. Tables ......

.... B-50 Oracle Forms Developer: Build Internet Applications I .................-------------6 Urguhart Molly murguhar 18-JAN-91 2 Warehouse Manager 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1200 9 Catchpole Antoinette acatchpo 09-FEB-92 2 Warehouse Manager 0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1300 10 Havel Marta mhavel 27-FEB-91 2 Warehouse Manager 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1307 11 Magee Colin cmagee 14-MAY-90 3 Sales Representative 0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 10 13 Sedeghi Yasmin ysedeghi 18-FEB-91 3 Sales Representative 0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1515 10 ....................................................--------------------------------..............Appendix B: Table Descriptions and Data .......................................---------.................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------............................ ID LAST_NAME FIRST_NAME USERID ---------...........------------------------DEPT_ID(ID............................................................................. NAME...............................-------START_DAT MANAGER_ID TITLE --------..............

.................... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------........................................-------------14 Nguyen Mai mnguyen 22-JAN-92 3 Sales Representative 0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1525 15 15 Dumas Andre adumas 09-OCT-91 3 Sales Representative 0000220208447F54A9ED5E676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1450 18 16 Maduro Elena emaduro 07-FEB-92 6 Stock Clerk 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1400 17 Smith George gsmith 08-MAR-90 6 Stock Clerk 0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 940 18 Nozaki Akira anozaki 09-FEB-91 7 Stock Clerk 0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1200 ..........................Oracle8 Objects: Types..................................--------------------------------............................ ID LAST_NAME FIRST_NAME USERID ---------...................................... NAME......................... Tables .......................................-------START_DAT MANAGER_ID TITLE --------...... Oracle Forms Developer: Build Internet Applications I B-51 ......................------------------------DEPT_ID(ID.........................---------.....

............................................................ NAME. ID LAST_NAME FIRST_NAME USERID ---------............................... B-52 Oracle Forms Developer: Build Internet Applications I ..............-------------19 Patel Vikram vpatel 06-AUG-91 7 Stock Clerk 0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 795 20 Newman Chad cnewman 21-JUL-91 8 Stock Clerk 0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 750 21 Markarian Alexander amarkari 26-MAY-91 8 Stock Clerk 0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 850 22 Chang Eddie echang 30-NOV-90 9 Stock Clerk 0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 800 23 Patel Radha rpatel 17-OCT-90 9 Stock Clerk 0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 795 .................Appendix B: Table Descriptions and Data .........................................--------------------------------.......................................................-------START_DAT MANAGER_ID TITLE --------..........................................------------------------DEPT_ID(ID... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.....---------......................................

........ NAME..............................................------------------------DEPT_ID(ID.......... Oracle Forms Developer: Build Internet Applications I B-53 ................................. Tables ............................................................... ID LAST_NAME FIRST_NAME USERID ---------.............-------START_DAT MANAGER_ID TITLE --------.....--------------------------------........... REGION_ID) -----------------------------------------------------------SALARY COMMISSION_PCT ---------.................................................-------------24 Dancs Bela bdancs 17-MAR-91 10 Stock Clerk 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 860 25 Schwartz Sylvie sschwart 09-MAY-91 10 Stock Clerk 0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408 002072C15B 1100 ..............................................Oracle8 Objects: Types.....................---------...

...................................................... ........................................................................................................................................................................Appendix B: Table Descriptions and Data ............................................................... B-54 Oracle Forms Developer: Build Internet Applications I ...............

............... Oracle Rdb Overview ..C ................

.. Features include full support for 64bit very large memory on OpenVMS Alpha.................. Default database settings provide great performance for Rdb out of the box................. patented record caching..... mission-critical applications................................................. a patented dynamic query optimizer. Oracle continues to enhance the functionality of Rdb by adding new features and strengthening integration with other Oracle technology and tools. and its customer list includes some of the world’s leading corporations.... What Is Oracle Rdb? Oracle Rdb is a multiuser relational database management system designed and developed by Oracle Corporation for high availability......................................... It includes a full set of utilities for database maintenance and an industrystandard version of SQL that allows you to easily create applications and maintain your Oracle Rdb databases.. The TRACE/Expert Option provides performance monitoring and expert database design for Rdb. high performance......... and query outlines for repeatable query performance...... It is used in many large online transaction processing (OLTP) systems...... pinning tables in memory for rapid access..000 sites worldwide..... Oracle Rdb is currently running on more than 45.............................. The Oracle Rdb server includes management utilities that are accessed using a command-line interface..................... • Ease of management Rdb provides comprehensive...000 servers at more than 15. and the Enterprise Manager DBAPack for Rdb provides a complete set of management tools for Rdb that can be run from the Oracle Enterprise Manager console.......... and ease of use in large-scale.... Supported Platforms Oracle Rdb is available on the following computing platforms: • OpenVMS VAX • OpenVMS Alpha • Windows NT Intel Oracle Rdb Features These are some of the features that Oracle Rdb offers: • High performance Rdb is optimized to meet enterprise OLTP requirements for the highest levels of performance on OpenVMS Alpha and VAX...................... .. mixed clusters..... simple management of Rdb databases.........Appendix C: Oracle Rdb Overview ........................... Rdb8 integration with Oracle Enterprise Manager provides common graphical interfaces to manage Rdb and Oracle RDBMS from the same Windows console......... C-2 Oracle Forms Developer: Build Internet Applications I ..............

..... but it is not recommended for deployment of production systems................. Oracle Designer.... Rdb supports Oracle Application Server.................... and DB Links......... • Disaster tolerance The Hot Standby Option is ideal where very high performance and continuous (24x7x365) availability is essential.......................... Customers and application partners can use standard Oracle APIs to build applications that run on Rdb and Oracle RDBMS... Oracle Reports Developer............................... licensed at no charge and available to users through the Oracle Technology Network........... Customers can make a single investment in products and training that is completely portable across Rdb and Oracle RDBMS... The Workbench is an unsupported developer’s kit........... Rdb includes support for the Oracle Call Level Interface (OCI)............................What Is Oracle Rdb? ......... Oracle network protocols....... ...... Rdb Workbench for Windows NT/Intel is a native. • Support for SQL*Net for Rdb This enables integration with the Oracle technologies listed above....... Oracle Discoverer.... complete implementation of Rdb that is suitable for development and personal use................... multithreaded... Oracle Forms Developer.... Oracle Rdb Features (continued) • Integration with other Oracle technologies Rdb customers can leverage their investment in Rdb by enhancing existing applications and developing new ones with the latest Oracle tools for Web and client-server application development and powerful business intelligence analysis... Data sharing between Rdb and Oracle RDBMS is enabled without the use of gateways....................... Oracle Forms Developer: Build Internet Applications I C-3 ............ It provides disaster tolerance across geographically dispersed systems using the existing network with no change in applications or increment in system overhead.......... The Hot Standby system can be accessed simultaneously for read-only transactions... and Oracle Express Server.......................... • Rdb Workbench for Windows NT/Intel Customers using Oracle Rdb can extend their environment to run Rdb on Windows NT systems....................

.....com Specify that you would like to receive the free Oracle Rdb CD-ROM. including your name........................ C-4 Oracle Forms Developer: Build Internet Applications I ................... go to the Oracle corporate Web site: http://www......Appendix C: Oracle Rdb Overview .com/rdb is the resource for finding out the latest news on the product and its features...... address......................... and company.....................oracle........... send e-mail............................................oracle.......oracle............................. and enrollment information................................ Oracle Rdb Product Information TThe Oracle Rdb Web site: http://www. to: infordb@us................... Look here for information such as: • New product releases • Product interoperability information • How customers are using Oracle Rdb • Calendar of product-related events Oracle Rdb Demonstration CD-ROM TTo receive a free Oracle Rdb product demonstration CD-ROM.......................com or call 1-800-633-0575......... The course titles include: • Introduction to Rdb: Technical Overview and SQL Language • Rdb for the Database Administrator • Rdb for the Database Designer • Rdb 3GL Programming • Rdb Performance and Tuning • Rdb Internals To view course descriptions.......... schedules................. ..... Other Information Oracle Rdb Education Oracle University offers a comprehensive series of Oracle Rdb courses....

D
................................

Locking in Form Builder

Appendix
D: Locking in Form Builder
......................................................................................................................................................

Objectives

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


Identify the locking mechanisms in Form Builder

Plan trigger code to minimize overheads
on locking

Write triggers to invoke or intercept the locking
process

Copyright  Oracle Corporation, 2000. All rights reserved.

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

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

Overview
Locking is an important consideration in multiuser applications that access
the database. This lesson shows you how Forms handles locking and how
you can design forms with these mechanisms in mind.
Instructor Note
Topic
Lecture

Timing
17 minutes

Total

17 minutes

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

Appendix
D: Locking in Form Builder
......................................................................................................................................................

Locking
Insert, update, or delete

Row in (X)

Insert, update, or delete

Row in (X)

Query

Table in (RX)

Copyright  Oracle Corporation, 2000. All rights reserved.

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

Locking
......................................................................................................................................................

Locking
In database applications, locking maintains the consistency and integrity of
the data, where several users are potentially accessing the same tables and
rows. Form Builder applications are involved in this locking process when
they access database information.
Oracle8 Locking
Form Builder applications that connect to an Oracle8 database are subject to
the standard locking mechanisms employed by the server. Here is a reminder
of the main points:
• Oracle8 uses row-level locking to protect data that is being inserted,
updated, or deleted.
• Queries do not prevent other database sessions from performing data
manipulation. This also applies to the reverse situation.
• Locks are released at the end of a database transaction (following a
rollback or commit).
A session issues locks to prevent other sessions from performing certain
actions on a row or table. The main Oracle8 locks that affect Form Builder
applications are the following:
Lock Type
Exclusive (X) row lock
Row Share (RS) table lock

Row Exclusive (RX) table lock

Description
Only allows other sessions to read the affected
rows
Prevents the above lock (X) from being applied to
the entire table; usually occurs because of
SELECT . . . FOR UPDATE
Allows write operations on a table from several
sessions simultaneously, but prevents (X) lock on
entire table; usually occurs because of a DML
operation

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

Appendix
D: Locking in Form Builder
......................................................................................................................................................

Default Locking in Form Builder

Insert record

No locks

Update record

RS on table

Delete record

RS on table

Action

Save

RX on above

Copyright  Oracle Corporation, 2000. All rights reserved.

Concurrent Updates and Deletes

When users compete for the same record, normal
locking protection applies.

Form Builder tells the operator if another user has
already locked the record.

Copyright  Oracle Corporation, 2000. All rights reserved.

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

Default Locking in Forms
......................................................................................................................................................

Default Locking in Forms
Form Builder initiates locking automatically when the operator inserts,
updates, or deletes records in a base table block. These locks are released
when a save is complete.
Form Builder causes the following locks on Oracle base tables and rows,
when the operator performs actions:
Operator Action
Insert a record
Update database items in a record*
Delete record in base table block
Save

Locks
No locks
Row Share (RS) on base table
Exclusive (X) on corresponding row
Row Share (RS) on base table
Exclusive (X) on corresponding row
Row Exclusive (RX) on base tables during the
posting process (Locks are released when
actions are completed successfully.)

*Update of nondatabase items with the Lock Record property set to Yes also causes
this.

The exclusive locks are applied to reserve rows that correspond to records
that the operator is deleting or updating, so that other users cannot perform
conflicting actions on these rows until the locking form has completed
(Saved) its transaction.
What Happens When Users Compete for the Same Row?
Users who are only querying data are not affected here. If two users are
attempting to update or delete the same record, then integrity is protected by
the locking that occurs automatically at row level.
Form Builder also keeps each user informed of these events through
messages and alerts when:
• A row is already locked by another user. The user has the option of
waiting or trying again later.
• Another user has committed changes since a record was queried. The
user must requery before the user’s own change can be applied.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
D-7

Appendix
D: Locking in Form Builder
......................................................................................................................................................

User A: Step 1

Copyright  Oracle Corporation, 2000. All rights reserved.

User B: Step 2

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
D-8
Oracle Forms Developer: Build Internet Applications I

Default Locking in Forms
......................................................................................................................................................

Example: Two Users Accessing the Same Record
1 User A is running the Personnel application and queries the sales
representatives. The record for employee 15, Dumas, is updated so that
his department is changed to 31.
User A does not save the change at this point in time. The row that corresponds to
the changed record is now locked (exclusively). The current situation is shown in
the top slide, opposite.
2 User B is running the Summit application and has started a form that
accesses the sales representatives. Employee Dumas still appears in
department 15 in this form, because User A has not yet saved the change
to the database.
User B attempts to update the record by changing the sales representative’s name
to Agasi. Since this action requests a lock on the row, and this row is already
locked by User A, Forms issues an alert saying the attempt to reserve the record
failed. This user can request additional attempts or reply No and try later.
The situation is shown in the lower slide, opposite. User B replies No. (This results
in the fatal error message 40501, which confirms that the original update action
has failed.)
Instructor Note
Show a similar example, by starting two separate Forms run-time sessions.
Apply the actions as given in steps 1–4.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
D-9

Appendix
D: Locking in Form Builder
......................................................................................................................................................

User A: Step 3

Copyright  Oracle Corporation, 2000. All rights reserved.

User B: Step 4

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
D-10
Oracle Forms Developer: Build Internet Applications I

......Default Locking in Forms ............................. ... Example: Two Users Accessing the Same Record (continued) 3 Back in the Personnel form...................... User B can now alter the record.......................... Form Builder tells User B that it must be requeried before a change can be made............... the record can then be changed........ However.......... which applies the change to the database row and then releases the lock at the end of the transaction................................... User A now saves the change to Dumas’ department...... Once User B requeries........... This situation is shown in the lower slide......... because the database row itself has now changed since it was queried in this form.......................... This is shown in the upper slide. opposite................. 4 In the Sales Representatives form................... Oracle Forms Developer: Build Internet Applications I D-11 ............................................................... opposite.........

All rights reserved........................................................................................Appendix D: Locking in Form Builder ...... ................................................. D-12 Oracle Forms Developer: Build Internet Applications I ........ Concurrent Updates and Deletes Achieved by: • • • • SQL data manipulation language SQL explicit locking statements Built-in subprograms DML statements Copyright  Oracle Corporation....................................................................................................................... 2000..................................

....................... and DELETE statements.. ..Locking in Triggers ................. Oracle Forms Developer: Build Internet Applications I D-13 ..... • Built-in subprograms: Certain built-ins allow you to explicitly lock rows that correspond to the current record (LOCK_RECORD) or to records fetched on a query (ENTER_QUERY and EXECUTE_QUERY).. The LOCK TABLE statement is also allowed.... DML statements should be used only in transactional triggers...................... their execution causes: • Row exclusive lock on the affected table • Exclusive lock on the affected rows Because locks are not released until the end of the transaction....................... ......... These can be: • SQL data manipulation language (DML): Sometimes you may need to perform INSERT................................. just before the end of a transaction when locks are released.. which add to those that Forms does during the saving process (posting and committing)... UPDATE... To keep locking duration to a minimum......... These triggers fire during the process of applying and saving the user’s changes........... database locks can occur in Forms applications because of actions that you include in triggers.............. though rarely necessary.... when all changes have been applied... • SQL locking statements: You can explicitly issue locks from a trigger through the SELECT ........... .............. Locking by DML Statements If you include DML statements in transactional triggers................ it is advantageous to code DML statements as efficiently as possible................. so that their actions are completed quickly........ These trigger SQL commands cause implicit locks on the tables and rows that they affect............................................. Locking in Triggers In addition to the default locking described earlier....... FOR UPDATE statement...............

...................... D-14 Oracle Forms Developer: Build Internet Applications I .............Appendix D: Locking in Form Builder ...................... Locking with Built-ins • • ENTER_QUERY (FOR_UPDATE) EXECUTE_QUERY (FOR_UPDATE) Copyright  Oracle Corporation................................................................................................................... 2000...................... All rights reserved................................................ ..............................................................

....................... Oracle Forms Developer: Build Internet Applications I D-15 ................................ • LOCK_RECORD: This built-in locks the row that corresponds to the current record in the form..................... because large queries cause locking on many rows.................. This item stores the ROWID value for the corresponding row of each record.......... ......... as in the example below: UPDATE s_ord SET date_stamp = SYSDATE WHERE ROWID = :order......................... where it has the same effect as Form Builder’s default locking........... these built-ins exclusively lock the rows fetched for their query...... Updates or deletes in triggers that apply to such rows can identify them most efficiently using this value....................................rowid..................................... Care should be taken when reserving rows in this way....................................... Locking with Built-in Subprograms The following built-ins allow locking: • EXECUTE_QUERY (FOR_UPDATE) and ENTER_QUERY (FOR_UPDATE): When called with the FOR_UPDATE option............................. Locking with Built-ins Form Builder maintains a hidden item called rowid in each base table block.....Locking in Triggers ....... This is typically used in an On-Lock trigger.....

.. 2000..................... END IF......... Copyright  Oracle Corporation............................................... RAISE form_trigger_failure........... All rights reserved.................................................... On-Lock Trigger Example IF USER = ’MANAGER’ THEN LOCK_RECORD............................ ELSE MESSAGE(’You are not authorized to change records here’).............. D-16 Oracle Forms Developer: Build Internet Applications I ............................ .................................................................Appendix D: Locking in Form Builder ...............................

.............Locking in Triggers ..... hence speeding processing • Conditionally lock the record or fail the trigger (Failing the trigger effectively fails the user’s action........................... The trigger fires before the change to the record is displayed......................... Example The following On-Lock trigger on the block Stock only permits the user MANAGER to lock records for update or delete... IF NOT FORM_SUCCESS THEN RAISE form_trigger_failure.. IF USER = ’MANAGER’ THEN LOCK_RECORD.......................................................... ELSE MESSAGE(’You are not authorized to change records here’)............) • Handle locking when directly accessing non-Oracle data sources If this trigger succeeds........ RAISE form_trigger_failure..................... then the row remains unlocked after the user’s update or delete operation................................... On-Lock Trigger This block-level trigger replaces the default locking that Forms normally carries out........ END IF................................. ..... Use this trigger to: • Bypass locking on a single-user system........ but its action does not lock the record.......... END IF......... typically when the user updates or deletes a record in a base table block.. Use the LOCK_RECORD built-in within the trigger if locking is not to be bypassed...... On failure................... Oracle Forms Developer: Build Internet Applications I D-17 ....... the input focus is set on the current item...

................................. 2000. Summary • Default locking – Locks rows during update and delete – Informs user of concurrent update and delete • Locking in triggers – Use SQL and certain built-ins – On-Lock trigger: LOCK_RECORD built-in available Copyright  Oracle Corporation................. D-18 Oracle Forms Developer: Build Internet Applications I ...................... ........................................................................................... All rights reserved...................Appendix D: Locking in Form Builder .........................................................................................................................

......................................................................................................................Summary .................................................................................................................... Summary Default Locking • Locks rows during update and delete • Informs user about concurrent update and delete Locking in Triggers • Use SQL and certain built-ins • On-Lock trigger: LOCK_RECORD built-in available ................................................ Oracle Forms Developer: Build Internet Applications I D-19 ...................

.............................................................. D-20 Oracle Forms Developer: Build Internet Applications I ...........................................Appendix D: Locking in Form Builder ................................................................................................................................................. ...................................................

....... Oracle8 Object Features ......................E ....

...... 2000... object columns............................. ............. All rights reserved............................. E-2 Oracle Forms Developer: Build Internet Applications I ............................... and object views • Describe the INSTEAD-OF triggers • Describe object REFs • Identify the display of objects in the Object Navigator Copyright  Oracle Corporation............................................ Objectives After completing this lesson................................................................Appendix E: Oracle8 Object Features ......................... you should be able to do the following: • Describe the Oracle8 scalar datatypes • Describe object types and objects • Describe object tables...............................................................

........... Oracle Forms Developer: Build Internet Applications I E-3 ....................................... Overview Introduction In this lesson. This lesson also explains how objects are displayed in the Object Navigator....................................................................................................................................................................................................... Objectives After completing this lesson.......... you will review certain object features of Oracle8. object columns......... you should be able to do the following: • Describe the Oracle8 scalar datatypes • Describe object types and objects • Describe object tables........Overview ........................... and object views • Describe the INSTEAD-OF triggers • Describe object REFs • Identify the display of objects in the Object Navigator ..

......................................................Appendix E: Oracle8 Object Features ................................................................... All rights reserved...................................................................................... 2000................... E-4 Oracle Forms Developer: Build Internet Applications I ............................. Oracle8 Scalar Datatypes • NCHAR • NVARCHAR2 • FLOAT • NLS types Copyright  Oracle Corporation................................... ..............

. which might use a fixed-width encoding such as US7ASCII or a variable-width encoding such as JA16SJIS............. which is the total number of binary digits........ Oracle Forms Developer: Build Internet Applications I E-5 ......................... There is no change to the way scalar datatypes are displayed in Oracle Forms Developer and Oracle Reports Developer............ • FLOAT is a subtype of NUMBER........................ Users around the world can interact with the Oracle server in their native languages.... number and date formats adapt automatically to the language conventions specified for a user session...Oracle8 Datatypes .......... With NLS........................................... Oracle8 Datatypes Scalar Datatypes • NCHAR stores fixed-length (blank-padded if necessary) NLS (National Language Support) character data............. which might use a fixed-width encoding such as WE8EBCDIC37C or a variable-width encoding such as JA16DBCS.. However. you cannot specify a scale for FLOAT variables........ You can only specify a binary precision. The datatypes are automatically converted to existing Forms and Reports item datatypes.............................. NLS Types Oracle8 offers extended NLS..... NLS is discussed in Oracle8 Server Reference Manual............................. including national character sets and the datatypes NCHAR and NVARCHAR2....... ...................... How the data is represented internally depends on the national character set.. • NVARCHAR2 stores variable-length NLS character data...................... How the data is represented internally depends on the national character set..................... which store NLS data...............

............................................. E-6 Oracle Forms Developer: Build Internet Applications I ................. .. 2000................................................................... Object Types Attributes Copyright  Oracle Corporation.......................................................................Appendix E: Oracle8 Object Features .................................................................................................. All rights reserved....

.......RNPS... MEMBER PROCEDURE set_dept_id (d_id NUMBER)......... END................. attributes declared in the object type specification are public and those declared in the body are private.......WNDS... PRAGMA RESTRICT_REFERENCES (get_dept_id...........WNPS)..Oracle8 Datatypes . Object Types (continued) Methods An object type is also similar to a package.. END..... END..... these subprograms are known as methods...... Here is an example of an object type: CREATE TYPE dept_type AS OBJECT (dept_idNUMBER(2)................ MEMBER FUNCTION get_dept_id RETURN NUMBER............. object types can be declared in two parts: a specification and a body.......WNPS))....... ......... Like packages... MEMBER FUNCTION get_dept_id RETURN NUMBER IS BEGIN RETURN (dept_id). RNDS............................ A method describes the behavior of an object type............... object types can contain procedures and functions............... loc VARCHAR2(3)............... As with package variables.... Oracle Forms Developer: Build Internet Applications I E-9 ... its attributes are similar to package variables..................... but only those whose specification appears in the object type specification are public methods..... Once an object is declared....... As with package subprograms. dnameVARCHAR2(14)................................ CREATE TYPE BODY dept_type AS MEMBER PROCEDURE set_dept_id (d_id NUMBER) IS BEGIN dept_id := d_id. all methods are defined in the package body........................WNDS..RNPS......... In object types...... PRAGMA RESTRICT_REFERENCES (set_dept_id. Like packages.... RNDS.........

..........................................................................................Appendix E: Oracle8 Object Features ............................ ....................................................................................................................... 2000................... E-8 Oracle Forms Developer: Build Internet Applications I ............... Object Types Attributes Ship ORDER Check status po_no custinfo line_items amount Cancel Hold Methods Copyright  Oracle Corporation................. All rights reserved................

.........WNPS))... loc VARCHAR2(3). As with package variables... A method describes the behavior of an object type....... MEMBER PROCEDURE set_dept_id (d_id NUMBER)... .. END....... END......WNDS................ attributes declared in the object type specification are public and those declared in the body are private.... PRAGMA RESTRICT_REFERENCES (get_dept_id.. RNDS.. these subprograms are known as methods.. but only those whose specification appears in the object type specification are public methods........................... Object Types (continued) Methods An object type is also similar to a package....... Here is an example of an object type: CREATE TYPE dept_type AS OBJECT (dept_idNUMBER(2)............RNPS..Oracle8 Datatypes .. Like packages....... object types can be declared in two parts: a specification and a body...... RNDS. Like packages.......... Oracle Forms Developer: Build Internet Applications I E-9 .RNPS. its attributes are similar to package variables.......... PRAGMA RESTRICT_REFERENCES (set_dept_id.........WNDS............................................................... In object types................... As with package subprograms........ CREATE TYPE BODY dept_type AS MEMBER PROCEDURE set_dept_id (d_id NUMBER) IS BEGIN dept_id := d_id.....WNPS)................ object types can contain procedures and functions................ END.... all methods are defined in the package body...... Once an object is declared................... dnameVARCHAR2(14)....... MEMBER FUNCTION get_dept_id RETURN NUMBER...... MEMBER FUNCTION get_dept_id RETURN NUMBER IS BEGIN RETURN (dept_id).....

................. They are only blueprints for objects......................... Make certain that your students are aware of the overloading of this term......... E-10 Oracle Forms Developer: Build Internet Applications I ........................ This is a completely different usage..................................................... Object Tables Object table based on object type Copyright  Oracle Corporation............................... ... The term object can be confusing because Oracle uses the term to refer to constructs within the database—for example................. and so on..... Instructor Note At this point..... views............ tables.................................... 2000........................Appendix E: Oracle8 Object Features ..... review the fact that object types are not themselves objects............. All rights reserved............................... procedures....

......... 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.................. Object Tables One way to create an object is to create a table whose rows are objects of that object type......... Here is an example of an object table declaration: CREATE TABLE o_dept OF dept_type....Creating Oracle8 Objects ............................................................... But there are significant differences. ....... Oracle Forms Developer: Build Internet Applications I E-11 ..................................... Note: REF types are reviewed later.................................................................. you can create objects based on the type........... Creating Oracle8 Objects Introduction Once you have declared an object type................. The most important difference is that rows in an object table are assigned object IDs (OIDs) and can be referenced using a REF type...........................

............................................ 2000....................................... All rights reserved.................................................................................................................................................................... Object Columns Object column based on object type Copyright  Oracle Corporation............... ......................................Appendix E: Oracle8 Object Features . E-12 Oracle Forms Developer: Build Internet Applications I ...

..................... Object columns are not assigned object IDs (OIDs) and therefore cannot be referenced using object REF values................... as well as one or more object columns........ the rows of a table are objects....................................... phone phone_type)............ In a relational table with an object column.. In the object table.... name VARCHAR2 (45)............... Note: Object REFs are reviewed later in this section................................2). repid NUMBER (4) NOT NULL... Here is an example of a relational table creation statement with an object column: CREATE TABLE o_customer ( custid NUMBER (6) NOT NULL....Creating Oracle8 Objects .............................................. .................................. creditlimit NUMBER (9. address address_type........................ Object Columns Another construct that can be based on an object type is an object column in a relational table............................... Oracle Forms Developer: Build Internet Applications I E-13 .... The table will usually have standard columns.... the column is an object.............

...................................................................Appendix E: Oracle8 Object Features ................... All rights reserved.............. Object Views Object-oriented application Object view Relational table Object views based on object types Copyright  Oracle Corporation....................................................................... .............................. 2000................................................................. E-14 Oracle Forms Developer: Build Internet Applications I ......................................

...... the most difficult part of adopting a new technology is the conversion process itself. a large enterprise might have several applications accessing the same data stored in relational tables....................... an object view transforms the way a table appears to a user..................................... e... Object views make relational tables look like object tables...... Objects accessed through object views are assigned object IDs (OIDs)..................................................Creating Oracle8 Objects ...........sal. During the conversion process. This allows the developers to postpone converting the data from relational structures to object-relational structures until after all of the applications have been converted.. without changing the actual structure of the table.......... Note: Object REFs are reviewed later in this section. Object Views Often.... the relational applications can continue to operate against the relational tables..... Here is an example of an object view creation statement: CREATE VIEW emp_view OF emp_type WITH OBJECT OID (eno) AS SELECT e..... whereas the applications that have not been converted need the data stored in relational tables...... e.. Like all views..empno....job FROM emp e................ The applications that have been converted need the data stored as objects.................... .. e.......... It would convert the applications one at a time...... For example..... If such an enterprise decided to start using objectrelational technology................. and can be referenced using object REFs...... Oracle Forms Developer: Build Internet Applications I E-15 ............ename..... This dilemma is addressed by object views...................... the enterprise would not convert all of the applications at once.......... the object-relational applications can operate against the object view................. That presents a problem...

.. Nonupdatable view INSTEAD-OF Trigger Copyright  Oracle Corporation........................................... .............................................................Appendix E: Oracle8 Object Features ..................... E-16 Oracle Forms Developer: Build Internet Applications I ..................... 2000................................................................................. All rights reserved................................................ INSTEAD-OF Triggers DECLARE BEGIN EXCEPTION END............................

.. INSTEAD-OF triggers are activated for each row.................................................... UPDATE............ they are typically needed with object views............... DELETE...............Creating Oracle8 Objects ........................ and the INSTEAD-OF trigger works invisibly in the background to make the right actions take place............... and UPDATE statements against the view........... .. and DELETE)................ Users write normal INSERT..................... Oracle Forms Developer: Build Internet Applications I E-17 ........................................ These triggers are called INSTEAD-OF triggers because................................... The trigger performs update........ or delete operations directly on the underlying tables.... Object Views (continued) INSTEAD-OF Triggers INSTEAD-OF triggers provide a transparent way of modifying views that cannot be modified directly through SQL DML statements (INSERT........ insert.............. Note: Although INSTEAD-OF triggers can be used with any view....... unlike other types of triggers... the Oracle server fires the trigger instead of executing the triggering statement.............

.........................................Appendix E: Oracle8 Object Features ...................................................................................................................... .......................................................................................................................... E-18 Oracle Forms Developer: Build Internet Applications I ....................

.................... you can associate two records by storing the primary key of one record in one of the columns (the foreign key column) of another.............................. Referencing Objects Introduction In relational databases........ only the OID value for the object................... job VARCHAR2(10)............................. The stored copy of the OID then becomes a pointer..... ........ primary key values are used to uniquely identify records............. O_DEPT........ it is automatically assigned a unique identifier called an object ID (OID). OIDs provide an alternative method.. comm NUMBER(7... ename VARCHAR2(10).............................. hiredate DATE.. to the original object... You can associate two objects by storing the OID of one object in an attribute of another.....Referencing Objects . sal NUMBER(7........................ The object itself is not stored in the table...... In a similar way...... mgr NUMBER(4).. or reference (REF).. Here is an example of a table declaration that includes a column with a REF datatype: CREATE TABLE o_emp ( empno NUMBER(4) NOT NULL........ dept REF dept_type SCOPE IS o_dept) ..............................2)........ Object REFs With relational tables.............. In object-relational databases..... 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.... Note: The REF is scoped here to restrict the reference to a single table.......2)....... The attribute or column that holds the OID is of datatype REF........... Oracle Forms Developer: Build Internet Applications I E-19 ...... Note: Object columns are not assigned OIDs and cannot be pointed to by a REF.. When a row in an object table or object view is created..

........... Object Types in Object Navigator Copyright  Oracle Corporation................................ All rights reserved........ 2000............................................................................................ Object Type Wizard Copyright  Oracle Corporation................... ...........................................Appendix E: Oracle8 Object Features ... All rights reserved..................................................... E-20 Oracle Forms Developer: Build Internet Applications I .. 2000............................................

............. the nested types within address_and_phone_type are displayed in an indented sublevel.............. Displaying Oracle8 Objects in the Object Navigator The Object Navigator lists declared types in the “Database Objects” section.......................... The wizard allows you to define the attributes and methods...... Also..................................... views......... This convention is used for nested object and object type displays throughout Oracle Developer......................................... Object Types Both the attributes and the methods are listed under each type........................................................ Oracle Forms Developer: Build Internet Applications I E-21 .... along with tables............... Oracle8 Type Wizard Object types can be created using the Oracle8 Type Wizard...............................Displaying Oracle8 Objects in the Object Navigator ............. and other Oracle objects..................... .........................

.............................................................................................. Object Columns in Object Navigator Copyright  Oracle Corporation......... 2000..........Appendix E: Oracle8 Object Features ................... All rights reserved........ Object Tables in Object Navigator Copyright  Oracle Corporation........... E-22 Oracle Forms Developer: Build Internet Applications I .............................................................................. ................................... 2000.............. All rights reserved.............................

........... the object table type name is displayed in parentheses after the name of the object table..................................... Object Tables Object tables are displayed like relational tables......Displaying Oracle8 Objects in the Object Navigator ................. Also................................................................................................................ ................ Object Columns Object columns are displayed with the object type in parentheses after the column name and with the attributes of the type indented underneath the column name.......................................... Oracle Forms Developer: Build Internet Applications I E-23 .......................................................... with the attributes of the object displayed like columns in a relational table.......

.............................................. ............................... E-24 Oracle Forms Developer: Build Internet Applications I ......................................................................... 2000.............................................. INSTEAD-OF Trigger Dialog Box Copyright  Oracle Corporation............... All rights reserved............................... 2000... All rights reserved... Object Views in Object Navigator Copyright  Oracle Corporation.......................Appendix E: Oracle8 Object Features ....................................

............................ and delete against object views........ the code in the trigger is executed in place of the triggering DML code..... INSTEAD-OF Triggers INSTEAD-OF database triggers can now be created through the trigger creation dialog box...................................... see Oracle8 Server SQL Reference Manual and Oracle8 Concepts Manual.................................. update...................................... Object Views Object views are displayed like any other view................... Oracle Forms Developer: Build Internet Applications I E-25 .. except that the object type on which they are based is written in parentheses after the view name................................ When a view has an INSTEAD-OF trigger..................... INSTEAD-OF INSERT............ and DELETE triggers allow you to directly insert..... UPDATE................ They can also be used with any other type of view that does not allow direct DML.......Displaying Oracle8 Objects in the Object Navigator ... ........................ just like any other database trigger....... Reference For more information about INSTEAD-OF triggers................

....................................... Object REFs in Object Navigator Copyright  Oracle Corporation...........................................Appendix E: Oracle8 Object Features .................. E-26 Oracle Forms Developer: Build Internet Applications I .................. 2000.. All rights reserved............................................................................................................................................... .........................................

.................................................... .................................. Object REFs Object types that contain attributes of type REF.......... Oracle Forms Developer: Build Internet Applications I E-27 ........Displaying Oracle8 Objects in the Object Navigator ................................... and relational tables that have columns of type REF......... The attributes of the referenced object type are displayed indented under the column or attribute.................................................. display the keyword REF before the name of the object type that is being referenced...........................................................................................................

... • Object REFs store the object identifier of certain types of objects... All rights reserved....... object columns............... and object views............... 2000....... Summary • INSTEAD-OF triggers allow DML on object views....... Summary • Oracle8 introduced three scalar datatypes............... • Three kinds of objects are object tables......... ...... • The Object Navigator can display certain types of objects......................Appendix E: Oracle8 Object Features .................................................................................... All rights reserved.................. 2000.................................... • Objects and object types allow representation of complex data..................... E-28 Oracle Forms Developer: Build Internet Applications I ........................... Copyright  Oracle Corporation........ Copyright  Oracle Corporation............

.............. ................ Objects Three kinds of objects are object tables..................Summary ................................ Summary Oracle8 Datatypes Oracle8 introduced three scalar datatypes and composite datatypes such as object types.... Object REFs store the object identifier of certain types of objects............. Oracle Forms Developer: Build Internet Applications I E-29 .............................. INSTEAD-OF triggers allow DML on object views................................................. and object views. Oracle8 Objects in the Object Navigator The Object Navigator can display certain types of objects...................................................................................................................... object columns.............

........................................................................................ E-30 Oracle Forms Developer: Build Internet Applications I ................................................................................................................................................ ...............................................................Appendix E: Oracle8 Object Features ......

....... Using the Layout Editor .......................F ...

.... .................................................................................................................................................... 2000.... you should be able to do the following: • Control the position and size of objects in a layout • Add lines and geometric shapes • Define the colors and fonts used for text • Color the body and boundaries of objects • Import images onto the layout Copyright  Oracle Corporation..........Appendix F: Using the Layout Editor ................................................. Objectives After completing this lesson............ All rights reserved............................. F-2 Oracle Forms Developer: Build Internet Applications I .................................................

....................................................... Objectives After completing this lesson...................................... you should be able to do the following: • Control the position and size of objects in a layout • Add lines and geometric shapes • Define the colors and fonts used for text • Color the body and boundaries of objects • Import images onto the layout Schedule Topic Lecture Timing 20 minutes Total 20 minutes ............ This will help you control the visual arrangement and appearance of objects in your applications......................................................................................... Overview Introduction In this lesson........................ Oracle Forms Developer: Build Internet Applications I F-3 ................................. you learn the graphical features of the Layout Editor common to Oracle Forms Developer and Oracle Reports Developer.....................................................Overview .

. Using the Layout Editor Layout types: • Canvases in Forms • Report layouts Copyright  Oracle Corporation..................................... F-4 Oracle Forms Developer: Build Internet Applications I .............................. ....... All rights reserved............ Using the Layout Editor Common features: • Moving and resizing objects and text • Defining colors and fonts • Importing and manipulating images and drawings • Creating geometric lines and shapes Copyright  Oracle Corporation................................................................ 2000...............Appendix F: Using the Layout Editor ..................................................................... 2000......... All rights reserved...............................................................

....... graphics....................... their views might overlay others in the same window............ This includes the frame structure of the report........... and other geometric shapes • Importing and manipulating images on the layout • Changing the font style and weight of text • Accessing the properties of objects that you see in the layout Layout Types You can use the Layout Editor to control the visual layout in Oracle Forms Developer and Oracle Reports Developer........................ Some objects occur only in a subset of the Oracle Forms Developer and Oracle Reports Developer tools................. .. Why Use the Layout Editor? The Layout Editor is a graphical tool for defining the arrangement and appearance of visual objects.............................. and background text (boilerplate)............................... The Layout Editor opens windows in Form Builder and Report Builder to present the surfaces on which you can arrange objects..... You can also display stacked views in the Layout Editor................... • Layouts in Reports Here..................... and so the associated Layout Editor appears only there......... Oracle Forms Developer: Build Internet Applications I F-5 .... the Layout Editor lets you plan the format of a report............ as well as buttons....Why Use the Layout Editor? ............................................ boxes. The following are common to each tool: • Moving objects to new positions in the layout and aligning them with each other • Resizing objects and text • Defining the colors of text and visual objects • Creating lines........... You can also see stacked or tabbed canvas views in the Layout Editor.......... Its view is the portion of that canvas that is initially visible in a window at run time........ The surfaces include: • Canvas views in Forms A canvas is the surface on which you arrange a form’s objects..............

...... Instructor Note Demonstration: • Accessing through the Tools menu • Access through the Navigator • Closing and minimizing the Layout Editor window • Reopening the Layout Editor ........................................................................................................................Appendix F: Using the Layout Editor .................................................................................................. All rights reserved..................... F-6 Oracle Forms Developer: Build Internet Applications I ................ Invoking the Layout Editor Copyright  Oracle Corporation..................... 2000......................

............ you can open several Layout Editor windows—one for each canvas view.. .. and the Parameter Form Editor—that are displayed in the same window.... select View—>Layout Model from the builder menu to set the context for the editor window.................. You can do this by selecting the appropriate objects in the Navigator....................... Oracle Forms Developer: Build Internet Applications I F-7 ............ Opening from the Builder Menus 1 Make sure that you have a context for either a form in Forms or a report in Reports................... Closing the Layout Editor You can close or minimize the Layout Editor window or windows as you would any window. Make sure that you have the canvas that you want.. Note: Reports has three editors—the Layout Editor......................... the Data Model Editor. select Tools—>Layout Editor from the builder menu................................ Opening from the Object Navigator • In Forms: Double-click a canvas view icon in a form hierarchy................... • In Reports: Double-click the Layout icon in a report hierarchy............. In Reports.. In Forms............................ one at a time..........................How to Access the Layout Editor ....................... This applies whether you are doing so for the first time in a session or at a later stage....................... If you have minimized an existing Layout Editor window...... 2 In Forms.............. you can also reacquire it in the way that you would any window............ How to Access the Layout Editor You can invoke the Layout Editor from either the builder menus or the Object Navigator..

................................................................................Appendix F: Using the Layout Editor ................................. All rights reserved...................................................... F-8 Oracle Forms Developer: Build Internet Applications I ..................................................................... .................. Layout Editor: Components 1 6 3 5 2 4 Copyright  Oracle Corporation.............. 2000....................................

......Product-specific tools ... You can switch these off or have their units altered.. scroll buttons appear on the vertical toolbar.................................. Components of the Layout Editor Common components of the Layout Editor are: • Menu facilities While the Layout Editor window is active.. Arrange. • Status line This appears at the bottom of the window........................ These are submenus for controlling the Layout Editor...Manipulation tools for controlling color and patterns • Rulers and ruler guides Rulers are horizontal and vertical markers to aid alignment............ as required.............................. and Format....... Note that some tools in the palette may be hidden if you have reduced the size of the Layout Editor window............................. the Main builder menu changes to include three new items: View.. Oracle Forms Developer: Build Internet Applications I F-9 ...Components of the Layout Editor ......... You can switch off or rescale this grid if required (in Forms........ ....................Graphics tools for creating and modifying lines and shapes .. they appear at the top and side of the layout region........ Drag ruler guides from the rulers across the layout region to mark positions in the layout............. There are three types of tools: .... • Horizontal toolbar This appears across the top of the window and is a subset of the tools from the Object Navigator...................................... If so....... It shows you the mouse position and drag distance (when moving objects) and the current magnification level..... • Style bar This appears under the horizontal toolbar and is a subset of the Format menu..................... It may also contain some other tools...... • Vertical toolbar This contains the tools for creating and modifying objects on the layout...... the grid is hidden if the View—>Show Canvas option is switched on).. • Layout/Painting region This is the main central/right area where you can place and manipulate objects......... A grid pattern is displayed in this area to aid alignment of objects...........

............................................................................................................................Appendix F: Using the Layout Editor ............................... F-10 Oracle Forms Developer: Build Internet Applications I ....... All rights reserved....................................................................... Tool Palette 1 2 3 4 5 6 7 8 9 10 11 12 13 Copyright  Oracle Corporation..................... 2000................ 1 Select 8 Rotate 2 Magnify 9 Reshape 3 Rectangle 10 Line 4 Ellipse 11 Arc 5 Polygon 12 Polyline 6 Rounded rectangle 13 Freehand 7 Text Instructor Note Show in the Layout Editor: • Creating a line and at least one other shape • Using the Freehand tool • Creating a circle or square using Constrained mode • Creating boilerplate text................ with text over multiple lines • Double-clicking the palette tool to retain selection ...................

.................... 2 Position the mouse at the start point for the new object in the layout....... Uses of text objects vary according to the Oracle Developer tool in which you create them....... 3 Release the mouse button........ You can type one or more lines of text into this object while it is selected with the Text tool.......................... a circle instead of an ellipse) by pressing the [Shift] key during step 2.......... Creating a New Line or Shape 1 Select the required graphic tool from the vertical toolbar with a mouse click. Creating Text The Text tool (T) lets you open a Boilerplate Text object on the layout............Creating and Modifying Objects in the Layout ................. Note: You can produce constrained shapes (for example......................................................... Creating and Modifying Objects in the Layout You can perform actions in the Layout Editor by selecting from the vertical toolbar and the builder menus and by controlling objects directly in the layout region............................................. This selects the tool for a single operation on the layout (a doubleclick causes the tool to remain active for subsequent operations)................. and then click-and-drag to the required size and shape.. with which you can select and move objects.. These include: • Rectangles/squares • Ellipses/circles • Polygons and polylines • Lines and arcs • Freehand tool The default tool in the vertical toolbar is Select............ Notice that the object remains selected after this procedure (selection handles appear on its boundaries) until you deselect it by clicking elsewhere........................................... Creating Lines and Shapes Create geometric lines and shapes by selecting from the graphics tools in the vertical toolbar......... ........ Oracle Forms Developer: Build Internet Applications I F-11 .............

2000..................................................................................... All rights reserved........ 2000.. ................................... All rights reserved................................................................. Selecting Objects Copyright  Oracle Corporation........ Manipulating Objects Expand/contract in one direction Expand/contract diagonally Copyright  Oracle Corporation............................................. F-12 Oracle Forms Developer: Build Internet Applications I ......................Appendix F: Using the Layout Editor .....................................

.. To select several objects together.. To select one object........... Oracle Forms Developer: Build Internet Applications I F-13 .............. This means that squares remain as squares....... Selecting Objects for Modification With the Select tool active. which can present a similar problem where it has no center to select....................... ................................... Note: By holding down the [Shift] key...............Creating and Modifying Objects in the Layout ....................................... and bit-mapped images do not become distorted when resized...... you can select one or more objects on the layout to move or modify........................... do one of the following: • Hold down the [Shift] key and then click each object to be selected • Draw a bounding box around the objects (providing the objects are adjacent to each other) Changing the Size or Ratio When an object is selected.............. so that an operation can be performed on them simultaneously......... • Midpoint handles: Position the mouse on one of these to change the size or ratio in a horizontal or vertical direction.................................. you can resize an object without changing its ratios.............. Also.... an object may be transparent (No Fill).............. It is convenient to select several objects. two types of selection handles are visible: • Corner handles: Position the mouse on one of these to change the size or ratio of the object diagonally...... do one of the following: • Click the object with the mouse • Draw a bounding box around it If the object is small or narrow...... it is sometimes easier to use the second method...................................

......... pointing out handles • Moving an object on the layout • Lining up several objects using the Align Objects dialog box • Moving objects while grid-snap is on • How grid and grid-snap can be turned on/off and how units can be altered (pointing out the warning opposite) • Overlapping some objects and changing layering through the Arrange menu ............................................................................................................... and Overlapping Copyright  Oracle Corporation............ All rights reserved..................................... Moving.......................... 2000........ Aligning..............Appendix F: Using the Layout Editor ................................................... F-14 Oracle Forms Developer: Build Internet Applications I .......... Instructor Note Create your own objects to show the following: • Selecting multiple objects by [Shift] + click • Selecting by a bounding box • Losing the association after you deselect • Expanding and contracting in different directions.............................

.Creating and Modifying Objects in the Layout .............. • Align the objects with each other: Objects can be aligned with the leftmost................. A Note on Grid-Snap Alignment You can ensure that all objects that you move align with snap points that are defined on the grid. To activate these...... or lowest object selected............................ They can also be centered and aligned with the grid.. highest............. if you use grid-snap at all..................... Try to stick to the same snap units........ Moving and Aligning Objects When one or more objects are selected in the layout........ Change the stacking order of overlapping objects by selecting the object to move and then choosing the following as required......... Overlapping Objects You can position objects on top of each other......................................... rightmost................. Note: If you position an object using one grid-snap spacing............ select View—>Snap to Grid from the menu......................... You can use the grid and ruler lines to help you position them properly......... If they are transparent.. then one object can be seen through another (this is explained in detail later in this lesson).... You can do this using the Alignment feature in the Arrange menu: Select Arrange—>Align Objects... it may prove difficult to align them with each other........... and then set the options required in the Alignment Settings dialog box.... Oracle Forms Developer: Build Internet Applications I F-15 .................... you can: • Move them to a new location: Do this by dragging to the required position and releasing the mouse button....... and then try to position other objects under different settings...................... You can also use the View options to change the grid-snap spacing and units..... from the Arrange menu: • Bring to Front • Send to Back • Move Forward • Move Backward ..............

.............. • Tool-specific operations exist for groups........................................... and then show how they can be manipulated as one............ All rights reserved........................ • Demonstrate zooming in/out using the Magnify tool.................................... • Point out or mention the other grouping options (Group Operations menu).... Instructor Note Create your own objects to do the following: • Place some objects into a group. Copyright  Oracle Corporation.......... or resized..... moved.... 2000........ • Groups have a single set of selection handles..........................Appendix F: Using the Layout Editor . Point out the single set of handles......... • Groups can be colored................................... • Show Undo/Redo of a Layout Editor operation from the Edit menu........ ................................... • Members can be added or removed................. F-16 Oracle Forms Developer: Build Internet Applications I ...... Groups in the Layout • Groups allow several objects to be repeatedly treated as one...................

Placing Objects into a Group 1 Select the objects in the layout that are to be grouped together.......... [Shift] + click reduces magnification..... Note: You can undo your previous action in the current Layout Editor session by selecting Edit—>Undo from the menu......Creating and Modifying Objects in the Layout ... coloring..... and other operations will now apply to the group..................... Other Tools for Manipulating Objects • Rotate: You can rotate a line or shape through an angle... which you can treat as a single object whenever you select a member within it............ • Reshape: You can change size/ratio of a shape that has been rotated or change the sweep angle of an arc. Manipulating Individual Group Members To manipulate group members individually....................... moving......................................................... You will notice there is now a single set of selection handles for the group.. Manipulating Objects As a Group Sometimes.... Resizing........... Oracle Forms Developer: Build Internet Applications I F-17 ... you want to group objects together in the layout so that they behave as a single object..... You can also reshape a polygon or polyline. You can use options in the Group Operations menu to remove objects from the group or to reselect the parent group............ select the group and then click the individual member............... • Magnify: You can increase magnification when you click at a desired zoom position on the layout region. 2 Select Arrange—>Group from the menu............................................................... ............. using the tool’s selection handles.......... The Arrange menu also gives you options to add and remove members....................................

.................................................................. All rights reserved...... 2000........ F-18 Oracle Forms Developer: Build Internet Applications I .......... Instructor Note Provide an overview of the Format menu options and demonstrate: • Changing the line thickness of a shape • Producing bevel effects on this shape • Changing the font size and style of boilerplate text ................ Format Menu Copyright  Oracle Corporation.........................................................................................................................................................................Appendix F: Using the Layout Editor .............................

..................... 2 Select the font style and size that you require from the style bar or select Format from the Main Builder menu.......Formatting Objects in the Layout ...................... the font choices may appear in the Format menu itself....... depending on which builder you are using................ Font settings are ignored if the application is run in character mode..... Oracle Forms Developer: Build Internet Applications I F-19 ................. ...... These include: • Font sizes and styles • Spacing in lines of text • Alignment of text in a text object • Line thickness and dashing of lines • Bevel (3D) effects on objects • General drawing options (for example... style of curves and corners) Whichever formatting option you intend to use..................... and then choose the necessary option from the Format menu......... first select the objects that you intend to change on the layout........................................ selecting Font from the menu opens the standard Windows Font dialog....... In other GUI environments..... and the select the font style and size that you require.... Formatting Objects in the Layout The builder’s Format menu provides a variety of facilities for changing the style and appearance of objects in the layout. Changing Fonts on Textual Objects There are a number of ways to change the font characteristics of textual objects................. The common steps provided by the Layout Editor are: 1 Select the objects in the layout whose content text you want to change (these may be boilerplate text objects and other textual object types supported by the Oracle Developer tool that you are using)......................................................................... Some of the format options are available from the style bar............................... Note: In Microsoft Windows.....

........ 2000................ All rights reserved............................................................. F-20 Oracle Forms Developer: Build Internet Applications I ..................Appendix F: Using the Layout Editor ......................... 1 Sample window 2 Fill color/pattern 3 Line color 4 Text color ........... Color and Pattern Tools 1 2 3 4 Copyright  Oracle Corporation.....................................................................................................................................................................

..... and follow the next step.. Select No Line at the bottom of this window to remove the objects’ boundary lines.................. Oracle Forms Developer: Build Internet Applications I F-21 ....................... The color palette opens... then select Patterns from the bottom of the color palette........ 4 If you select Patterns..................................... 2 Select the color for lines and bounding lines from this color palette.Coloring Objects and Text .... select No Fill at the bottom of the color palette window........ Select one...... • Text Color: Use this tool to choose the color for the text......... 3 Select a color from those visible.... Coloring a Line 1 With the desired layout objects selected.......... The color palette appears....... another window appears with patterns for you to choose. These are: • Fill Color: Use this tool to define the colors and pattern for an object’s body......... the affected objects become invisible.................. Coloring Objects You can separately color the fill area (body) of an object and its boundary line (a line object has no body)......... Note: If you set both No Fill and No Line........... • Line Color: Use this tool to define the color of a line or the boundary line around an object.................... If you want the fill area to be patterned instead of plain.. If you want the objects to become transparent...... You can define separate colors for the two shades of the pattern by selecting the pattern color buttons at the bottom of the Fill Pattern palette........... Coloring Objects and Text There are three tools in the vertical toolbar for coloring objects........... click the Line Color tool............... 2 Select the Fill Color tool..... Coloring an Area 1 Select the objects whose color you want to change................................................. ...... each button opens a further color palette.........

.. 2000..................................................................... F-22 Oracle Forms Developer: Build Internet Applications I ...................Appendix F: Using the Layout Editor .............................................................................................................................................................................. Color and Pattern Tools 1 2 3 4 Copyright  Oracle Corporation.. All rights reserved.......... 1 Sample window 2 Fill color/pattern 3 Line color 4 Text color Instructor Note Show the following: • Coloring the body of a shape • Changing the fill pattern and how elements of the pattern can be colored • Making an object transparent and how other objects can then be seen through it • Coloring lines and removing them completely • Coloring text • How color palettes can be torn off and repositioned • How color settings are retained in the Layout Editor • How to modify the color palette ............................

....... Changes to the color palette are saved with the current module... 3 Select a color from those shown (click the appropriate square)....................................... This option is available only when the builder option Color Palette Mode is set to Editable... showing the available colors............ Coloring Text 1 Select the textual objects whose color you want to change in the layout............ Also.................. Note: Modifications to the color palette will not be apparent until you close the document and reopen it................ This indicates the current text color setting..................................................... Altering the Color Palette By selecting Format—>Layout Options—>Color Palette from the menu..................................... ........................................... Oracle Forms Developer: Build Internet Applications I F-23 ........ you can edit the color palette that is presented when selecting colors.. The color palette appears......................Coloring Objects and Text ... 4 Notice that the selected objects on the layout have adopted the chosen text color.......... 2 Select the Text Color tool.. and this color appears next to the Text Color tool................ the sample area in the vertical toolbar shows a T with the selected color..........

.. Importing Images Copyright  Oracle Corporation......... Show that boilerplate images can be moved and resized on the layout................ Recommend using summitlo........tif................................................................................ All rights reserved................................................................. 2000.............. Instructor Note Show how to import an image from the file system.................................................Appendix F: Using the Layout Editor ............ pointing out the various file formats that are supported................... F-24 Oracle Forms Developer: Build Internet Applications I .............................. .....

...... This is a trade-off between image resolution and memory required....... TIFF.............................. Importing Images Select File—>Import—>Image from the menus.... PICT..... Importing Images and Drawings Oracle Forms Developer and Oracle Reports Developer allow both static and dynamic bit-mapped images to be integrated into the application......... and specify the source in the Import dialog box.... you can move it or resize it like other objects on the layout...................... These might include: • Company logos • Photographs for inclusion in a report or display • Background artwork Importing Drawings You can import line art onto the layout from either the file system or the database....... RAS.. and PCD [Kodak Photo CD]) Range from Excellent to Poor...... Manipulating the Imported Image or Drawing When the imported image or drawing appears on the layout............. CALS...................................... those that are fixed on the layout............ PCX............................................ Oracle Format............ This section discusses how you can import static images and drawings—that is....... Select File—>Import—>Drawing from the menus..... GIF.......... It is usually better to resize images in Constrained mode (while pressing the [Shift] key) so the image does not become distorted....... The format can be Oracle or a CGM file..... Oracle Forms Developer: Build Internet Applications I F-25 ..........................................Importing Images and Drawings ..... and set the Import Image options: Option (Radio buttons) File/Database Filename Format Quality Description Where to import from File to be imported Image format (BMP...... ..............

..................... All rights reserved............................................................ Copyright  Oracle Corporation............................................................... lines........ ........ • View.................... and text.......Appendix F: Using the Layout Editor .......................... • You can import images and drawings by using File—>Import............................ and Format menus are available for layout................................ 2000...... Summary • You can create objects by: – Choosing a palette tool – Clicking and dragging on a layout region • There are color palette tools for fill area................ Arrange.... • Objects can be grouped for operations.......... F-26 Oracle Forms Developer: Build Internet Applications I ...

.............................Choosing the correct toolbar tool .......... Arrange.................. lines.............Summary ................ Summary • • • • • You can create objects by: .Clicking and dragging the layout region There are color palette tools for fill area............................. You can import images and drawings by selecting Edit—>Import................... View........................... You can group objects for operations................... Oracle Forms Developer: Build Internet Applications I F-27 ........................ and Format menus are available while you are in the Layout Editor...................... ....................................... and text.............................................

................................................................ ......................................................................Appendix F: Using the Layout Editor ......................................................................................................................................................... F-28 Oracle Forms Developer: Build Internet Applications I ..............

.... Introduction to Query Builder ............G .................

............... Query Builder Features • • • • Easy-to-use data access tool Point-and-click graphical user interface Distributed data access Powerful query building Copyright  Oracle Corporation.................................................................................. G-2 Oracle Forms Developer: Build Internet Applications I . 2000...................................................................................................................... All rights reserved.................. .............................Appendix G: Introduction to Query Builder ........................................

......... and so on) as graphical datasources... It provides a logical and intuitive means to access information stored in networked.... Oracle Forms Developer: Build Internet Applications I G-3 ..... • Locating database objects is easy because Query Builder uses a single hierarchical directory that lists all accessible data in your account........................ which look and work exactly the same way regardless of which database or account the data came from.. distributed databases for analysis and reporting................................... Point-and-Click Graphical User Interface Query Builder enables you to become productive quickly because its graphical user interface works like your other applications................................. enterprisewide databases is no more difficult than querying a single database..................................................... A toolbar enables you to perform common operations quickly............ • Performing distributed queries on complex..What Is Query Builder? ........................... Distributed Data Access Query Builder represents all database objects (tables... What Is Query Builder? Easy-to-Use Data Access Tool Query Builder is an easy-to-use data access tool................ .................... in other accounts... views................................................ and in other databases...............

...... 2000........ ........................ G-4 Oracle Forms Developer: Build Internet Applications I ...................................................................................................................................................................................... Query Builder Features • • • • Easy-to-use data access tool Point-and-click graphical user interface Distributed data access Powerful query building Copyright  Oracle Corporation............................................................................Appendix G: Introduction to Query Builder .. All rights reserved.....

... • You can specify exactly which rows to retrieve from the database by using conditions................ which consist of any valid SQL expression that evaluates to true or false........................ The browser generates the necessary SQL statements behind the scenes..................... • Graphical representation of tables and their relationships enables you to see the structure of your data......... • You can build queries by clicking the columns that you want to retrieve from the database............................. Note: Query Builder as a tool in itself also includes WYSIWYG formatting and reporting capabilities........................................................... Powerful Query Building Query Builder is designed for professionals who do not have a computer programming or database background................ This appendix describes Query Builder as part of tools such as Report Builder..... Oracle Forms Developer: Build Internet Applications I G-5 .....What Is Query Builder? ................................ because of its powerful query features and its support of Structured Query Language (SQL) statements.................... • You can combine and nest conditions graphically using logical operators............ You can disable conditions temporarily for what-if analysis. experienced database users and programmers will find that Query Builder serves many of their needs as well....................... ................................... However...

........................................................................ All rights reserved..........................Appendix G: Introduction to Query Builder ......................................................................................... 1 2 3 Toolbar Conditions panel Datasource panel ....................................................................... 2000........ G-6 Oracle Forms Developer: Build Internet Applications I .................... Query Builder Window 1 Copyright  Oracle Corporation.................

The Query Builder Window
.....................................................................................................................................................

The Query Builder Window
The Query Builder graphical user interface consists of one window, the Query
window, where you build your queries.
Query Window Panels
The Query window is divided into two panels:
• The Conditions panel where you specify conditions to refine your queries
• The Datasource panel where you display and select tables and columns for a query
Toolbar
The toolbar enables you to issue commands with a click of the mouse. You can create
conditions, add new datasources, or define new columns.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
G-7

Appendix G: Introduction to Query Builder
.....................................................................................................................................................

Building a New Query

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
G-8
Oracle Forms Developer: Build Internet Applications I

Building a New Query
.....................................................................................................................................................

Building a New Query
To build a query, you must select the tables you want to include and the columns you
want to retrieve.
How to Include a Table
1 Choose Select Data Tables from the toolbar.
The Select Data Tables dialog box appears.
Note: When you open Query Builder to create a new query, the Select Data Tables
dialog box is open by default.
2 Select the table name and then click Include, or simply double-click the desired
table name.
The selected table appears in the Query window.
3 Click Close to close the dialog box.
You can at any time include additional tables in the query by following these steps.
How to Delete a Table
1 Select the data source in the Query window.
2 Select Clear from the toolbar or press [Delete].

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
G-9

Appendix G: Introduction to Query Builder
.....................................................................................................................................................

Datasource Components

1

5

2

6

3
7
8

4
Copyright  Oracle Corporation, 2000. All rights reserved.

1
2
3
4

Datasource name
Primary key
Column name
Foreign key

5
6
7
8

Object type
Column datatype
Recursive relationship icon
Comments icon

......................................................................................................................................................
G-10
Oracle Forms Developer: Build Internet Applications I

Datasource Components
.....................................................................................................................................................

Datasource Components
Tables
A table that has been included in a query is referred to as a datasource. It is displayed
as a rectangular graphic in the Datasource panel of the Query window. The top part of
the rectangle contains the table name and an icon representing its type.
Type
Table
View
Synonym

Alias

Description
Stores data in the database.
Acts like a table when you execute a query, but is really a pointer to either
a subset of a table, a combination of tables, or a join of two or more tables.
Another name for an object. Sometimes table names can be rather cryptic,
such as emp_em_con_tbl. You can create a synonym that simply calls this
table Contracts.
Query Builder uses an alias name for a table when the table is used more
than once, mostly with self-joins (you can also rename a table).

Columns
The body of the rectangle contains column names listed vertically. To the right of the
column name is an icon representing the datatype.
Columns also provide additional information.
• Primary keys are displayed in bold.
• Foreign keys are displayed in italics.
• Recursive relationships are indicated by a self-relationship icon.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
G-11

Appendix G: Introduction to Query Builder
.....................................................................................................................................................

Refining a Query

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
G-12
Oracle Forms Developer: Build Internet Applications I

Refining a Query
.....................................................................................................................................................

Refining a Query
Adding Columns to a Query
There are several methods of adding columns to a query:
• Select the check box to the right of the column name
• Double-click the column name
To include all columns from any single table, double-click the table heading.
Removing Columns to a Query
There are several methods of removing columns to a query:
• Clear the check box to the right of the column name
• Double-click the column name
To remove all columns from any single table, double-click the table heading.
Changing Column Position in a Query
By default, Query Builder places columns in the order in which you select them. You
can resequence them by selecting the Column Sequence tool.
The Column Sequence dialog box appears. Column names are shown in the Displayed
Columns list in order of their appearance in the query. Drag any column to a new
position.
Note: You can also use the Column Sequence dialog box to add columns to or remove
them from a query.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
G-13

Appendix G: Introduction to Query Builder
.....................................................................................................................................................

Sorting Data

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
G-14
Oracle Forms Developer: Build Internet Applications I

Refining a Query
.....................................................................................................................................................

Sorting Data
By default, a query returns the data in no specific order. To sort the data, you must add
an ORDER BY clause to the query.
How to Add an ORDER BY Clause to a Query
1 Select the Sort tool. The Sort dialog box appears.
2 Select the column you want to sort from the Available Columns list.
3 Select Copy.
Query Builder adds the column to the Sorted Columns list and places an up arrow
in the list box to indicate the default sort ascending order.
Note: You can sort by more than one column. Query Builder sorts according to the
order in which columns appear in the Sorted Columns list.
4 You can change the sorting order by selecting the column name in the Sorted
Columns list and selecting the desired option button.
5 Select OK to close the dialog box.

......................................................................................................................................................
Oracle Forms Developer: Build Internet Applications I
G-15

Appendix G: Introduction to Query Builder
.....................................................................................................................................................

Viewing and Saving Queries

Copyright  Oracle Corporation, 2000. All rights reserved.

......................................................................................................................................................
G-16
Oracle Forms Developer: Build Internet Applications I

.......SQL file extension................................................. 1 Select the Save tool from the toolbar............. How to Save a Query You can save your query as a SQL statement to the file system..................... Note: If you do not enter a file extension.. 4 Click OK................................................................................................................................... 2 Enter a filename..... Viewing and Saving Queries Viewing a Query Select the Show SQL tool to view the query text that Query Builder will create.............. Query Builder automatically appends the ...............Viewing and Saving Queries ..... Oracle Forms Developer: Build Internet Applications I G-17 .. The Save As dialog box appears.................. 3 Select a destination..... .......................

..................................................................... Including Additional Tables Copyright  Oracle Corporation............................................................................................................ G-18 Oracle Forms Developer: Build Internet Applications I .Appendix G: Introduction to Query Builder ................... All rights reserved.............................. ...................................... 2000......................................

...... 4 Follow the normal procedure for including tables in the Query window..................... you can include multiple tables in a single query............... or simply doubleclick the account name..... How to Find Tables in Other Accounts If you do not find the table you are looking for in the Select Data Tables dialog box in your own account................... How to Find Tables in Other Databases If you do not find the table you are looking for in the Select Data Tables dialog box in your own account............. This opens the account and displays a list of tables in the account...................... This brings up the Select Data Tables dialog box................ you can search other databases........ Oracle Forms Developer: Build Internet Applications I G-19 . 3 Select the name of the account in the list and then click Open..... or simply doubleclick the account name.Including Additional Tables ........... You can also use this dialog box to show only certain types of datasources as well as datasources in other accounts and databases....................... Including Additional Tables Often.......... all of the data needed to create a desired report cannot be found in a single table.. 2 Select databases............................................ ... 2 Select the current database name.......... 1 Open the pop-up menu to display the name of the current database and the option databases............ Remember that you can see the names of all the tables in your account by choosing the Select Data Tables tool.. 4 Follow the normal procedure for including tables in the Query window........ you can search other accounts......... 3 Select the name of the database in the list and then click Open. The list box displays a list of databases you can access.................... 1 Open the pop-up menu to display the name of the current database and the option databases.......................... The list box displays a list of accounts that contain tables you can access.... With Query Builder.......

................................................................................... Viewing Comments Copyright  Oracle Corporation......................... ............Appendix G: Introduction to Query Builder ...................................... G-20 Oracle Forms Developer: Build Internet Applications I .................. All rights reserved..... 2000..........................................................................................................................

This can often make it difficult to decide which objects to include in your query................... 2 Select the Get Info tool...... To open the dialog box............ How to View Comments Sometimes............................. ........................ follow these steps: 1 In the Datasource panel.......... select the table or column name..............................Including Additional Tables ....... Oracle Forms Developer: Build Internet Applications I G-21 ................... details about the kind of data stored in the database are not reflected by the table or column names........................................................ you can double-click the Comment icon in each table or column in the Datasources panel............. Query Builder features the Get Info dialog box to provide this kind of information for tables and columns............................. Alternatively........................................................

..............Appendix G: Introduction to Query Builder ................ 2000............ G-22 Oracle Forms Developer: Build Internet Applications I .............................................................................................................. Including Related Tables Copyright  Oracle Corporation........................................................................................... All rights reserved............ ................................................

. 2 Choose the Select Related Tables tool................. Query Builder enables you to search for relationships between tables and to create user-defined relationships if they do not exist.................. Note: When you select a foreign key column before selecting related tables..........Relationships ....... only the table to which the foreign key refers appears in the Select Related Tables dialog box.................................. you can activate or deactivate relationships to suit your needs................................... Relationships between the tables are identified by relationship lines........... How to Find and Include Related Tables 1 Select the table in the Datasource panel. Oracle Forms Developer: Build Internet Applications I G-23 ..... you can retrieve its columns... Once you have included the table... 4 Click Close to close the dialog box........... drawn from the primary keys in one table to the foreign keys in another................... or simply double-click the table name...... A list of tables that have relationships defined with the selected table appears........... The selected table appears in the Datasource panel............. Additionally................................... ........................ Relationships To combine data from multiple tables into one query......................... 3 Select the table name and click Include............................

............. ........................... 2000....................................................................................................................................................................... Creating a User-Defined Relationship Copyright  Oracle Corporation.................................Appendix G: Introduction to Query Builder .... G-24 Oracle Forms Developer: Build Internet Applications I ... All rights reserved........................................................

.............................. Query Builder draws a relationship line connecting the related columns............................................................. 2 Enter the foreign key (A—>) and primary key (B—>) column names.... The Set Relationship dialog box appears............................... 3 Type the complete table and column names (separate the table name from its column name with a period)........ Oracle Forms Developer: Build Internet Applications I G-25 .................... release the mouse button to anchor the relationship line........................... You are drawing a relationship line as you do so................ How to Create a Relationship (Optional Method) 1 Select the column that you want to relate (foreign key)...... Creating a User-Defined Relationship When you create a user-defined relationship............ 4 Click OK to close the dialog box................. How to Create a Relationship 1 Select the Set Table Relationship tool..........Relationships ....... .. 2 While holding down the mouse button............................. 3 Once the target column is selected............................... drag the cursor to the related column in the second table (the primary key)..

............................................... All rights reserved....................... 2000........ Unmatched Rows Copyright  Oracle Corporation..................................................................................Appendix G: Introduction to Query Builder ........................... G-26 Oracle Forms Developer: Build Internet Applications I ............................................................................... .....................................

....... An unmatched relationship icon is placed on the relationship line next to the column that returns unmatched rows.................... Retrieving Unmatched Rows Query Builder lets you choose whether to retrieve any unmatched rows when you are using a relationship in a query............... 2 Select the Set Table Relationship tool from the toolbar....... The Set Relationship dialog box appears...............................................................................................................Relationships ....................... There are three types of relationships that you can choose from: • Display records from table A not found in table B • Display records from table B not found in table A • Suppress any mismatched records (default) How to Create an Unmatched Relationship 1 Click on the relationship line that connects the tables......... An unmatched row occurs when the relationship connects tables where there are values on one side that have no corresponding values on the other side.............................................................. Oracle Forms Developer: Build Internet Applications I G-27 ........................... Both the column names and the relationship line should be selected.... ............. 3 Choose one of the three relationship option buttons.......... 4 Click OK.

... G-28 Oracle Forms Developer: Build Internet Applications I ........................................................................... Conditions Copyright  Oracle Corporation............... All rights reserved....................................... ...................................................... 2000.............................................................................................................Appendix G: Introduction to Query Builder ........

........ Selecting Rows with Conditions The Conditions Panel The Query window contains two independently scrollable panels........................................Selecting Rows with Conditions .................. Oracle Forms Developer: Build Internet Applications I G-29 .......... 2 Enter the text that describes the condition.... You enter conditions into the Condition field of the panel..... Closing and Validating the Condition Query Builder automatically validates the condition when you close the Condition field................ ......... using the appropriate tools.. Note: Character and date values must be enclosed in single quotes.. • Click in the Conditions panel outside the Condition field.... The Conditions panel is where you apply conditions..................................... How to Add Conditions to a Query 1 Activate the Conditions field.... The Toolbar The logical operators and the Accept and Cancel tools in the toolbar are active whenever the Condition field is active...... the Conditions panel and the Datasource panel.. • Select Accept from the toolbar. 3 Close and validate the condition........................... The Datasource panel is where you include tables and columns.......................... You can insert an operator from the toolbar into the condition by clicking it.................. Note: If a column is used in a condition but it is not displayed in the results window....... Type the conditions directly into the Condition field..... Or Select columns and functions....................... Or Click in the columns in the Datasource panel and enter the rest of the condition.......... You can close the Condition field in the following ways: • Press [Return].................. a gray check mark appears to the left of the column name in the datasource in the Query Window...................

............................. -........................................ OR.................. <................... All rights reserved........... AND Copyright  Oracle Corporation............................ / Logical • Combine conditions • Examples: AND. ............. IN.. NOT Comparison • Compare one expression with another • Examples: =.... 2000............. x................................................................... Operators Arithmetic • Perform calculations on numeric and date columns • Examples: +................ G-30 Oracle Forms Developer: Build Internet Applications I .Appendix G: Introduction to Query Builder ........................ BETWEEN .................. IS NULL......... <>...

..... In handling calculations....... IN (LIST) IS NULL Usage Equal Not equal Less than Less than or equal Greater than Greater than or equal Between two values Equal to any member of the following list Is a NULL value..... Oracle Forms Developer: Build Internet Applications I G-31 .......................................................... such that the result will either be true or false............. Query Builder first evaluates any multiplication or division... AND.................................. which performs addition.............. A row without a value in one column is said to contain a NULL value.............. ...... The browser returns all data for which the result evaluates true............. Logical Operators Logical operators are used to combine conditions. such as the + operator.. such as NOT NULL Comparison Operators Comparison operators are used to compare one expression with another......... /) operators are used to perform calculations on numeric and date columns..................... and then evaluates any addition or subtraction....................... Operators An operator is a character or reserved word that is used to perform some operation in Query Builder........................ They include: • AND: Causes the browser to retrieve only data that meets all conditions • OR: Causes the browser to retrieve all data that meets at least one of the conditions • NOT: Used to make a negative condition....... Arithmetic Operators Arithmetic (+.. x...... Operator = <> < <= > >= BETWEEN.................... Query Builder uses several types of operators............... -...............Operators .......

........................................................ All rights reserved....................................... ...................................... Multiple Conditions Copyright  Oracle Corporation.....................................................Appendix G: Introduction to Query Builder ... G-32 Oracle Forms Developer: Build Internet Applications I ................................... 2000...............................................................................

........ These are referred to as nested conditions.............. Multiple conditions are always combined using logical operators........... To nest two or more conditions: 1 Build each condition to be included in the nest...... Each time you add a condition...................... a new blank Condition field is created................... 2 While holding down the [Shift] key............. Query Builder draws a box around the highlighted conditions in the Conditions panel and combines them with the operator that you specified......... To change the logical operator: 1 Select the logical operator in the Conditions panel...... ................... Oracle Forms Developer: Build Internet Applications I G-33 .................. 3 Select the logical operator to combine the conditions—either AND or OR.Entering Multiple Conditions ...................................... 3 Press [Return] to close and validate the condition.... Entering Multiple Conditions There is no limit to the number of conditions you can include in a browser query........... 1 Click in the empty Condition field to activate it... You can add conditions to any query either before or after execution. How to Add Conditions The Conditions panel always displays a blank Condition field at the bottom of the list of conditions. Note: Pressing [Shift]-[Return] following the entry of each condition is the fastest way to create multiple conditions.......... click in the box to the left of each condition to be nested......... How to Change Logical Operators By default............................................ because it moves the cursor and prompt down one line so that you can enter another condition... Query Builder combines multiple conditions with the AND operator... Use this field to enter multiple conditions......... 2 Enter the new condition........ 2 Click a new operator on the toolbar or select one from the Data menu................................ How to Create Nested Conditions Query Builder enables you to combine logical operators to produce complex queries made up of multiple levels of conditions.

................... ................................. All rights reserved................................... Deactivating a Condition Copyright  Oracle Corporation.................................................................................................................................................................Appendix G: Introduction to Query Builder ..... G-34 Oracle Forms Developer: Build Internet Applications I ..................... 2000.............................

............... 2 Select Clear from the toolbar or select Delete.........Changing Conditions ....... .. deactivate.... or edit any of them in the Conditions panel............... Double-clicking the box to the left of the condition or its operator acts as a toggle switch.................... alternately turning the condition on and off...................... you can delete......................................................... Changing Conditions If you change your mind about including one or more conditions in your query.................................................... Additionally.. Oracle Forms Developer: Build Internet Applications I G-35 ................... 2 Double-click in the box to deactivate the condition................................... Deactivated conditions remain in the Condition field but appear dimmed.. Note: Hold down the [Shift] key to select multiple conditions.................. you can turn conditions on and off by using the Data menu: 1 Select the box to the left of the condition or its operator... How to Deactivate a Condition Query Builder enables you to temporarily deactivate a condition so that you can test different scenarios without having to re-create the conditions each time.......... The condition is removed from the query............... How to Delete a Condition 1 Click inside the Condition field to activate it........

... G-36 Oracle Forms Developer: Build Internet Applications I ......................................................... 2000.......................................................................................... ....... Defining Columns Using an Expression Copyright  Oracle Corporation........................................................Appendix G: Introduction to Query Builder ........................................................................................ All rights reserved..

........Defining Columns Using an Expression ......................................................... which displays a list of all columns currently defined in the query (if any)........... How to Display and Hide Defined Columns You display or hide defined columns from a query in exactly the same manner as you do ordinary columns. 6 Click OK to close the dialog box. The new column is added to the list of defined columns in the dialog box and appears in the Datasource panel.............. 3 Click in the Defined Column field to activate it. – Select the column from the displayed list...... 5 Select Define................................. Defining Columns Using an Expression Besides retrieving columns of data stored in a table......... The Defined Column dialog box appears............. Oracle Forms Developer: Build Internet Applications I G-37 ..... How to Enter Expressions You can enter information in the Defined As field in the following ways: • Type the expression in directly........... not in the database. it exists only in your query.. 1 Select the table where you want to define a new column.... The Paste Column dialog box appears................... – Click OK to paste the column into your expression and return to the Define Column dialog box.... Query Builder enables you to define new columns that are derived or calculated from the values in another column............................................ and then enter the name for your new column....... How to Define a Column When you define a column................................................ ...... 2 Select the Define Column tool......... 4 Move your cursor to the Defined As field and enter the formula or expression that defines your column. • Select Paste Column......

........... G-38 Oracle Forms Developer: Build Internet Applications I ...... 2000............................................................................................................. All rights reserved....................................................................................................................................... Defining Columns Using a Function Copyright  Oracle Corporation.................................Appendix G: Introduction to Query Builder .. .......

TRUNC() Aggregate Functions • Return a single row based on the input of multiple rows of data • Examples: AVG().............. 4 Select the function from the displayed list..... Functions usually include at least one argument................... Note: If this check box is selected............................. ................... SUBSTR().......... or select Paste Function to select from a list..... a description or datatype name of the arguments appropriate for the function is pasted into your expression............ You then replace the description with the actual arguments............................ 2 Select Paste Function............. COUNT(). You can type a function directly in the Defined As field of the Define Columns dialog box.... Oracle Forms Developer: Build Internet Applications I G-39 . SUM() How to Select a Function 1 Click in the Defined As field to activate it................. Defining Columns Using a Function The browser also enables you to define columns using a variety of built-in functions provided by the Oracle Server........................ 6 Click OK to paste the function into your expression and return to the Define Columns dialog box........... Single-Row Functions • Return one value for every data row operated on • Examples: INITCAP().... What Is a Function? A function is similar to an operator in that it performs a calculation and returns a result...... most commonly the name of the column on which the operation will be performed..............Defining Columns Using a Function ......... 3 Select or deselect the Show Categories check boxes to view the desired list of functions......... Functions consist of a function name followed by parentheses..................................... An argument is an expression that supplies information for the function to use.................... 5 Select the Paste Arguments check box (optional)....... The Paste Function dialog box appears. in which you indicate the arguments....

......................................Appendix G: Introduction to Query Builder ...................................................................................................................................................................... ............................................................. G-40 Oracle Forms Developer: Build Internet Applications I ...................................

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.