Академический Документы
Профессиональный Документы
Культура Документы
.......................................................................................
nly
e O
Us
AI
& O
al
ern
Int
40034GC11
cle
Production 1.1
ra
June 2001
OD33130
Author Copyright Oracle Corporation, 2001. All rights reserved.
Pam Gamer If this documentation is delivered to a U.S. Government Agency not within the
Department of Defense, then it is delivered with “Restricted Rights,” as defined in
Pascal Gibert
FAR 52.227-14, Rights in Data-General, including Alternate III (June 1987).
Thierry Guibert
The information in this document is subject to change without notice. If you find
Ellen Gravina any problems in the documentation, please report them in writing to Education
Norris Gray Products, Oracle Corporation, 500 Oracle Parkway, Box 659806, Redwood
Anthony Hargreaves Shores, CA 94065. Oracle Corporation does not warrant that this document is
error-free.
Ali Hiemstra
Oracle Developer, Oracle Server, and PL/SQL are trademarks or registered
Barry Hiern
trademarks of Oracle Corporation.
Ursula Hovy
All other products or company names are used for identification purposes only,
Sarah Jones and may be trademarks of their respective owners.
Jan Keuben
Aija Lehtonen
Regis Louis
Kenji Makita
nly
O
Jayne Marlow
e
Sergei Pechersky
Milos Randak
Us
I
Jonas Reborg
Bryan Roberts
Candace Stover
OA
Hiroyuki Sugiyama
l &
Laura Tejero
Jack Walsh
rna
nte
e I
cl
Publisher
ra
Shane Mattimoe
O
Contents
.....................................................................................................................................................
Contents
Preface
Profile xv
Related Publications xvi
Typographic Conventions xvii
Introduction
Introduction I-2
Course Content I-3
ly
Implementing Menu Toolbars 1-23
Storing the Menu Module 1-25
On
Attaching the Menu Module 1-27
se
U
Pop-up Menus 1-29
Summary 1-31
AI
Practice Overview: Lesson 1 1-33
& O
l
Practice 1 1-34
rna
Lesson 2: Managing Menu Modules
te
Introduction 2-3
n
e I
Using PL/SQL in Menu Item Code 2-5
ra
O
.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II iii
Contents
.....................................................................................................................................................
e O
s
Responding to Mouse Button Actions 4-11
Summary 4-15
I U
Practice Overview: Lesson 4 4-17
Practice 4 4-18
OA
l &
rna
Lesson 5: Controlling Windows and Canvases Programmatically
e
Introduction 5-3
Int
Using Window-Interaction Triggers 5-5
le
Built-ins for Manipulating Windows 5-7
c
a
Built-ins for Manipulating Canvases 5-9
Or
.....................................................................................................................................................
iv Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................
ly
of Records 6-17
Data Block Wizard 6-19
Data Block Properties 6-21
On
Data Source Guidelines 6-23
se
Summary 6-27
I U
Practice Overview: Lesson 6 6-29
OA
&
Practice 6 6-30
al
ern
Lesson 7: Working with Oracle8i Objects in Form Builder
t
Introduction 7-3
In
What Are Object Types? 7-5
cle
Review of Objects 7-7
.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II v
Contents
.....................................................................................................................................................
ly
Implementing a Coordination-Type Toggle 8-17
Forcing a Commit Per Master 8-19
On
e
Summary 8-21
Practice Overview: Lesson 8 8-23
Us
Practice 8 8-24
AI
Lesson 9: Building Multiple Form Applications
& O
l
Introduction 9-3
a
rn
OPEN_FORM to Invoke Additional Forms 9-5
e
Int
Closing Forms 9-7
Navigating Between Forms 9-9
cle
Transaction Processing for Opened Forms 9-11
ra
CALL_FORM to Invoke Additional Forms 9-13
.....................................................................................................................................................
vi Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................
ly
Manipulating Selected Record Group Rows 10-23
Defining Global Record Groups 10-25
On
e
Manipulating List Items Programmatically 10-27
Implementing Dynamic List Items 10-29
Us
Adding Values to Combo Boxes 10-31
AI
Summary 10-33
Practice Overview: Lesson 10 10-35
& O
al
Practice 10 10-36
ern
Int
Lesson 11: Using Reusable Components
Introduction 11-3
cle
Reusable Components 11-5
.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II vii
Contents
.....................................................................................................................................................
ly
The Java Importer Tool 12-31
Summary 12-33
On
e
Practice Overview: Lesson 12 12-35
Practice 12 12-36
Us
Lesson 13: Using Server Features in Form Builder
AI
Introduction 13-3
& O
l
Using Oracle Database Server Functionality in Forms 13-5
a
rn
Dealing with PL/SQL Code 13-7
e
Int
PL/SQL8 Support 13-9
PL/SQL8 Scalar Data Types 13-11
cle
Unsupported Oracle Forms Developer PL/SQL8 Features 13-13
ra
Handling Errors Raised by the Oracle Database Server 13-15
.....................................................................................................................................................
viii Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................
e O
s
Summary 15-23
Practice Overview: Lesson 15 15-25
I U
Practice 15 15-26
OA
Appendix A: Practice Solutions
l &
na
Practice 1 Solutions A-2
r
e
Practice 2 Solutions A-6
Int
Practice 3 Solutions A-9
cle
Practice 4 Solutions A-11
a
Practice 5 Solutions A-12
Or
.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II ix
Contents
.....................................................................................................................................................
ly
S_PRODUCT Description B-17
S_PRODUCT Data B-18
On
e
S_REGION Description and Data B-22
S_TITLE Description and Data B-23
Us
Oracle8i Objects: Types, Tables B-24
AI
Appendix C: Mouse Movement Events
& O
l
Introduction C-2
a
rn
Drag and Drop C-4
e
Int
Summary C-6
le
Appendix D: Introduction to Oracle8i Object Features
c
a
Introduction D-3
Or
.....................................................................................................................................................
x Oracle iDS Forms: Build Internet Applications II
Contents
.....................................................................................................................................................
e O
Appendix G: EMP_PKG Package
Us
Package Specification G-2
AI
Package Body G-4
& O
al
Appendix H: Working with ActiveX Controls
rn
Introduction H-3
e
Int
What Are VBX, OCX, and ActiveX Controls? H-5
Comparison of VBX, OCX, and ActiveX Controls H-7
cle
ActiveX in Form Builder H-9
.....................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II xi
Contents
.....................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
.....................................................................................................................................................
xii Oracle iDS Forms: Build Internet Applications II
................................
Using Reusable
Components
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Lesson 11: Using Reusable Components
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn about the reusable components that are
available with Oracle Forms Developer. You will learn how these
components can fit into any application.
Objectives
After completing this lesson, you should be able to do the following:
• List the reusable components
• Include the calendar object in an application
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-3
Lesson 11: Using Reusable Components
......................................................................................................................................................
Reusable Components
Picklist
Calendar
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-4 Oracle iDS Forms: Build Internet Applications II
Reusable Components
......................................................................................................................................................
Reusable Components
Oracle Forms Developer contains a complete set of demonstrations that
illustrate the power and productivity of the product. These demonstrations
contain many tips and techniques that you can copy and use in your own
applications.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-5
Lesson 11: Using Reusable Components
......................................................................................................................................................
• ActiveX controls
• Java Beans
• Sample Icons
• Standard Menus
• PL/SQL Drag & Drop Library
• PL/SQL Utilities Library
• PL/SQL Conversion Library
• PL/SQL Window System Interface Library
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-6 Oracle iDS Forms: Build Internet Applications II
Reusable Components List
......................................................................................................................................................
ly
PL/SQL Conversion library This PL/SQL library contains procedures to perform
n
complex conversions.
PL/SQL Window system
O
This PL/SQL library contains many commonly used routines
e
s
interface library specific to the Windows environment. The utility consists of
U
a PL/SQL library and a Windows dynamic-link library
I
A
(DLL) and can be used with either Form Builder or Report
O
Builder.
&
The PL/SQL library uses the ORA_FFI package and can be
al used as a model for creating your own DLL calls. The utility
t
interface to DLLs.
In
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-7
Lesson 11: Using Reusable Components
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-8 Oracle iDS Forms: Build Internet Applications II
Reusable Components List
......................................................................................................................................................
ly
have also been designed for maximum portability.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-9
Lesson 11: Using Reusable Components
......................................................................................................................................................
Creating a Calendar
To create a calendar:
1. Copy or make the Calendar Object
Group a subclass.
2. Attach the PL/SQL library
nly
O
CALENDAR.PLL.
3. Create a Key-Listval trigger.
se
U
4. Call Date_LOV.Get_Date.
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
11-10 Oracle iDS Forms: Build Internet Applications II
The Calendar Class
......................................................................................................................................................
Creating a Calendar
To create a calendar, follow the steps below:
1 Open the stndrd20.olb object library. From the Components page,
copy or subclass the Calendar object group.
2 Attach the PL/SQL library calendar.pll, which contains the
Date_LOV package, to your module.
3 Create a Key-Listval trigger on the date item for which you would like to
use the Date List of Values window. Add code to display the calendar
using the Date_LOV package.
4 If you want the end user to be able to close the Date List of Values
window by clicking the WindowClose button in the title bar, create a
form-level When-Window-Closed trigger.
The calendar appears whenever the end user invokes a list of values for the
date item. A single calendar can be reused on many different date items.
Simply create a Key-Listval trigger for each item.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-11
Lesson 11: Using Reusable Components
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-12 Oracle iDS Forms: Build Internet Applications II
Calendar Object Group Content
......................................................................................................................................................
The Blocks
The calendar object contains two blocks:
• Date_Control_Block: This block contains the buttons that control which
month and year is displayed.
• Date_Button_Block: This block contains the buttons that represent each
day of the month.
The Canvas
The calendar class contains a content canvas named Date_Lov_Canvas. This
canvas contains all the items from both blocks.
The Window
The calendar class contains a window named Date_Lov_Window. This
window is used to display the Date_Lov_Canvas.
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-13
Lesson 11: Using Reusable Components
......................................................................................................................................................
• Example
date_lov.get_date(sysdate,’s_ord.date_ordered’,240
date_lov.get_date(sysdate,’s_ord.date_ordered’,240
,60,’Order
,60,’Order Date’,’OK’,’Cancel’,TRUE,FALSE,FALSE);
Date’,’OK’,’Cancel’,TRUE,FALSE,FALSE);
®
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-14 Oracle iDS Forms: Build Internet Applications II
Built-in for Manipulating the Calendar
......................................................................................................................................................
Date_LOV.Get_Date Procedure
This procedure displays the calendar with the month and year specified in
the Display_Date argument. The day of the month is displayed with bold
numbers. The date chosen by the end user is returned to the item specified
by the Return_Item argument.
. . .
PROCEDURE Date_LOV.Get_Date(
display_date DATE, return_item VARCHAR2,
v_x_pos NUMBER := 0, v_y_pos NUMBER := 0,
v_title VARCHAR2 := ’Date List of Values’,
v_ok VARCHAR2 := ’OK’,
v_cancel VARCHAR2 := ’Cancel’, v_highlight BOOLEAN := TRUE,
v_autoconfirm BOOLEAN := TRUE, v_autoskip BOOLEAN := FALSE );. . .
Argument Description
display_date The date to display when the Date List of Values window first
appears
return_item The name of the block and item to which to return the chosen date
v_x_pos Specifies the X coordinate of the Date List of Values window
v_y_pos
nly
Specifies the Y coordinate of the Date List of Values window
v_title
e O
Title to display in the Date List of Values window
v_ok Label for the OK button
Us
v_cancel Label for the Cancel button
AI
v_highlight
& O
Specifies that weekend days appear in a different color
al
v_autoconfirm Specifies that the date immediately be returned when the end user
t
v_autoskip
In
Specifies that the input focus moves to the next item in sequence
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-15
Lesson 11: Using Reusable Components
......................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-16 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
Reusable Components
• The purpose of a reusable component
• Reusable components list
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-17
Lesson 11: Using Reusable Components
......................................................................................................................................................
Practice 11 Overview
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-18 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 11
......................................................................................................................................................
Practice Contents
• Create a picklist to display and select the products available.
• Add a calendar on the S_ORD.DATE_ORDERED and
S_ORD.DATE_SHIPPED items.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-19
Lesson 11: Using Reusable Components
......................................................................................................................................................
Practice 11
1 Create a picklist by using the picklist class. This picklist enables the end
user to select order items from a product list, and to place selections in a
second list.
a Create a new form module, called PICKXX where XX is your student
course number. Open the Form_Builder_II.olb object
library. This library contains form objects and code for the picklist.
Copy the PICKLIST_BASIC object group to your form module.
Copy the PICKLIST object group into your new form module.
b Ensure the CONTROL block is the last defined data block in the
Object Navigator.
c Attach the picklist.pll library. This contains the functions
and procedures required for creating the picklist.
d Define a When-New-Form-Instance trigger which will create and
populate the picklist. You can import the code from the
pr11_1.txt file.
Create the picklist with the picklist.Create_Picklist procedure.
Call function pick_list.Populate_Picklist_With_Query to populate
the List_in object. You must define a query that returns the ID, name
and suggested prices from the S_PRODUCT table.
Call pick_list.Set_Picklist_Selection procedure to select the first
element in the list.
Display both lists by using the pick_list.Display_Picklist procedure.
Exclude from the query any products already in the current S_ITEM
block. You should use the global variable :GLOBAL.where_cls.
nly
e Save and compile your form. Deploy your form to the Web.
e O
f In your ORDERS form, modify the When-Button-Pressed trigger for
Us
the CONTROL.PRODUCT_LOV_BUTTON so that it calls your
new form module.
AI
g Save and compile your form. Deploy your form to the Web to test.
& O
al
ern
t
If you have time
In
2 In the ORDERS form, add a calendar on the S_ORD.DATE_ORDERED
le
item and S_ORD.DATE_SHIPPED item.
c
a
a From the calendar page of the Form_Builder_II.olb object
r
O
library, copy the calendar object group.
......................................................................................................................................................
11-20 Oracle iDS Forms: Build Internet Applications II
Practice 11
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 11-21
Lesson 11: Using Reusable Components
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
11-22 Oracle iDS Forms: Build Internet Applications II
................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson you will learn how to enhance Web-deployed forms by using
JavaBeans to customize the user interface. You will also learn about
Oracle8i features that may be used within Web-deployed Oracle forms.
Objectives
After completing this lesson, you should be able to do the following:
• Customize the user interface
• Incorporate JavaBeans in Web-deployed forms by
- Inserting Pluggable Java Components
- Creating Bean Areas
• Exploit Oracle8i features with Web-deployed forms
• Invoke the Java Importer Tool
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-3
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-4 Oracle iDS Forms: Build Internet Applications II
Java and Oracle Forms Developer
......................................................................................................................................................
Forms Applet
The Forms Applet is a Java code component embedded in the base HTML
file. It is responsible for downloading and executing the Java class files that
create the Oracle Forms Developer user interface.
JavaBeans
JavaBeans are portable, reusable and platform independent Java programs.
You can change the appearance and behavior of the Forms user interface by
ly
including JavaBeans in your Oracle Form Builder applications.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-5
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Oracle Look
and Feel
Bean
Areas
Pluggable Java
Components
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-6 Oracle iDS Forms: Build Internet Applications II
Java in Web-Deployed Forms
......................................................................................................................................................
JavaBeans
You can add JavaBeans to extend existing Oracle Form Developer
components using Pluggable Java Components. With Bean Areas you can
insert JavaBeans that provide new application functionality, and may also be
used to execute code on the user interface.
Bean Areas
You can insert new functionality, such as slider controls or progress bars, by
ly
defining a Bean Area Item in your form module. With supplied triggers and
n
PL/SQL built-ins, you can communicate between the Form Server and the
O
client JavaBean.
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-7
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
ly
<EMBED type="application/x-jinit-applet"
n
java_CODE="oracle.forms.engine.Main"
java_CODEBASE="/web_frms/"
O
java_ARCHIVE="f60all.jar"
e
WIDTH=750 HEIGHT=400
s
serverPort="5555"
serverArgs="module=emp userid=scott/tiger@mydatabase"
U
serverApp="/web_html/summit"
I
pluginspage="http://machine/jinit_download.htm"
A
splashScreen="/web_img/summitlo.gif"
O
lookAndfeel="Oracle"
colorScheme="teal">
&
</EMBED>
l
</BODY></HTML>
nte
e I
cl
ra
O
......................................................................................................................................................
12-8 Oracle iDS Forms: Build Internet Applications II
The Forms Applet
......................................................................................................................................................
Technical Note
ly
To enable the Web Previewer, you must have installed the Forms Server
Runtime Engine in your test environment.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-9
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Defining Fonts
for Web-Deployed Forms
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-10 Oracle iDS Forms: Build Internet Applications II
Defining Fonts for Web-Deployed Forms
......................................................................................................................................................
At run time, Oracle Form Developer fonts are converted to their Java
equivalent using a reference to an alias file, Registry.dat. If your
selected Oracle Form Builder font does not map to a supported Java font, it
will be replaced with the default Java font. You can specify the default Java
font by editing the Java registry file. The Registry.dat file is located
in:
ORACLE_HOME/forms60/java/oracle/forms/registry/
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-11
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
e O
Check box List Item Push Button
Us
Text Item Radio Button
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
12-12 Oracle iDS Forms: Build Internet Applications II
Pluggable Java Components
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-13
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Text Items:
Checkboxes:
Y N
Smoking ?
Radio Buttons
Cash
Credit Card
Cheque
ly
in the ‘Implementation Class’ property:
On
se
I U
– Name: PasswordFieldPJC.class
– Path :
OA
l
FORMS60_JAVADIR oracle\forms\demos
&
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
12-14 Oracle iDS Forms: Build Internet Applications II
Pluggable Java Components
......................................................................................................................................................
ly
Location of PJC Class Files
You should specify the FORMS60_JAVADIR environment variable to
On
e
enable Oracle Forms Developer to locate your JavaBeans. The default path
is: ORACLE_HOME/forms60/java. It is recommended that you place
Us
I
your custom JavaBean class files within a subdirectory in this path.
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-15
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Bean Areas
ly
• Add new control
n
items and new Hello Forms!
O
functionality Someone hit the OK
e
button….
•
s
Execute Client- here’s the
U
side Java code “Date Changed” event
• Communicate
and
AI
a parameter list with
O
between Forms the selected date
Server and Client
l
with PL/SQL
&
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
12-16 Oracle iDS Forms: Build Internet Applications II
What Is a Bean Area?
......................................................................................................................................................
With PL/SQL built-ins and triggers, you can also communicate with the
JavaBean at run time.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-17
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Hosting a JavaBean
3. JavaBean is visible in
Layout Editor
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-18 Oracle iDS Forms: Build Internet Applications II
Hosting a JavaBean
......................................................................................................................................................
Hosting a JavaBean
You can host a JavaBean in your Oracle Forms Developer application by
creating a Bean area control item.
ly
After you have specified the Implementation class property, the JavaBean
will be visible in the Bean Area (in the Layout Editor).
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-19
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
• When-Custom-Item-Event trigger
• System variables:
– :SYSTEM.CUSTOM_ITEM_EVENT
– :SYSTEM.CUSTOM_ITEM_EVENT_PARAMETERS
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-20 Oracle iDS Forms: Build Internet Applications II
How a JavaBean Communicates
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-21
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
SET_CUSTOM_PROPERTY built-in
Example:
Declare
EventName varchar2(20) := :system.custom_item_event;
EventValues ParamList;
EventvalueType number;
TempString varchar2(4000);
Begin
If EventName = ‘ALARMFIRED’ then
EventValues := get_parameter_list(:system.custom_event_parameters);
get_parameter_attr(EventValues, ALARMTIME’, EventvalueType,
TempString);
If Summit_Show_Alert(‘Alarm Call:’||TempString) =
alert_button1 then
set_custom_property(‘jAlarmClock’, 1, ‘wakeuptime’, 1000);
end if;
end if;
End;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-22 Oracle iDS Forms: Build Internet Applications II
Communicating with the JavaBean
......................................................................................................................................................
Example
SET_CUSTOM_PROPERTY(’alarm_clock’,1, ’wakeuptime’, 1000);
In the following example the When-Custom-Item-Event trigger examines
the system variables to identify the contents of a parameter list sent by the
JavaBean. The JavaBean has sent date and time information to the form,
which is then displayed to the user using an alert.
Declare
EventName varchar2(20) := :system.custom_item_event;
EventValues ParamList;
Eventvalue Typenumber;
TempString varchar2(4000);
Begin
If EventName = ‘ALARMFIRED' then
EventValues := get_parameter_list(
:system.custom_event_parameters);
get_parameter_attr(EventValues, 'ALARMTIME',
ly
EventvalueType, TempString);
If Summit_Show_Alert(‘Alarm Call: '||TempString) =
On
e
alert_button1 then
set_custom_property(‘AlarmClock',
Us
1,‘wakeuptime', 1000);
AI
O
end if;
&
end if;
End;
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-23
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-24 Oracle iDS Forms: Build Internet Applications II
Exploiting Oracle8i Features
......................................................................................................................................................
Enterprise JavaBeans
Unlike JavaBeans, Enterprise JavaBeans (EJB) do not perform user
interface functions. EJB encapsulate and distribute Java backend logic
across many servers in order to manage data, transaction security, and
resources.
nly
O
Developing Server Side Java
You can develop Java stored procedures, EJB, and BC4J by using Oracle
se
U
JDeveloper. You will require knowledge in Java programming.
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-25
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-26 Oracle iDS Forms: Build Internet Applications II
How to Create JavaBeans
......................................................................................................................................................
nly
Technical Note
e O
You should only deploy light-weight JavaBeans with your Web-deployed
Us
I
forms applications; the light-weight JavaBean user interface (UI)
components are rendered completely and can be used independently of any
operating system. In contrast, heavy-weight JavaBeans rely on UI objects
OA
&
provided by the client operating system. Oracle Forms Developer uses light-
l
rna
weight JavaBeans to provide a common look and feel across different
operating systems.
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-27
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-28 Oracle iDS Forms: Build Internet Applications II
The Java Importer
......................................................................................................................................................
ly
are:
• Java Importer Tool, which allows you to select and specify which Java
classes you want to access in your application.
On
• Java Importer Generator, which creates PL/SQL packages that provide
se
access to the specified Java class.
I U
• ORA_JAVA package, which provides a set of functions to assist you in
working with the selected Java packages.
OA
l
• Oracle Forms Services Java Native Interface (JNI) Bridge, which
&
na
handles low level interaction with the Java classes at runtime.
r
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-29
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
nly
2
e O
Us
3
AI
4 5
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
12-30 Oracle iDS Forms: Build Internet Applications II
The Java Importer Tool
......................................................................................................................................................
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-31
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-32 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
Customize the User Interface
• Specifying Oracle look and feel
• Specifying default Java fonts
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-33
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Practice 12 Overview
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
12-34 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 12
......................................................................................................................................................
Practice Contents
• Provide an alternative UI for text items by including PJC
- Change the mouse cursor style
- Display secure data as ‘asterisks’.
• Add a Java Bean to allow users to specify hyperlinks of their choice.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 12-35
Lesson 12: Using Java with Web-Deployed Forms
......................................................................................................................................................
Practice 12
1 Provide an alternative user interface for your Web-deployed forms by
including Pluggable Java Components (PJCs).
a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb,
where XX is your student course code.
b Change the :EMP.SAL item so that values are displayed as asterisks
at run time. Use the PJC ‘PasswordFieldPJC.class’.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
c Change the :EMP.ENAME item so that the mouse cursor changes to
‘hand’ style whenever the cursor is moved over the item. Use the
PJC ‘ModCursor.class’.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
d Use the built-in SET_CUSTOM_PROPERTY in an appropriate
trigger, to specify the cursor style:
SET_CUSTOM_PROPERTY(’Emp.Ename’,1,
’DOCURSOR’,’HAND’);
e Save and compile your form. Deploy your form to the Web to test.
ly
b Create a Bean Area called ‘HYPERLINK1’ in the new data block
and specify the class file ‘HyperLinkWrapper.class’.
On
e
c Create an appropriate trigger to identify the user-supplied URL from
the JavaBean, and to download his or her Web page. You can import
Us
I
the code from the pr12_1.txt file.
d Create two text items, one called ‘URL’ to accept a URL and one
called ‘LABEL’ to accept a URL label. These will enable the user to
OA
l
select a different URL. Set the maximum length for the URL text
&
rna
item to 255.
e
e Create a push button with an appropriate trigger that will accept
nt
values from the URL and LABEL text items, and pass them to the
I
JavaBean. You can import the code from the pr12_2.txt file.
cle
f Save and compile your form. Deploy your form to the Web to test.
ra
O
......................................................................................................................................................
12-36 Oracle iDS Forms: Build Internet Applications II
................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson covers the use of Oracle database server features in Form
Builder applications. You will learn about storing and calling PL/SQL code,
handling Oracle database server errors, and issuing DDL commands from
within forms.
Objectives
After completing this lesson, you should be able to do the following:
• Use Oracle database server functionalities in forms
• Deal with server-side PL/SQL
• Recognize which PL/SQL8 features are supported in forms
• Handle Oracle database server errors
• Perform DDL commands by using the FORMS _DDL built-in
subprograms
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-3
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-4 Oracle iDS Forms: Build Internet Applications II
Using Oracle Database Server Functionality in Forms
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-5
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-6 Oracle iDS Forms: Build Internet Applications II
Dealing with PL/SQL Code
......................................................................................................................................................
ly
Application Partitioning
For enhanced performance, you may want to call or store PL/SQL code on
either the Oracle database server or the Oracle Form Builder application.
On
In Form Builder you can drag and drop PL/SQL program units between the
se
Oracle database server and the application. This is called application
I U
A
partitioning. With Web-deployed forms it is also possible to place code on
the client by using JavaBeans. In this way, you can optimally divide
application code over the available resources.
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-7
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-8 Oracle iDS Forms: Build Internet Applications II
PL/SQL8 Support
......................................................................................................................................................
PL/SQL8 Support
Oracle Forms Developer uses PL/SQL8 in the Oracle database server and
the Oracle Form Builder application. However, Form Builder module
program units currently cannot support Oracle8i object-related functionality.
The Stored Program Unit editor has been extended in Oracle Forms
Developer to allow editing of the type body (methods) and type
specification (attributes) of Oracle8i user-defined data types.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-9
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-10 Oracle iDS Forms: Build Internet Applications II
PL/SQL8 Scalar Data Types
......................................................................................................................................................
ly
code, PL/SQL8 now supports a second character set called the national
n
character set, which is used for NLS data. The PL/SQL data types NCHAR
and NVARCHAR2 allow you to store character strings formed from the
e O
s
national character set.
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-11
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Unsupported Client-Side
PL/SQL8 Features
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-12 Oracle iDS Forms: Build Internet Applications II
Unsupported Oracle Forms Developer PL/SQL8 Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-13
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Database
Trigger/PU
trigger
Explicit DML
Stored
Stored PU call program unit
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-14 Oracle iDS Forms: Build Internet Applications II
Handling Errors Raised by the Oracle Database Server
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-15
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-16 Oracle iDS Forms: Build Internet Applications II
Handling Errors Raised by the Oracle Database Server
......................................................................................................................................................
Technical Note
The values of DBMS_ERROR_CODE and DBMS_ERROR_TEXT are the
same as what a user would see after selecting [Display Error]; the values are
not automatically reset following successful execution.
Appendix F “Handling Server-Side Errors” covers server-side error
handling in more detail.
& O
al
FRM-Error Messages with Web-Deployed Forms
rn
A generic FRM-999999 is the most common error displayed with Web
e
t
forms. You can obtain meaningful information from the JInitiator Control
In
Panel, or from the DOS window if you run the form from a Java
le
Appletviewer. For further information see Oracle 9iAS Forms Services:
c
a
Deploy Internet Applications.
Or
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-17
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
• Characteristics:
– Statement cannot return results directly
– Use FORM_SUCCESS to check
•
success of statement
nly
O
Hints:
– Create SQL Query record group
instead of FORMS_DDL
se
– Call stored program unit instead of
I U
FORMS_DDL
OA
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
13-18 Oracle iDS Forms: Build Internet Applications II
Performing DDL with FORMS_DDL
......................................................................................................................................................
Syntax
FORMS_DDL(statement);
Description
FORMS_DDL issues dynamic SQL statements at run time, including
server-side PL/SQL and DDL.
Parameter
The specified statement can be any string expression up to 32K
representing a:
• PL/SQL block
• DML statement
• DDL statement
Do not end the PL/SQL block with a slash or the DML or DDL statement
with a semicolon.
Characteristics
FORMS_DDL is an unrestricted procedure that is also valid in Enter Query
mode.
• The specified statement must not contain bind-variable references.
nly
O
However, you can concatenate the values of bind variables into the
e
specified string.
• The statement executed using FORMS_DDL cannot return results to
Us
Forms directly.
AI
O
• Use the FORM_SUCCESS built-in to check whether the statement
&
issued using FORMS_DDL executed correctly.
al
Note: Consider using a query record group with a SELECT statement or
rn
calling a stored program unit, instead of executing FORMS_DDL.
e
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-19
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-20 Oracle iDS Forms: Build Internet Applications II
Using FORMS_DDL
......................................................................................................................................................
Using FORMS_DDL
The following examples show how you can use the FORMS_DDL built-in
function.
Example
Create a temporary table at the start of a post.
Pre-commit trigger at form level:
BEGIN
FORMS_DDL(’CREATE table temp(n_col number)’);
IF not FORM_SUCCESS THEN
MESSAGE (’Table creation failed.’);
RAISE form_trigger_failure;
END IF;
END;
Example
Execute a procedure with a given name. This is useful if you want to determine
dynamically which procedure should be executed in a certain situation.
PROCEDURE exec_proc (p_proc_name IN VARCHAR2)
IS
BEGIN
FORMS_DDL(’BEGIN ’|| p_proc_name ||’; END;’);
IF not FORMS_SUCCESS THEN
handle_server_error(DBMS_ERROR_CODE,DBMS_ERROR_TEXT);
END IF;
END;
Note: If the FORMS_DDL built-in fails, Forms sets the DBMS_ERROR_CODE
nly
O
and DBMS_ERROR_TEXT built-ins. Therefore, you can handle Oracle server
e
errors using the HANDLE_SERVER_ERROR procedure discussed earlier.
Always test the SYSTEM.FORM_STATUS before calling the FORMS_DDL
Us
built-in.
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-21
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-22 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
Oracle Database Server Features Useful for Form Builder
• Declarative integrity constraints
• Stored program units
• Database triggers
• DDL
ly
• Trap explicit DML errors and stored program unit errors by using
n
SQLCODE and SQLERRM in a WHEN OTHERS exception handler
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-23
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Practice 13 Overview
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
13-24 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 13
......................................................................................................................................................
Practice Contents
• Handle errors caused by stored program units.
• Handle errors caused by declarative-constraint violations.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 13-25
Lesson 13: Using Server Features in Form Builder
......................................................................................................................................................
Practice 13
1 Create a stored procedure, and process error messages that it may
generate in the CUSTSERVER form.
a Open the CUSTSERVER form and save as CUSTSERVXX where
XX is your student course number. Copy the code in the
SELECT_CODE program unit and create a stored procedure called
SELECT_CUSTOMER. This procedure takes a user supplied value
from :CONTROL.NAME to check whether a customer name already
exists. Existing names will generate an error.
b Modify the When-Button-Pressed trigger for the CONTROL block
CHECK_CUSTOMER button, to trap any errors generated from the
stored procedure SELECT_CUSTOMER. If a customer already
exists, display a warning message to the user.
c Save and compile your form module; test.
ly
c Display all messages in an ALERT called ‘errors’.
d Save and compile your form module; test your form.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
13-26 Oracle iDS Forms: Build Internet Applications II
................................
Applying Timers
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Lesson 14: Applying Timers
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson covers time-initiated processing; that is, processing that occurs
after a certain amount of time has elapsed. The mechanism you use to do this
is called a timer and it is created, modified, and deleted at run time.
Objectives
After completing this lesson, you should be able to do the following:
• Describe timers
• Create a timer
• Modify a timer
• Delete a timer
• Handle timer expiration
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-3
Lesson 14: Applying Timers
......................................................................................................................................................
Timers
• What is a timer?
• Built-ins for timers:
– FIND_TIMER
– CREATE_TIMER
– SET_TIMER
– DELETE_TIMER
– GET_APPLICATION_PROPERTY
(TIMER_NAME)
Timers
• When-Timer-Expired trigger
• Using timers:
– Poll database
– Periodically query, commit, or rollback
nly
– Show “About…” information at startup
e O
Us
AI
& O
al
rn
®
Technical Note
nte
e I
l
Timers are not suitable means of shutting down an application. It is the job
rac
of the operating system to recognize idle processes and shut them down.
......................................................................................................................................................
14-4 Oracle iDS Forms: Build Internet Applications II
Timers
......................................................................................................................................................
Timers
Forms typically processes events that are user initiated. You can use timers
when you want Forms to initiate actions after a specific time period time.
What Is a Timer?
A timer is a programmatic construct similar to an “internal alarm clock.”
You can create, modify, or delete timers with built-ins. When you create or
modify a timer, you can specify the time period for the timer. Using a
trigger, you can specify actions to be performed at the end of that period.
When-Timer-Expired Trigger
ly
This trigger fires when the specified time interval of the timer has elapsed.
Uses of Timers
On
• Polling the database to check if a certain event has occurred
se
• Performing an automatic query at regular intervals
I U
• Showing “About this...” information at form startup
• Performing automatic commits or rollbacks after a specified idle time
OA
l &
rna
Web Design Tip
e
You should restrict the frequency of timers in Web-deployed forms in order
nt
to reduce a potential increase in network traffic. Replacing timers with
I
e
JavaBeans, which provide similar functionality, will benefit users as code
cl
would be executed on the Web client without invoking network traffic.
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-5
Lesson 14: Applying Timers
......................................................................................................................................................
Timer A B,A
expired
Query
complete
(R) When-Timer-Expired (B)
When-Timer-Expired (A)
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-6 Oracle iDS Forms: Build Internet Applications II
Handling Timer Expiration
......................................................................................................................................................
Timer Queue
When a timer expires, it is put in a queue of expired timers. Forms services
this timer queue on a first-in-first-out basis, but only while it is waiting for
user actions. After an expired timer is handled, it is removed from the queue.
Note: A repeating timer will not begin the next iteration while it is still in
the timer queue.
When-Timer-Expired Trigger
When using the When-Timer-Expired trigger remember that it:
• Fires once for each timer that expires, but only after Form Builder has
completed any current processing of triggers and built-in functions
• Fires after the specified time interval, rather than exactly on the moment
of expiration
• Must be defined at the form level
• Should include the GET_APPLICATION_PROPERTY built-in function
for you to find out which timer has expired
Example
ly
Handle the expiration of two timers named HOUR_ALARM and
n
ABOUT_STARTUP.
DECLARE
v_timer_name VARCHAR2(30);
e O
BEGIN
Us
I
v_timer_name := GET_APPLICATION_PROPERTY(timer_name);
A
IF v_timer_name = ’HOUR_ALARM’ THEN
O
MESSAGE(’One hour has passed again.’);
&
ELSIF v_timer_name = ’ABOUT_STARTUP’ THEN
l
DELETE_TIMER(’ABOUT_STARTUP’);
a
n
END IF;
e
END;
t r
In
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-7
Lesson 14: Applying Timers
......................................................................................................................................................
Creating a Timer
• Syntax:
CREATE_TIMER
CREATE_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)
• Example:
v_timer_id
v_timer_id := CREATE_TIMER ((′hour_alarm’,
:= CREATE_TIMER ′hour_alarm’, cst_hour);
cst_hour);
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-8 Oracle iDS Forms: Build Internet Applications II
Creating a Timer
......................................................................................................................................................
Creating a Timer
You can create a timer by using the CREATE_TIMER built-in function,
which returns type TIMER.
Syntax
Parameter Description
timer_name The timer name
milliseconds The duration of the timer in milliseconds (Value must be
between 1 and 2147483648, approximately 25 days.)
iterate Specifies whether the timer should repeat upon expiration
(Valid values are REPEAT—the default—and NO_REPEAT.)
Example
At form startup, create a timer named HOUR_ALARM that expires every
hour.
DECLARE
cst_hour constant NUMBER(7) := 3600000;
--3600000 is one hour in milliseconds
v_timer_id TIMER;
BEGIN
v_timer_id := CREATE_TIMER(’hour_alarm’, cst_hour);
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-9
Lesson 14: Applying Timers
......................................................................................................................................................
Modifying a Timer
• Syntax:
SET_TIMER
SET_TIMER (timer_name,
(timer_name, milliseconds,
milliseconds, iterate)
iterate)
SET_TIMER
SET_TIMER (timer_id, iterate))
(timer_id, milliseconds, iterate
milliseconds,
• Example:
SET_TIMER ((′hour_alarm’,
SET_TIMER ′hour_alarm’, no_change, no_repeat);
no_change, no_repeat );
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-10 Oracle iDS Forms: Build Internet Applications II
Modifying a Timer
......................................................................................................................................................
Modifying a Timer
You can modify a timer by using the SET_TIMER built-in procedure.
Syntax
Parameter Description
timer_name The timer name
timer_id The internal timer ID
millisec- The duration of the timer in milliseconds (Value must be between 1 and
onds 2147483648—approximately 25 days—or must be NO_CHANGE.)
iterate Specifies whether the timer should repeat upon expiration (Valid
values are REPEAT (default), NO_REPEAT, and NO_CHANGE.)
Example
Set the repeat behavior of a timer named HOUR_ALARM without changing
the time interval. The trigger name depends on the situation.
BEGIN
SET_TIMER(’hour_alarm’, no_change, no_repeat);
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-11
Lesson 14: Applying Timers
......................................................................................................................................................
Deleting a Timer
• Syntax:
DELETE_TIMER
DELETE_TIMER (timer_name)
(timer_name)
DELETE_TIMER
DELETE_TIMER (timer_id)
(timer_id)
• Example:
...
...
IF
IF NOT
NOT ID_NULL (FIND_TIMER ((′hour_alarm
ID_NULL (FIND_TIMER ′hour_alarm′))
′)) THEN
THEN
DELETE_TIMER (’hour_alarm’);
DELETE_TIMER (’hour_alarm’);
END
END IF;
IF;
...
...
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-12 Oracle iDS Forms: Build Internet Applications II
Deleting a Timer
......................................................................................................................................................
Deleting a Timer
You can delete a timer by using the DELETE_TIMER built-in procedure.
Syntax
DELETE_TIMER(timer_name)
DELETE_TIMER(timer_id)
Parameter Description
timer_name The timer name
timer_id The internal timer ID
Example
Delete a timer named HOUR_ALARM after first checking that it exists. The
trigger name depends on the situation.
BEGIN
IF NOT ID_NULL(FIND_TIMER(’hour_alarm’)) THEN
DELETE_TIMER(’hour_alarm’);
END IF;
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-13
Lesson 14: Applying Timers
......................................................................................................................................................
Summary
Summary
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
14-14 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
A timer is a programmatic construct much like an “internal alarm clock.”
Uses of Timers
• Polling the database to check if a certain event has occurred
• Performing an automatic query at regular intervals
• Showing “About this...” information at form startup
• Performing an automatic commit or rollback after a specific amount of
idle time
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-15
Lesson 14: Applying Timers
......................................................................................................................................................
Practice 14 Overview
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-16 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 14
......................................................................................................................................................
Practice Contents
If table rows are locked, display an alert that asks the user to commit or roll
back changes after a set period of time.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 14-17
Lesson 14: Applying Timers
......................................................................................................................................................
Practice 14
1 Automatically ask the users if they want to commit after a set period of
time.
a Open your CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING. This will indicate at all times
whether rows of the S_CUSTOMER table are locked. The default
value is NULL. Append your new code to existing code.
c Create the On-Lock trigger to implement the default lock processing,
update the global variable, and create the timer. You can import the
code from the pr14_1.txt file.
d Display an alert if locks are still pending after a certain period of
time elapses. This alert should ask the user to commit or roll back the
changes. The alert, ASK_SAVE, already exists in your form. Define
an appropriate trigger. You can import the code from the
pr14_2.txt file.
e Create a Post-Database-Commit trigger to restore the NULL value to
the global variable. You can import the code from the pr14_3.txt
file.
f Create the On-Rollback trigger to implement the default rollback
processing and restore the NULL value to the global variable. You
can import the code from the pr14_4.txt file.
g Save and compile your form to test.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
14-18 Oracle iDS Forms: Build Internet Applications II
................................
Including Charts
and Reports
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn how to include charts and reports in your
application. You will also learn how to invoke additional document types
with Web-deployed forms.
Objectives
After completing this lesson, you should be able to do the following:
• Include charts in an application
• Include reports in an application
• Integrate other documents with Web-deployed forms
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-3
Lesson 15: Including Charts and Reports
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-4 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Incorporating a Chart
The steps to create a chart are:
1 Specify a chart type and subtype.
2 Specify the data block that contains the data you want to assign to chart
columns.
3 Specify the data to appear on the Category (X) axis of the chart.
4 Specify the data to appear on the Value (Y) axis of the chart.
Follow the prompts on each page of the wizard to specify the settings for the
chart you want to create.
nly
Re-entering the Chart Wizard
e O
A powerful quality of the Chart Wizard is its ability to operate in reentrant
Us
mode. This means you can use the Chart Wizard to modify an existing chart
created with the wizard.
AI
To invoke the Chart Wizard in reentrant mode, select the chart object in the
& O
l
Object Navigator, and then select Tools—>Chart Wizard from the menu.
a
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-5
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Chart
type
ly
is represented in the
chart.
On
se
I U
OA
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
15-6 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Chart Type
Select the style of chart that you require. The picture on the left of the wizard
displays the relevant chart style.
The chart subtype options are context-sensitive; the number and style of
options change depending on the chart type that you choose. Select the chart
subtype that you require, and then click Next to continue to the next wizard
page.
Data Source
The next step in the Chart Wizard is to select the block that contains the data
you want to represent in the chart. The data block you select determines the
data that is available for assignment to the Category and Value axes of your
chart.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-7
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Arrow points to
the Value axis.
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
15-8 Oracle iDS Forms: Build Internet Applications II
Including Charts by Using the Chart Wizard
......................................................................................................................................................
Category Axis
To use the Chart Wizard to map data to your chart’s Category (X) axis:
1 In the Available Fields list, select the field that you want to map to the
Category (X) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Category
Axis list.
Value Axis
To use the Chart Wizard to map data to your chart’s Value (Y) axis:
1 In the Available Fields list, select the field that you want to map to the
Value (Y) axis of the chart.
2 Transfer the selected field from the Available Fields list to the Value
Axis list.
ly
Bar chart Values are represented by the length of the column against
the x-axis.
On
e
Pie chart Values are represented by the size of each segment.
Us
You must transfer at least one field from the Available Fields list to the
Category Value list before navigating to the next page.
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-9
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Filename
Execution Mode
Communication Mode
Data Source Data Block
Query Name
Data Source X Axis
Data Source Y Axis
Update on Query
Update on Commit
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-10 Oracle iDS Forms: Build Internet Applications II
Chart Item Properties
......................................................................................................................................................
Property Description
Filename Specifies the name of the file where the chart is stored
Execution Mode Specifies the execution version of Graphics Builder to use:
BATCH or RUNTIME
Communication Mode Specifies the communication mode to be used when calling
Graphics Builder: SYNCHRONOUS or ASYNCHRONOUS
Data Source Data Block Specifies the block that contains the data to represent in the chart
Query Name Specifies the name of the query used to display the chart
Data Source X Axis Specifies the item name used to map data to the chart Category
(X) axis
Data Source Y Axis Specifies the item name used to map data to the chart Value (Y)
axis
Update on Query Specifies that the chart is refreshed each time you perform a
query
Update on Commit Specifies that the chart is refreshed each time you perform a
commit
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-11
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Technical Note
Passing data is applicable only if running against a local server.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-12 Oracle iDS Forms: Build Internet Applications II
Reporting Within Form Builder
......................................................................................................................................................
ly
4 Choose the report style that most closely resembles the report you want
n
to create.
5 Select the fields you would like to display in your report.
e O
s
6 Select the fields you would like to total by choosing from a list of
possible calculations. (This step is optional.)
I U
8 Select a template for your report and then click the Finish button.
OA
7 Enter labels and widths for your fields and totals. (This step is optional.)
l
The Live Previewer is displayed.
&
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-13
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Filename
Filename
Execution
Execution Mode
Mode
Communication
Communication Mode
Mode
Data
Data Source
Source Data
Data Block
Block
Query
Query Name
Name
ly
Other Report Parameters
On
se
I U
A
Reports properties
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
15-14 Oracle iDS Forms: Build Internet Applications II
Report Object Properties
......................................................................................................................................................
Reports Properties
ly
Property Name Description
Report Destination Type
n
Specifies the type of device that will receive the report
output
O
Report Destination Name
se
Specifies the name of the file, printer, or Oracle Office
I U
username (or distribution list) to which the report output will
A
be sent
Report Destination Format
O
Specifies the format of your report (values are PDF, HTML,
&
l
HTMLCSS, XML) or the printer driver to be used when
te
Report Server
n
Name of the remote server on which the report is run
e I
Other Report Parameters Declares additional parameters
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-15
Lesson 15: Including Charts and Reports
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-16 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................
Built-in Description
RUN_REPORT_OBJECT Runs a specified report on a specified server
FIND_REPORT_OBJECT Returns the internal ID of a report object
GET_REPORT_OBJECT_PROPERTY Dynamically gets report object properties at
run time
SET_REPORT_OBJECT_PROPERTY Dynamically sets report object properties at
run time
CANCEL_REPORT_OBJECT Cancels a report in the server queue
COPY_REPORT_OUTPUT Copies the report output back to the client
REPORT_OBJECT_STATUS Returns the current status of a report (The status
codes can be FINISHED, RUNNING,
CANCELED, OPENING_REPORT,
ENQUEUED, INVALID_JOB,
TERMINATED_WITH_ERROR, or
CRASHED.)
RUN_PRODUCT Invokes one of the supported Oracle tools
products and specifies the name of the module or
modules to be run
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-17
Lesson 15: Including Charts and Reports
......................................................................................................................................................
DECLARE
v_rep VARCHAR2(100);
repid REPORT_OBJECT;
BEGIN
repid := FIND_REPORT_OBJECT(’deptrpt’);
v_rep := RUN_REPORT_OBJECT(repid);
end;
. . .
repid := FIND_REPORT_OBJECT(’barcode’);
ly
v_rep := RUN_REPORT_OBJECT(repid);
rep_status := REPORT_OBJECT_STATUS(v_rep);
IF rep_status = ’FINISHED’ THEN
On
COPY_REPORT_OBJECT_OUTPUT(v_rep,’c:\local.pdf’);
se
U
HOST(’netscape c:\local.pdf’);
END IF;
AI
O
. . .
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
15-18 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................
ly
END IF;
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-19
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Example
my_url
my_url :=
:= ‘http://www.summit.com/repts/emps.pdf’;
‘http://www.summit.com/repts/emps.pdf’;
WEB.SHOW_DOCUMENT(my_url,
WEB.SHOW_DOCUMENT(my_url, ‘_SELF’);
‘_SELF’);
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-20 Oracle iDS Forms: Build Internet Applications II
Working with Reports
......................................................................................................................................................
Property Value
Report Destination Format File
Report Destination Name ‘pathname’ / ‘report filename’
Report Destination Format HTML
HTMLCSS
PDF
XML
ly
• Target window or frame for displaying the report:
‘_BLANK’ specifies that the document can be downloaded in a new
HTML window.
On
‘_SELF’ specifies that the document is downloaded to the base HTML
se
page window or frame.
I U
‘_TOP’ specifies that the document is downloaded to the base HTML
page, replacing any frames.
OA
l
‘_PARENT’ specifies that the document is downloaded to the parent &
na
window of the base HTML page.
r
te
In this example, WEB.SHOW_DOCUMENT is used to download the emps
n
I
report which has been formatted in pdf:
cle WEB.SHOW_DOCUMENT(’http://www.summit.com/repts/emps.pdf’,
a
‘_blank’);
Or
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-21
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Summary
Summary
e O
s
– COPY_REPORT_OUTPUT
• Communicate with a Web server
I U
A
– WEB.SHOW_DOCUMENT
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
15-22 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
In this lesson, you should have learned how to include charts and reports in
your application. You should have learned how to invoke the Chart Wizard.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-23
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Practice 15 Overview
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-24 Oracle iDS Forms: Build Internet Applications II
Practice Overview: Lesson 15
......................................................................................................................................................
Practice Contents
• Create a chart to display the total orders for each customer.
• Create a report based on the S_CUSTOMER block.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-25
Lesson 15: Including Charts and Reports
......................................................................................................................................................
Practice 15
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the ORDCHART form module. Save as ORDCHARTXX
where XX is your student course number. This form module contains
a S_ORD block. Only one item from this block is visible: TITLE.
This item displays a title for your chart.
b In the Layout Editor, use the Chart tool to drag a chart area onto the
canvas. Select “Use the Chart Wizard” from the New Chart Object
dialog box. Do not specify a title for the chart.
c Select Column as chart type, Plain as chart subtype.
d Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
e Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
f Click the Finish button.
g Save and compile your form module. Deploy your form to the Web
to test. To display the chart, click in the Title item on the Chart tab.
nly
O
This will invoke Report Builder. Within the Report Wizard:
Choose the report style Tabular.
se
U
Select the ID, NAME, COUNTRY, and REGION_ID fields.
Do not select fields to total.
Change labels and widths for your fields.
AI
Select a template for your report.
& O
l
b Save your report and exit Report Builder.
a
rn
c Set the Execution Mode report object property to “runtime” and the
e
t
Report Destination Type report object property to “screen”. Rename
In
the report object to “my_report”.
le
d Create a button named CUST_REP_BUTTON in the control block.
c
a
Display this button on the CANVAS2 canvas.
Or
......................................................................................................................................................
15-26 Oracle iDS Forms: Build Internet Applications II
Practice 15
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II 15-27
Lesson 15: Including Charts and Reports
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
15-28 Oracle iDS Forms: Build Internet Applications II
................................
Practice Solutions
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 1 Solutions
1 Create a new menu module.
a Using the following screenshot as a guideline, create a new menu
module called M_SUMMITXX where XX is your student course
number.
- Select the Menus node in the Object Navigator and click the
Create tool.
- Invoke the Menu Editor.
- This automatically creates the main menu.
nly
O
- Change the name of the menu to MAIN_MENU.
- Rename the menu item New Item to File. Click New Item twice
se
U
to obtain the text cursor. Erase the old name. Enter the name
File.
AI
- Create new menu items under File. Click File. Click the Create
Down tool. Change the name.
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
A-2 Oracle iDS Forms: Build Internet Applications II
Practice 1 Solutions
......................................................................................................................................................
Visible in
Menu Visible Horiz.
Item Command Menu Item in Menu Icon
Label Type Type Code Menu Toolbar Filename
Save Plain PL/SQL DO_KEY(’CO Yes Yes Save
MMIT_FORM’
);
Clear Plain PL/SQL DO_KEY(’ Yes Yes Abort
CLEAR_FORM
’);
Null1 Separator Null Yes Yes
Exit Plain PL/SQL DO_KEY( Yes Yes Exit
’EXIT_FORM
’);
Null2 Separator Null No Yes
- Note the exact names of the Main Menu, and each of its menu
items. These will be needed in a later exercise.
- Create a new menu item to the right of File and rename it Edit.
- Click the File menu item.
- Click the Create Right tool.
nly
O
- Name the new menu item Edit.
- Create new menu items under Edit. Click Edit. Click the Create
se
U
Down tool. Change the name.
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-3
Appendix A: Practice Solutions
......................................................................................................................................................
Visible in
Menu Magic Command Visible Horiz. Menu Icon
Label Item Type Item Type in Menu Toolbar Filename
Cut Magic Cut Null Yes Yes Cut
Copy Magic Copy Null Yes Yes Copy
Paste Magic Paste Null Yes Yes Paste
Null3 Separator Null No Yes
- Create a new menu item to the right of Edit and rename it Sort
By. Click Edit. Click the Create Right tool. Rename the new
menu item Sort By.
- Create three new menu items under Sort By. Click Sort By. Click
the Create Down tool. Change the name. Set additional
properties as follows:
• Sort By Menu
nly
’s_ord’, order_by,
e O’id’ ) ;
Customer Id Radio Order_By PL/SQL
Us SET_BLOCK_PROPERTY(
AI ’s_ord’, order_by,
’customer_id’ ) ;
Sales Rep Id Radio Order_By PL/SQL
& O SET_BLOCK_PROPERTY(
al ’s_ord’, order_by,
ern ’sales_rep_id’ ) ;
Int
cle
ra
O
......................................................................................................................................................
A-4 Oracle iDS Forms: Build Internet Applications II
Practice 1 Solutions
......................................................................................................................................................
Visible in
Menu Command Horiz. Menu Icon
Label Item Type Type Menu Item Code Toolbar Filename
Enter Plain PL/SQL DO_KEY(’ Yes query
Query ENTER_QUERY’);
eXe- Plain PL/SQL DO_KEY(’EXECUT Yes execute
cute E_QUERY’);
Query
ly
a Open the CUSTOMERS form module. Save as CUSTGXX where
XX is your student course number.
On
e
b Copy the EDIT_MENU menu from your M_SUMMIT menu
module to your CUSTOMERS form. Attach this pop-up menu to the
Us
I
Comments item.
- Select EDIT_MENU from the M_SUMMIT menu module.
OA
&
- Click the right mouse button and select Copy.
al
- Select the Pop-up Menus node from the CUSTOMERS form
rn
module.
e
Int
- Click the right mouse button and select Paste.
- Select this pop-up menu in the Popup Menu property for the
ra c Save and compile the form module. Deploy your form to the Web to
O
test.
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-5
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 2 Solutions
1 Define a check menu item.
a Open your M_SUMMIT menu module and add a new menu item to
the Sort By menu; name it Display_Help.
- See previous solution.
- Set the properties as follows:
ly
enabled, property_true);
Else
On
e
set_canvas_property(’toolbar’,
visual_attribute,’Toolred’);
Us
I
set_item_property(’control.showhelp’,
End If;
enabled, property_false);
OA
l
c Save and compile the menu module. &
rna
d Deploy your ORDERS form on the Web to test your menu.
te
2 Synchronize the menu module with the form.
n
I
a Write startup code for your M_SUMMIT menu module that
e
l
synchronizes the Display_Help menu item with the toolbar HELP
c
a
button. You can import the code from the pr2_2.txt file.
r
O
......................................................................................................................................................
A-6 Oracle iDS Forms: Build Internet Applications II
Practice 2 Solutions
......................................................................................................................................................
ly
existing code. You may need to change the code to conform to the
exact names you gave to the Main Menu and its menu items. Also,
be sure the When-Button-Pressed trigger on the Orders button refers
On
to your Orders form.
se
- Import pr2_3.txt file to add the following code.
I U
If :System.current_form = ’CUSTOMERS’then
set_menu_item_property(
OA
l
’main_menu.sort_by’,
&
rna visible,
e
property_false);
Int
End if;
cle
c Save and compile the menu module.
a
d Deploy your CUSTOMERS form to the Web and test your
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-7
Appendix A: Practice Solutions
......................................................................................................................................................
4 With both the ORDERS and CUSTOMERS form modules, restore the default
menu, (DEFAULT&SMARTBAR).
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
A-8 Oracle iDS Forms: Build Internet Applications II
Practice 3 Solutions
......................................................................................................................................................
Practice 3 Solutions
1 Maintain consistent functionality in your form module by using key
triggers. Define a key trigger in your ORDERS form to give users
consistent functionality whenever they exit the form, either using the
menu or when the CONTROL.EXIT_BUTTON button is pressed.
a Redefine [Exit Form] in your ORDERS form so that an alert
message is displayed to users before allowing them to exit the form.
b Amend the entry in Keyboard Help to “Exit Orders” for the key
trigger.
c Save and compile your form. Deploy your form to the Web to test.
- Create a form-level KEY-EXIT trigger. Copy the code from the
CONTROL.EXIT_BUTTON When-button-pressed trigger.
Set_Alert_Property(’Exit_Alert’,
ALERT_MESSAGE_TEXT,
’Do you really want to leave the form?’);
If show_alert(’EXIT_ALERT’) = alert_button1
then
exit_form;
End if;
- Change the keyboard help text in the KEY-EXIT trigger
property palette to “Exit Orders”, and set keyboard help display
to YES.
ly
d Customize the Alert Text message in your key trigger and ensure that
n
it is displayed whenever the user exits the form using the
EXIT_BUTTON on the Control block.
e O
s
- Replace the code in the EXIT_BUTTON When-Button -Pressed
trigger with: do_key(’Exit_Form’);
I U
A
e Save and compile your form module. Deploy to the Web and test
your form.
If you have time
& O
al
2 Disable [Enter query] in your CUSTOMERS form by creating an
rn
appropriate key trigger. Replace [Enter Query] functionality with a call
e
nt
to the customized query form CUSTQUERY. This form allows the user
I
to select a CUSTOMER ID, a CUSTOMER NAME, or a SALES REP
cle
ID. The user selections are returned to your CUSTOMER form using
ra global variables.
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-9
Appendix A: Practice Solutions
......................................................................................................................................................
ly
trigger:
default_value(’’,’global.custid’);
On
e
default_value(’’,’global.custname’);
default_value(’’,’global.repid’);
Us
d Save and compile your CUSTOMER form. Deploy your form to the
AI
O
Web to test.
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
A-10 Oracle iDS Forms: Build Internet Applications II
Practice 4 Solutions
......................................................................................................................................................
Practice 4 Solutions
In this practice, you provide additional functionality in your forms by
defining mouse event triggers.
1 In your CUSTOMERS form, define a mouse event trigger on
S_CUSTOMER.COMMENTS that invokes the item’s editor when the
user double-clicks the item.
- When-Mouse-Doubleclick on s_customer.comments
Edit_TextItem;
2 In your ORDERS form change the mouse cursor symbol to “busy” while
the HELP canvas is displayed.
a Ensure that the default symbol is restored whenever the user hides
the HELP canvas.
- When-Button-Pressed on :control.showhelp
Set_Application_Property(cursor_style,’help’);
- When-Button-Pressed on :control.hidehelp
Set_Application_Property(cursor_style,’normal’);
b The user can close the HELP canvas without pressing the
HIDEHELP button, by navigating to an item in another block. How
can you ensure that the mouse cursor is always restored?
- Define a Post-Block trigger for the Control Data block.
Copy the code to restore the mouse cursor from your
ly
:Control.hidehelp button When-Button-Pressed trigger.
c Save and compile your form modules. Deploy your forms to the Web
to test.You can call the ORDERS form from your CUSTOMERS
On
form.
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-11
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 5 Solutions
1 Manipulate a multiple-window form.
aIn your ORDERS form module, ensure that the form is exited when a
user closes the orders window using the window system menu box.
An alert should be displayed to users asking them to confirm that
they wish to leave the application.
- Define a When-Window-Closed trigger at Form Level.
- Call the do_key built-in to execute [Exit_Form].
b If a user closes the Inventory window through the system menu box,
ensure that the form remains open with the cursor positioned in the
Orders window.
- In the When-Window-Closed trigger, use :system.event_window
to identify the current window:
If :system.event_window = ’WIN_ORDER’ then
do_key(’exit_form’);
else
go_block(’s_ord’);
end if;
c Whenever the user navigates between the order and inventory
windows, place the cursor in the first navigable item within the
current window.
- Define a When-Window-Activated trigger at form level. Use
ly
:system.event_window to identify the current window, and use
the GO_BLOCK built in to enforce navigation within the
appropriate window.
On
d Save and compile your form. Deploy your form to the Web to test.
se
2 In your CUSTOMERS form module, define triggers to manage tab page
I U
navigation.
a Using an appropriate trigger, disable the COMMENTS tab page
OA
l
whenever the COMMENTS item contains no text.
&
na
b The trigger should fire whenever the user navigates to another
r
e
record.
Int
cle
ra
O
......................................................................................................................................................
A-12 Oracle iDS Forms: Build Internet Applications II
Practice 5 Solutions
......................................................................................................................................................
nly
O
then GO_ITEM(‘s_customer.name’);
else if :SYSTEM.tab_new_page = ‘BILLING’
se
then GO_ITEM(‘s_customer.credit_rating’);
I U
A
else GO_ITEM(‘s_customer.comments’);
end if;
& O
l
end if;
n
End;
r a
te
d Save and compile your form. Deploy your form to the Web to test.
n
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-13
Appendix A: Practice Solutions
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
A-14 Oracle iDS Forms: Build Internet Applications II
Practice 6 Solutions
......................................................................................................................................................
Practice 6 Solutions
1 Create a server-side package containing a procedure to return a REF
cursor.
a Create the Orders_pkg package specification; you can import the
code from the pr6_1.txt file.
b Create the Orders_pkg package body; you can import the code from
the pr6_2.txt file.
- Use the Stored Procedure editor in Forms and import the code
from the files.
c Examine the Orders_pkg package body to identify required
parameter values.
- A value of ‘P’,’C’ or ‘S’ is passed to the REF cursor to determine
which query is required. The REF cursor can query on either
products, customers, or sales reps.
2 Open the ORDERREFCURSOR.fmb file and save as ORDREFXX where
XX is your student course number. This form contains a control block,
called CHOOSE, and a group of option buttons which allows the user to
specify a parameter value to be passed to the REF cursor.
a Create a data block called SELECTION and base it on the REF
cursor procedure that you have just created.
- Use the Data Block Wizard and select “Stored Procedures” for
data block type.
- Specify full procedure name:
‘orders_pkg.query_proc’
nly
- Press the Refresh button. Available columns will be displayed.
e O
s
- Select all as Database Items.
b Pass the name of the radio group as the value for the P_VIEW
I U
A
argument: ‘:choose.view_type’.
- For the P_VIEW argument, set the value to
‘:choose.view_type’
& O
al
- Select Finish to end the wizard.
ern
c In the layout editor, customize the canvas layout to ensure that
Int
SELECTION items are displayed to the left of the option buttons
e
group.
cl
d Save and compile your form. Deploy your form to the Web to test.
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-15
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 7 Solutions
1 Create a data block based on a relational table with an object column.
aCreate a form called OBJ_COLXX where XX is your student course
number.
b Using the Data Block Wizard, create a block based on the
REL_EMP_TABLE_OBJCOL relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Expand the object column DEPT_ID and select the attributes ID and
NAME. Note the names that are given to the new items.
e In the Layout Wizard, select all available items for display. Change
the prompt for item DEPT_ID to Department ID and
DEPT_ID_NAME to Department Name. Use a form layout.
f Save, compile, and test your form.
If you have time
2 Create a block based on a relational table with an REF column, and
specify an LOV to populate the REF column.
a Create a form called REF_COLXX where XX is your student course
number.
b Create a block based on the REL_EMP_TABLE_REFCOL
relational table.
c Select the columns ID, FIRST_NAME, and LAST_NAME.
d Select the DEPT_ID attributes ID and NAME.
ly
- Note that there are two items called DEPT_ID. The first is
expandable and has the term “LOOKUP” in parentheses after
the name. The second represents the REF column value itself.
On
The REF item is included automatically when the LOV is
se
created.)
I U
e Create an LOV for the REF item DEPT_ID. Select the check box,
and select OO_DEPT_TABLE as the source for the LOV.
OA
l
f In the Layout Wizard, select all available items for display.
&
na
- The REF item DEPT_ID is included in the list of items in the
r
e
Object Navigator but is not included in the list of available items
nt
in the Layout Wizard.
I
e
g In the Object Navigator, identify the canvas with which item
cl
DEPT_ID is associated.
ra
O
......................................................................................................................................................
A-16 Oracle iDS Forms: Build Internet Applications II
Practice 7 Solutions
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-17
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 8 Solutions
1 Open your ORDERS form and examine the properties of the relation
called S_ORD_S_ITEM.
a Note the deletion and coordination property values.
b Run the ORDERS form and test the way deletes are handled.
2 Implement a query coordination-type toggle.
a Add two check boxes to the control block with the following
properties:
nly Y
DataBase Item No
e O No
Canvas TOOLBAR
Us TOOLBAR
& O
l
c Make sure that the first check box enables a user to toggle between
na
immediate coordination and deferred coordination. You can import
r
e
the code from the pr8_1.txt file.
Int
- When-Checkbox-Changed on CONTROL.IMMEDIATE
cle
ra
O
......................................................................................................................................................
A-18 Oracle iDS Forms: Build Internet Applications II
Practice 8 Solutions
......................................................................................................................................................
If GET_RELATION_PROPERTY( ’s_ord_s_item’,
DEFERRED_COORDINATION )
= ’FALSE’ Then
SET_RELATION_PROPERTY(’s_ord_s_item’,
DEFERRED_COORDINATION,
PROPERTY_TRUE);
SET_ITEM_PROPERTY(’control.auto_query’,
ENABLED,
PROPERTY_TRUE );
Else
SET_RELATION_PROPERTY(’s_ord_s_item’,
DEFERRED_COORDINATION,
PROPERTY_FALSE);
SET_ITEM_PROPERTY(’control.auto_query’,
ENABLED,
PROPERTY_FALSE );
End If;
d Make sure that the second check box enables a user to toggle
between automatic query and no automatic query for the detail
block. This check box should be disabled if the other check box
indicates immediate coordination. You can import the code from the
pr8_2.txt file.
ly
- When-Checkbox-Changed on CONTROL.AUTO_QUERY
If GET_RELATION_PROPERTY(’s_ord_s_item’,
On
e
AUTOQUERY ) = ’FALSE’ Then
SET_RELATION_PROPERTY(’s_ord_s_item’,
Us
AUTOQUERY, PROPERTY_TRUE );
AI
O
Else
&
SET_RELATION_PROPERTY(’s_ord_s_item’,
al AUTOQUERY, PROPERTY_FALSE);
rn
End If;
e
Int
e Save, compile, and test your form.
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-19
Appendix A: Practice Solutions
......................................................................................................................................................
ly
Else
:control.auto_query := ’N’;
On
e
End If;
End;
Us
c Call this procedure from the When-New-Form-Instance trigger.
AI
d Save, compile, and run the module.
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
A-20 Oracle iDS Forms: Build Internet Applications II
Practice 9 Solutions
......................................................................................................................................................
Practice 9 Solutions
1 Create a multiple-form application by linking the CUSTOMERS and the
SALESREP forms. The SALESREP form provides a look up facility for
:S_CUSTOMER.SALES_REP_ID. It replaces the SALES_REP_LOV
list of values. Values are selected by mouse double click.
a Open SALESREP form and save as SALESREPXX where XX is
your student course number.
b In your CUSTOMERS form, modify the code in the
SALES_LOV_BUTTON When-Button-Pressed trigger to call the
SALESREP form.
c Ensure that the user can see, but not navigate to, your CUSTOMERS
form, while the SALESREP form is open.
d Update :S_CUSTOMER.SALES_REP_ID with the value selected
by the user in the SALESREP form. The selected Sales Rep ID is
returned in a GLOBAL variable called “salesrepid”. This variable
contains either a valid value or the text “NOT SELECTED”.
- Ensure that you call your SALESREP form which is identified
by the XX suffix.
CALL_FORM(‘SALESREP’,no_hide);
If :global.salesrepid <> ‘NOT SELECTED’ then
:S_CUSTOMER.SALES_REP_ID :=
:global.salesrepid
End if;
ly
e Save and compile your form. Deploy your form to the Web to test.
r
e
If :global.salesrepid <> ‘NOT 4SELECTED’ then
Int :S_CUSTOMER.SALES_REP_ID :=
e
:global.salesrepid
cl End if;
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-21
Appendix A: Practice Solutions
......................................................................................................................................................
b In the SALESREP form, ensure that whenever the form has been
opened by ‘CALL_FORM’, that a [Commit Form] performs a POST.
- In a KEY-COMMIT trigger, define the following code:
If get_application_property(calling_form)
is not null then
post;
else
commit_form;
end if;
c Ensure that updates in SALESREP are not cleared when the user
exits the form.
- SALESREP form KEY-EXIT trigger
If get_application_property(calling_form)
is not null then
exit_form(do_commit,no_rollback);
else
exit_form;
end if;
d Save and compile your form. Deploy your form to the Web to test.
ly
the form is called from CUSTOMERS.
a Create a parameter called ‘EVERYONE’ in the SALESREP form.
On
e
Specify a default value of ‘Y’.
- Create a PARAMETER object, called “EVERYONE” in the
Us
I
Object Navigator. Define as character type CHAR, with a
default value of “Y”.
b Ensure that the SALESREP form will perform an unrestricted query
OA
l
whenever the parameter value = ‘Y’. If the parameter value = ‘S’, a
&
na
restricted query should be performed, selecting only Sales
r
e
Representatives.
Int
- Create a PRE-QUERY trigger :
cle
If :parameter.everyone = ‘S’ then
ra
O
......................................................................................................................................................
A-22 Oracle iDS Forms: Build Internet Applications II
Practice 9 Solutions
......................................................................................................................................................
e
No_Share_Library_Data, ‘EMPS’ );
If :global.salesrepid = ‘NOT SELECTED’ then
Us
message(‘New Sales Rep not selected’);
AI
Else
:s_customer.sales_rep_id :=
& O
al :global.salesrepid;
Int
End;
e
d Save and compile your forms. Deploy your form to the Web to test.
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-23
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 10 Solutions
1 Create a dynamic list item populated from a design-time query record
group. The record group will hold region ID and the name of the
departments in the S_DEPT table.
a Open the Employees form. Save as EmpXX where XX is your student
course number. In the Object Navigator, create a record group named
DEPT_ID based on the query below:
SELECT name || ‘ in region ’ ||
TO_CHAR(region_id) Name,
TO_CHAR(id) Id
FROM s_dept
UNION
SELECT ‘none’ Name, ‘0’ Id from dual
ORDER BY 1
b Convert the text item DEPT_ID into a list item, with a Poplist style.
Resize the list item in the Layout Editor.
c Create one element in the list item. Specify a label of ‘Dummy’ and a
value of ‘0’. Set the Mapping of Other Values property to ‘0’.
d Create a procedure called POPULATE_DEPT_LIST. This procedure
will accept the list item name as an argument and populate the list
item dynamically at run time, using the design-time query record
group.
You can import the code from the pr10_1.txt file.
ly
- Procedure Populate_Dept_List
p_list_item in varchar2) is
On
e
cst_rg_nom constant varchar2( 30 ) :=
Get_Item_Property(p_list_item,
Us
I
Item_Name );
Begin
OA
&
If Populate_Group( cst_rg_nom ) = 0 then
al
Populate_List( p_list_item, cst_rg_nom );
rn
End If;
e
Int
Copy(Get_List_Element_Value( p_list_item,1),
p_list_item);
cle
End;
ra
O
......................................................................................................................................................
A-24 Oracle iDS Forms: Build Internet Applications II
Practice 10 Solutions
......................................................................................................................................................
ly
c The procedure will also populate the list item S_EMP.DEPT_ID.
d You can import the procedure code from pr10_2.txt file.
On
e
- Procedure Create_Dept_List is
v_rg_id recordgroup;
Us
v_error number;
AI
Begin
rg_count number;
& O
al
v_rg_id := find_group(’qdept’);
Int v_rg_id :=
e
create_group_from_query(’qdept’,
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-25
Appendix A: Practice Solutions
......................................................................................................................................................
’Select name||to_char(region_id),
to_char(id)
from s_dept
UNION
Select ‘‘none’’ Name, to_char(0) Id
from dual
order by 1');
end if;
v_error := populate_group(v_rg_id);
populate_list('s_emp.dept_id',v_rg_id);
Copy(Get_List_Element_Value('s_emp.dept_id',
1), 's_emp.dept_id');
End;
e Call the procedure from the When-Create-Record trigger.
- When-Create-Record Trigger on the S_EMP Block:
Create_Dept_List;
f Compile and save your form module. Test.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
A-26 Oracle iDS Forms: Build Internet Applications II
Practice 11 Solutions
......................................................................................................................................................
Practice 11 Solutions
1 Create a picklist by using the picklist class. This picklist enables the end
user to select order items from a product list, and to place selections in a
second list.
a Create a new form module, called PICKXX where XX is your student
course number. Open the Form_Builder_II.olb object
library. This library contains form objects and code for the picklist.
Copy the PICKLIST_BASIC object group to your form module.
Copy the PICKLIST object group into your new form module.
b Ensure the CONTROL block is the last defined data block in the
Object Navigator.
c Attach the picklist.pll library. This contains the functions
and procedures required for creating the picklist.
d Define a When-New-Form-Instance trigger which will create and
populate the picklist. You can import the code from the
pr11_1.txt file.
- Declare
dummy number;
Begin
Default_Value(‘Y’,’Global.where_cls’);
pick_list.create_picklist;
if :GLOBAL.where_cls = ‘Y’ then
dummy := pick_list.populate_picklist_with_query(
pick_list.list_in, ‘select name, id from
s_product ‘ order by 1’);
nly
O
else
e
dummy := pick_list.populate_picklist_with_query(
pick_list.list_in, ‘select name, id from
Us
I
s_product where ‘ || :GLOBAL.where_cls ||’ order
by 1’);
end if;
OA
l
pick_list.set_picklist_selection(
&
rna pick_list.list_in,1,null);
pick_list.display_picklist(pick_list.list_in);
nte pick_list.display_picklist(pick_list.list_out);
e I End;
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-27
Appendix A: Practice Solutions
......................................................................................................................................................
ly
Date_LOV package, to your module.
n
c Create a Key-Listval trigger on the date ordered item. Add code to
display the calendar using the Date_LOV package. You can import
e O
s
the code from the pr11_2.txt file.
- date_lov.get_date( sysdate, -- initial date
I U
A
’s_ord.date_ordered’, -- return block.item
240,
60,
-- window x position
-- window y position
& O
al ’Order Date’, -- window title
t
’Cancel’, -- cancel button label
a
FALSE); -- autoskip after selection
Or
......................................................................................................................................................
A-28 Oracle iDS Forms: Build Internet Applications II
Practice 11 Solutions
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-29
Appendix A: Practice Solutions
......................................................................................................................................................
Practice 12 Solutions
1 Provide an alternative user interface for your Web-deployed forms by
including Pluggable Java Components (PJCs).
a Open the JAVAEMP.fmb form module. Save as JAVAXX.fmb,
where XX is your student course code.
b Change the :EMP.SAL item so that values are displayed as asterisks
at run time. Use the PJC ‘PasswordFieldPJC.class’.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
- In the :EMP.SAL Property Palette, set the implementation class
to ‘oracle.forms.demos.PasswordFieldPJC’.
c Change the :EMP.ENAME item so that the mouse cursor changes to
‘hand’ style whenever the cursor is moved over the item. Use the
PJC ‘ModCursor.class’.
This class file is held in the folder:
FORMS60_JAVADIR /oracle/forms/demos
- In the :EMP.ENAME property palette, set the implementation
class to ‘oracle.forms.demos.ModCursor’.
ly
- In the When-New-Form-Instance trigger, include:
n
SET_CUSTOM_PROPERTY(‘EMP.ENAME’,1,
‘DOCURSOR’,‘HAND’);
e O
s
e Save and compile your form. Deploy your form to the Web to test.
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
A-30 Oracle iDS Forms: Build Internet Applications II
Practice 12 Solutions
......................................................................................................................................................
ly
:system.custom_item_event_parameters);
if(eventName = ’LINKEVENT’) then
On
get_parameter_attr(eventValues,
se
U
’LINKEVENTDATA’,
eventValueType,url);
AI
O
web.show_document(url,’_blank’);
&
end if;
al
End;
ern
d
Int Create two text items, one called ‘URL’ to accept a URL and one
called ‘LABEL’ to accept a URL label. These will enable the user to
cle select a different URL. Set the maximum length for the URL text
a
item to 255.
Or
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-31
Appendix A: Practice Solutions
......................................................................................................................................................
- Create two text items, URL and LABEL, in the Data Block
‘LINK’.
e O
s
’Oracle Technet!’);
set_custom_property(’HYPERLINK1’,1,
I U
A
’LINKURL’,
O
’http://technet.oracle.com’);
end if;
l &
rna
e
f Save and compile your form. Deploy your form to the Web to test.
Int
cle
ra
O
......................................................................................................................................................
A-32 Oracle iDS Forms: Build Internet Applications II
Practice 13 Solutions
......................................................................................................................................................
Practice 13 Solutions
1 Create a stored procedure, and process error messages that may be
generated in the CUSTSERVER form.
a Open the CUSTSERVER form and save as CUSTSERVXX where
XX is your student course number. Copy the code in the
SELECT_CODE program unit and create a stored procedure called
SELECT_CUSTOMER. This procedure takes a user supplied value
from :CONTROL.NAME to check whether a customer name already
exists. Existing names will generate an error.
b Modify the When-Button-Pressed trigger for the CONTROL block
CHECK_CUSTOMER button, to trap any errors generated from the
stored procedure SELECT_CUSTOMER. If a customer already
exists, display a warning message to the user.
- Add the following code:
exception
when others then
message(sqlcode||’ ‘||sqlerrm);
raise form_trigger_failure;
c Save and compile your form module; test.
e O
s
b Define an appropriate trigger to trap the generated error message,
and display the database constraint violation message and error code.
I U
A
Ensure that any other generated messages will continue to be
O
displayed.
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-33
Appendix A: Practice Solutions
......................................................................................................................................................
ly
d Save and compile your form module; test your form.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
A-34 Oracle iDS Forms: Build Internet Applications II
Practice 14 Solutions
......................................................................................................................................................
Practice 14 Solutions
1 Automatically ask the users if they want to commit after a set period of
time.
a Open your CUSTOMERS form module.
b At the startup of the form, create a global variable called
GLOBAL.LOCKS_PENDING. This will indicate at all times
whether rows of the S_CUSTOMER table are locked.
The default value is NULL. Append your new code to existing code.
- When-New-Form-Instance Trigger at Form Level
...
Default_Value( NULL, ’GLOBAL.locks_pending’);
ly
:GLOBAL.locks_pending := ’TRUE’;
timer_id := CREATE_TIMER( ’locks’,
On
e
5000 );
End If;
Us
Else
AI
O
Raise Form_Trigger_Failure;
End If;
l &
End;
rna
e
d Display an alert if locks are still pending after a certain period of
Int
time elapses. This alert should ask the user to commit or roll back the
changes. The alert, ASK_SAVE, already exists in your form. Define
cle an appropriate trigger. You can import the code from the
ra pr14_2.txt file.
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-35
Appendix A: Practice Solutions
......................................................................................................................................................
& O
l
:Global.locks_pending := NULL;
End If;
rna
e
g Save and compile your form to test.
Int
cle
ra
O
......................................................................................................................................................
A-36 Oracle iDS Forms: Build Internet Applications II
Practice 15 Solutions
......................................................................................................................................................
Practice 15 Solutions
1 Create a chart object by using the Chart Wizard. This chart should
display the total orders for each customer.
a Open the ORDCHART form module. Save as ORDCHARTXX
where XX is your student course number. This form module contains
a S_ORD block. Only one item from this block is visible: TITLE.
This item displays a title for your chart.
b In the Layout Editor, use the Chart tool to drag a chart area onto the
canvas. Select “Use the Chart Wizard” from the New Chart Object
dialog box. Do not specify a title for the chart.
c Select Column as chart type, Plain as chart subtype.
d Specify the S_ORD block as the data block that contains the data
you want to assign to chart columns.
e Select CUSTOMER_NAME to appear on the Category (X) axis, and
TOTAL to appear on the Value (Y) axis of the chart.
f Click the Finish button.
g Save and compile your form module. Deploy your form to the Web
to test. To display the chart, click in the Title item on the Chart tab.
nly
O
- Select the Reports node in the Object Navigator.
- Click the Create icon.
se
- Specify a filename of ‘myreport’ and a block name.
I U
A
Click OK.
b This will invoke Report Builder. Within the Report Wizard:
Choose the report style Tabular.
& O
al
Select the ID, NAME, COUNTRY, and REGION_ID fields.
ern
Do not select fields to total.
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II A-37
Appendix A: Practice Solutions
......................................................................................................................................................
d Set the Execution Mode report object property to “runtime” and the
Report Destination Type report object property to “screen”. Rename
the report object to “my_report”.
- Display the Property Palette for the report object.
- Select Execution Mode and change the value to “RUNTIME”.
- Select Report Destination Type and change the value to
“SCREEN”.
e Create a button named CUST_REP_BUTTON in the control block.
Display this button on the CANVAS2 canvas.
f Create a When-Button-Pressed trigger on the
CUST_REP_BUTTON button to run the report.
- DECLARE
repid REPORT_OBJECT;
v_rep VARCHAR2(100);
rep_status VARCHAR2(20);
BEGIN
repid := FIND_REPORT_OBJECT(‘my_report’);
v_rep := RUN_REPORT_OBJECT(repid);
END;
g Change the Query All Record property value to Yes for the
S_CUSTOMER block.
h Save and compile your form module. Deploy your form to the Web
ly
to test. Query a customer record before calling the report.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
A-38 Oracle iDS Forms: Build Internet Applications II
................................
Table Descriptions
and Data
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ORD_ID
ID
S_ITEM S_ORD
PRODUCT_ID CUSTOMER_ID
SALES_REP_ID
S_INVENTORY
*
PRODUCT_ID
ID
ID ID
S_CUSTOMER
S_PRODUCT SALES_REP_ID
IMAGE_ID
ID ID ID
S_IMAGE S_EMP
DEPT_ID
nly
e O ID
S_DEPT Us
A I
*Unique occurrences are identified by PRODUCT_ID and
& O
WAREHOUSE_ID.
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-2 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Description
.....................................................................................................................................................
S_CUSTOMER Description
Column Name Null? Datatype
-------------- --------- ------------- -----------------
ID NOT NULL NUMBER(7)
NAME NOT NULL VARCHAR2(50)
PHONE VARCHAR2(25)
ADDRESS VARCHAR2(400)
CITY VARCHAR2(30)
STATE VARCHAR2(20)
COUNTRY VARCHAR2(30)
ZIP_CODE VARCHAR2(75)
CREDIT_RATING VARCHAR2(9)
SALES_REP_ID NUMBER(7)
REGION_ID NUMBER(7)
COMMENTS VARCHAR2(255)
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-3
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_CUSTOMER Data
ly
Customer should always pay by cash until his credit rating
n
improves.
e O
s
203 Delhi Sports 91-10351 11368 Chanakya
New Delhi India
I U
A
Good 14 4
Customer specializes in baseball equipment and is the largest
& O
l
retailer in India.
rna
nte
e I
cl
ra
O
......................................................................................................................................................
B-4 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Data
.....................................................................................................................................................
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-5
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
EXCELLENT 12 2
Customer is difficult to reach by phone. Try mail.
On
211 Kuhn’s Sports 42-111292
se 7 Modrany
Prague
I U Czechoslovakia
EXCELLENT 15
OA 5
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
B-6 Oracle iDS Forms: Build Internet Applications II
S_CUSTOMER Data
.....................................................................................................................................................
ly
Buffalo NY USA
14202 POOR 11
On 1
se
U
215 Sporta Russia 7-3892456 6000 Yekatamina
St. Petersburg Russia
AI
O
POOR 15 5
&
This customer is very friendly, but has difficulty paying bills.
al
Insist upon cash.
ern
Int
le
Note: This display has been formatted.
c
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-7
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ID NAME REGION_ID
------ ---------------- -----------------
10 Finance 1
31 Sales 1
32 Sales 2
33 Sales 3
34 Sales 4
35 Sales 5
41 Operations 1
42 Operations 2
43 Operations 3
44 Operations 4
45 Operations 5
50 Administration 1
12 rows selected.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-8 Oracle iDS Forms: Build Internet Applications II
S_EMP Description
.....................................................................................................................................................
S_EMP Description
Column Name Null? Datatype
------------------------ -------------- --------------
ID NOT NULL NUMBER(7)
LAST_NAME NOT NULL VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
COMMENT VARCHAR2(255)
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID NUMBER(7)
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-9
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_EMP Data
nly
O
5 Ropeburn Audry aropebur 04-MAR-90
1 VP, Administration
se 50 1550
I U
A
6 Urguhart Molly murguhar 18-JAN-91
2 Warehouse Manager
& O 41 1200
al
n
7 Menchu Roberta rmenchu 14-MAY-90
In
8 Biri Ben bbiri 07-APR-90
le
2 Warehouse Manager 43 1100
......................................................................................................................................................
B-10 Oracle iDS Forms: Build Internet Applications II
S_EMP Data
.....................................................................................................................................................
nly 33 1515
O
10
se
U
14 Nguyen Mai mnguyen 22-JAN-92
3 Sales Representative
AI 34 1525
15
& O
al
15 Dumas Andre adumas 09-OCT-91
Int 17.5
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-11
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
21 Markarian Alexander
O
8 Stock Clerk 43 850
se
U
22 Chang Eddie echang 30-NOV-90
9 Stock Clerk
AI 44 800
23 Patel Radha
& O rpatel 17-OCT-90
al
9 Stock Clerk 34 795
ern
Int
24 Dancs Bela bdancs 17-MAR-91
e
10 Stock Clerk 45 860
cl
ra 25 Schwartz Sylvie sschwart 09-MAY-91
......................................................................................................................................................
B-12 Oracle iDS Forms: Build Internet Applications II
S_ITEM Description
.....................................................................................................................................................
S_ITEM Description
Column Name Null? Datatype
------------------------- -------------- ----------
ORD_ID NOT NULL NUMBER(7)
ITEM_ID NOT NULL NUMBER(7)
PRODUCT_ID NOT NULL NUMBER(7)
PRICE NUMBER(11,2)
QUANTITY NUMBER(9)
QUANTITY_SHIPPED NUMBER(9)
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-13
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_ITEM Data
ly
104 2 20512 8 12 12
104
105
3
1
30321
50273
1669 19
22.8 16
19
16
On
105 3 50532 47 28
se
28
105 2 50419 80 13
I U13
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
B-14 Oracle iDS Forms: Build Internet Applications II
S_ITEM Data
.....................................................................................................................................................
ly
109 4 30326 582 1500 1500
109
109
2
3
10012
10022
175
On
600
21.95 300
600
300
110 1 50273
se
22.89 17 17
U
110 2 50536 50 23 23
111
111
1
2
40421
41080
AI
65
35
27
29
27
29
97 1 20106
l
97 2 303211 500 50 50
98
r
99
na 1
1
404218
20510
5
9
7
18
7
18
nte
99 2 20512 8 25 25
I
99 3 50417 80 53 53
cle 99 4 50530 45 69 69
ra
O
Note: This display has been formatted.
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-15
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
110 214 09-SEP-92 21-SEP-9211 1539.13 CASH Y
111 204 09-SEP-92 21-SEP-9211 2770 CASH Y
97
98
201
202
28-AUG-92
31-AUG-92
17-SEP-9212
10-SEP-9214
On
84000
595
CREDIT
CASH
Y
Y
99 203 31-AUG-92 18-SEP-9214
se 7707 CREDIT Y
U
112 210 31-AUG-92 10-SEP-9212 550 CREDIT Y
16 rows selected.
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-16 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Description
.....................................................................................................................................................
S_PRODUCT Description
Column Name Null? Datatype
---------------------------------- -----------------
ID NOT NULL NUMBER(7)
NAMENOT NULL VARCHAR2(50)
SHORT_DESC VARCHAR2(255)
LONGTEXT_ID NUMBER(7)
IMAGE_ID NUMBER(7)
SUGGESTED_WHLSL_PRICE NUMBER(11,2)
WHLSL_UNITS VARCHAR2(25)
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-17
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
S_PRODUCT Data
ly
20106 Junior Soccer BallJunior soccer ball613
11
On
20108 World Cup Soccer BallWorld cup soccer ball615
se
U
28
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-18 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Data
.....................................................................................................................................................
ly
Bottle 7
1381
Lifting Bar
65
OA
l &
1382
rna
40422 Pro Curling BarCurling bar
50
929
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-19
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
e O
s
45
I U
A
50169 Major League Baseball 676
O
Baseball
&
1119 4.29
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-20 Oracle iDS Forms: Build Internet Applications II
S_PRODUCT Data
.....................................................................................................................................................
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-21
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ID NAME
--- --------------------------
1 North America
2 South America
3 Africa / Middle East
4 Asia
5 Europe
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-22 Oracle iDS Forms: Build Internet Applications II
S_TITLE Description and Data
.....................................................................................................................................................
TITLE
------------------------
President
Sales Representative
Stock Clerk
VP, Administration
VP, Finance
VP, Operations
VP, Sales
Warehouse Manager
8 rows selected.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-23
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
emp_type_RefCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
ly
START_DATE DATE
MANAGER_ID
On NUMBER(7)
e
TITLE VARCHAR2(25)
DEPT_ID
Us REF OF DEPT_TYPE
SALARY
AI NUMBER(11,2)
O
COMMISSION_PCT NUMBER(4,2)
dept_type
l &
na
---------------------------------
r
----------------
e
ID NUMBER
Int
NAME VARCHAR2(25)
ra
O
......................................................................................................................................................
B-24 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
Tables
oo_emp_Table_ObjCol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
ID LAST_NAME FIRST_NAME USERID
--------- --------------------- --------------- --------
START_DAT MANAGER_ID TITLE
--------- ---------- -------------------------
DEPT_ID(ID, NAME, REGION_ID)
-----------------------------------------------------------
SALARY COMMISSION_PCT
ly
---------- --------------
n
1Velasquez Carmencvelasqu
03-MAR-90 President
e O
s
DEPT_TYPE(50, ’Administration’, 1)
2500
I U
2Ngao
OA
LaDorislngao
08-MAR-90
l & 1 VP Operations
na
DEPT_TYPE(41, ’Operations’, 1)
r
te
1450
In
cle 3Nagayama Midorimnagayam
a
17-JUN-91 1 VP Sales
Or
DEPT_TYPE(31, ’Sales’, 1)
1400
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-25
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
nly
O
7 Menchu Roberta rmenchu
e
14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, ’Operations’, 2)
Us
1250
AI
8 Biri Ben bbiri
& O
al
07-APR-90 2 Warehouse Manager
rn
DEPT_TYPE(43, ’Operations’, 3)
e
Int 1100
O DEPT_TYPE(44, ’Operations’, 4)
1300
......................................................................................................................................................
B-26 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
nly
O
13 Sedeghi Yasmin ysedeghi
e
18-FEB-91 3 Sales Representative
DEPT_TYPE(33, ’Sales’, 3)
Us
1515 10
AI
14 Nguyen Mai mnguyen
& O
22-JAN-92
al 3 Sales Representative
rn
DEPT_TYPE(34, ’Sales’, 4)
e
Int
1525 15
ra
09-OCT-91 3 Sales Representative
ODEPT_TYPE(35, ’Sales’, 5)
145018
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-27
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
nly
O
19 Patel Vikram vpatel
e
06-AUG-91 7 Stock Clerk
DEPT_TYPE(42, ’Operations’, 2)
Us
795
AI
20 Newman Chad
& O cnewman
al
21-JUL-91 8 Stock Clerk
rn
DEPT_TYPE(43, ’Operations’, 3)
e
Int 750
O DEPT_TYPE(43, ’Operations’, 3)
850
......................................................................................................................................................
B-28 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
nly
O
25 Schwartz Sylvie sschwart
e
09-MAY-91 10 Stock Clerk
DEPT_TYPE(45, ’Operations’, 5)
Us
1100
AI
oo_emp_Table_RefCol
& O
Name
al Null? Type
n
------------------------------ ----------------
ID
ter NUMBER(7)
In
LAST_NAME VARCHAR2(25)
le
FIRST_NAME
c
VARCHAR2(25)
a
USERID VARCHAR2(8)
Or
START_DATE
MANAGER_ID
DATE
NUMBER(7)
TITLE VARCHAR2(25)
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-29
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
1450
& O
al
n
4 Quick-To-See Mark mquickto
er
07-APR-90 1 VP Finance
t
In
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408
e
002072C15B
cl 1450
ra
O 5 Ropeburn
04-MAR-90 1 VP Administration
Audry aropebur
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
1550
......................................................................................................................................................
B-30 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
ly
27-FEB-91 2 Warehouse Manager
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
On
1307
se
I U
A
11 Magee Colin cmagee
14-MAY-90 3 Sales Representative
& O
l
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
002072C15B
rna
e
1400 10
Int
e
13 Sedeghi Yasmin ysedeghi
cl
18-FEB-91 3 Sales Representative
ra
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408
O
002072C15B
1515 10
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-31
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
1400
e O
Us
I
17 Smith George gsmith
A
08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
940
rna
nte
18 Nozaki Akira anozaki
e I
09-FEB-91 7 Stock Clerk
cl
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 1200
......................................................................................................................................................
B-32 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
ly
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
850
e O
Us
I
22 Chang Eddie echang
A
30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
800
rna
nte
23 Patel Radha rpatel
e I
17-OCT-90 9 Stock Clerk
cl
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 795
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-33
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
oo_dept_table
Name Null? Type
-------------------- ------------- ----------------
ID
nly NUMBER
O
NAME VARCHAR2(25)
e
REGION_ID NUMBER(7)
Us
AI
O
ID NAME REGION_ID
&
-------------------- ------------- ----------------
10
al Finance 1
31
ern Sales 1
32
33
Int Sales
Sales
2
3
34
cle Sales 4
ra
35 Sales 5
O41
42
Operations
Operations
1
2
43 Operations 3
......................................................................................................................................................
B-34 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
44 Operations 4
45 Operations 5
50 Administration 1
rel_emp_Table_Objcol
Name Null? Type
-------------------- ------------- ----------------
ID NUMBER(7)
LAST_NAME VARCHAR2(25)
FIRST_NAME VARCHAR2(25)
USERID VARCHAR2(8)
START_DATE DATE
MANAGER_ID NUMBER(7)
TITLE VARCHAR2(25)
DEPT_ID DEPT_TYPE
SALARY NUMBER(11,2)
COMMISSION_PCT NUMBER(4,2)
ly
--------- ---------- -------------------------
n
DEPT_ID(ID, NAME, REGION_ID)
------------------------------------------------------------
e O
s
SALARY COMMISSION_PCT
---------- --------------
I U
A
1 Velasquez Carmen cvelasqu
03-MAR-90 President
& O
l
DEPT_TYPE(50, ’Administration’, 1)
2500
rna
nte
I
2 Ngao LaDoris lngao
le
08-MAR-90 1 VP Operations
c
a
DEPT_TYPE(41, ’Operations’, 1)
Or 1450
nly
O
7 Menchu Roberta rmenchu
e
14-MAY-90 2 Warehouse Manager
DEPT_TYPE(42, ’Operations’, 2)
Us
1250
AI
8 Biri Ben bbiri
& O
07-APR-90
al 2 Warehouse Manager
rn
DEPT_TYPE(43, ’Operations’, 3)
e
Int
1100
ra
09-FEB-92 2 Warehouse Manager
ODEPT_TYPE(44, ’Operations’, 4)
1300
......................................................................................................................................................
B-36 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
nly
O
13 Sedeghi Yasmin ysedeghi
e
18-FEB-91 3 Sales Representative
DEPT_TYPE(33, ’Sales’, 3)
Us
1515 10
AI
14 Nguyen Mai mnguyen
& O
22-JAN-92
al 3 Sales Representative
rn
DEPT_TYPE(34, ’Sales’, 4)
e
1525
Int 15
ra
09-OCT-91 3 Sales Representative
O
DEPT_TYPE(35, ’Sales’, 5)
1450 18
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-37
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
nly
O
19 Patel Vikram vpatel
e
06-AUG-91 7 Stock Clerk
DEPT_TYPE(42, ’Operations’, 2)
Us
795
AI
20 Newman Chad
& O cnewman
21-JUL-91
al 8 Stock Clerk
rn
DEPT_TYPE(43, ’Operations’, 3)
e
Int
750
ra
26-MAY-91 8 Stock Clerk
ODEPT_TYPE(43, ’Operations’, 3)
850
......................................................................................................................................................
B-38 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
nly
O
25 Schwartz Sylvie sschwart
e
09-MAY-91 10 Stock Clerk
DEPT_TYPE(45, ’Operations’, 5)
Us
1100
AI
rel_emp_Table_RefCol
& O
Name
al Null? Type
n
-------------------- ------------- ----------------
ID
ter NUMBER(7)
In
LAST_NAME VARCHAR2(25)
le
FIRST_NAME
c
VARCHAR2(25)
a
USERID VARCHAR2(8)
Or
START_DATE
MANAGER_ID
DATE
NUMBER(7)
TITLE VARCHAR2(25)
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-39
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-40 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
ly
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
1400
e O
Us
I
4 Quick-To-See Mark mquickto
A
07-APR-90 1 VP Finance
0000220208447F54A9ED59676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
1450
rna
nte
5 Ropeburn Audry aropebur
e I
04-MAR-90 1 VP Administration
cl
0000220208447F54A9ED64676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 1550
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-41
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
0000220208447F54A9ED63676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
1307
e O
Us
I
11 Magee Colin cmagee
A
14-MAY-90 3 Sales Representative
0000220208447F54A9ED5A676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
1400
rna 10
nte
13 Sedeghi Yasmin ysedeghi
e I
18-FEB-91 3 Sales Representative
cl
0000220208447F54A9ED5C676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 1515 10
......................................................................................................................................................
B-42 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
ly
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
1400
e O
Us
I
17 Smith George gsmith
A
08-MAR-90 6 Stock Clerk
0000220208447F54A9ED5F676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
940
rna
nte
18 Nozaki Akira anozaki
e I
09-FEB-91 7 Stock Clerk
cl
0000220208447F54A9ED60676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 1200
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-43
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
ly
0000220208447F54A9ED61676AE03408002072C15B447F54A9ED55676AE03408
n
002072C15B
850
e O
Us
I
22 Chang Eddie echang
A
30-NOV-90 9 Stock Clerk
0000220208447F54A9ED62676AE03408002072C15B447F54A9ED55676AE03408
& O
l
002072C15B
800
rna
nte
23 Patel Radha rpatel
e I
17-OCT-90 9 Stock Clerk
cl
0000220208447F54A9ED5D676AE03408002072C15B447F54A9ED55676AE03408
ra
002072C15B
O 795
......................................................................................................................................................
B-44 Oracle iDS Forms: Build Internet Applications II
Oracle8i Objects: Types, Tables
.....................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II B-45
Appendix B: Table Descriptions and Data
.....................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
B-46 Oracle iDS Forms: Build Internet Applications II
................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix C: Mouse Movement Events
.....................................................................................................................................................
Introduction
Overview
You have already seen how to use mouse action triggers and built-ins. This appendix
explains how to develop drag-and-drop functionality with Client Server forms
applications.
Objectives
After completing this appendix, you should be able to implement drag-and-drop
functionality with Client Server forms.
Item-A highlighted
Items repositioned
nly
Copyright Oracle Corporation, 2001. All rights reserved.
e O ®
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
C-2 Oracle iDS Forms: Build Internet Applications II
Introduction
.....................................................................................................................................................
Notes Page
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II C-3
Appendix C: Mouse Movement Events
.....................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
C-4 Oracle iDS Forms: Build Internet Applications II
Drag and Drop
.....................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II C-5
Appendix C: Mouse Movement Events
.....................................................................................................................................................
Summary
In this Appendix, you should have learned how to implement drag-and-drop
functionality in your Client Server form applications by using appropriate mouse
triggers and system variables.
Mouse Triggers
• When_Mouse_Move
• When_Mouse_Up
• When_Mouse_Down
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
C-6 Oracle iDS Forms: Build Internet Applications II
................................
Introduction to
Oracle8i Object Features
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
In this appendix you will review certain object features of Oracle8i. This appendix
also explains how these objects are displayed in the Object Navigator.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-3
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
• NCHAR
• NVARCHAR2
• FLOAT
• NLS types
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-4 Oracle iDS Forms: Build Internet Applications II
New Oracle8i Data Types
......................................................................................................................................................
NLS Types
Oracle8i offers extended National Language Support (NLS) including national
character sets and the data types NCHAR and NVARCHAR2, which store NLS data.
With NLS, number and date formats adapt automatically to the language conventions
specified for a user session. Thus, users around the world can interact with the Oracle
Database Server in their native languages. NLS is discussed in Oracle8i Server
ly
Reference Manual.
On
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-5
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Object Types
Attributes
ORDER
po_no
custinfo
line_items
amount
Methods
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-6 Oracle iDS Forms: Build Internet Applications II
Object Types
......................................................................................................................................................
Object Types
An object type is a user-defined composite data type. You build object types from
predefined data types or from previously defined object types. When you create an
object type you specify the component types from which it is built. You also specify
the functions and procedures that can act on the object type. Thus, an object type is in
some ways similar to a record type, and in some ways similar to a package.
An object type must have one or more attributes and can contain methods.
nly
O
Object types are like record types in another sense: Both of them must be declared as
types before the actual object or record can be declared.
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-7
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Object Types
Ship
ORDER
Check Cancel
status
Hold
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-8 Oracle iDS Forms: Build Internet Applications II
Object Types
......................................................................................................................................................
Methods An object type is also similar to a package. Once an object is declared, its
attributes are similar to package variables. Like packages, object types can contain
procedures and functions. In object types, these subprograms are known as methods.
A method describes the behavior of an object type.
Like packages, object types can be declared in two parts: a specification and a body.
Like package variables, attributes declared in the object type specification are public
and those declared in the body are private. As with package subprograms, all methods
are defined in the package body, but only those whose specification appears in the
object type specification are public methods.
Here is an example of an object type:
CREATE TYPE dept_type AS OBJECT
(dept_idNUMBER(2),
dnameVARCHAR2(14),
loc VARCHAR2(3),
MEMBER PROCEDURE set_dept_id (d_id NUMBER),
PRAGMA RESTRICT_REFERENCES (set_dept_id,
RNDS,WNDS,RNPS,WNPS),
MEMBER FUNCTION get_dept_id RETURN NUMBER,
PRAGMA RESTRICT_REFERENCES (get_dept_id,
RNDS,WNDS,RNPS,WNPS));
CREATE TYPE BODY dept_type AS
MEMBER PROCEDURE set_dept_id (d_id NUMBER)
IS
ly
BEGIN
dept_id := d_id;
END;
On
MEMBER FUNCTION get_dept_id
se
U
RETURN NUMBER
IS
BEGIN
AI
RETURN (dept_id);
& O
l
END;
END;
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-9
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Object Tables
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-10 Oracle iDS Forms: Build Internet Applications II
Creating Oracle8i Objects
......................................................................................................................................................
Object Tables
One way to create an object is to create a table whose rows are objects of that object
type.
Here is an example of an object table declaration:
CREATE TABLE o_dept OF dept_type;
SQL and PL/SQL treat object tables very similarly to relational tables, with the
attribute of the object corresponding to the columns of the table, but there are
significant differences. The most important difference is that rows in an object table
are assigned object IDs (OIDs) and can be referenced by using a REF type.
Note: REF types are reviewed later.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-11
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Object Columns
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-12 Oracle iDS Forms: Build Internet Applications II
Object Columns
......................................................................................................................................................
Object Columns
Another construct that you can base on an object type is an object column in a
relational table. Here is an example of a relational table creation statement with an
object column:
CREATE TABLE o_customer (
custid NUMBER (6) NOT NULL,
name VARCHAR2 (45),
repid NUMBER (4) NOT NULL,
creditlimit NUMBER (9,2),
address address_type,
phone phone_type);
In the object table, the rows of a table are objects. In a relational table with an object
column, the column is an object. The table will usually have standard columns, as well
as one or more object column.
Object columns are not assigned object IDs (OIDs), and therefore cannot be
referenced by using object REF values.
Note: Object REFs are reviewed later in this section.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-13
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Object Views
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-14 Oracle iDS Forms: Build Internet Applications II
Object Views
......................................................................................................................................................
Object Views
Often the most difficult part of adopting a new technology is the conversion process
itself. For example, a large enterprise might have several applications accessing the
same data stored in relational tables. If such an enterprise decided to start using object-
relational technology, it would not convert all of the applications at once, but would
convert the applications one at a time.
This presents a problem. The applications that have been converted need the data
stored as objects, while the applications that have not been converted need the data
stored in relational tables.
This dilemma is addressed by object views. Like all views, an object view transforms
the way a table appears to a user, without changing the actual structure of the table.
Object views make relational tables look like object tables. This enables developers to
postpone converting the data from relational structures to object-relational structures
until after all of the applications have been converted. During the conversion process,
the object-relational applications can operate against the object view, while the
relational applications can continue to operate against the relational tables.
Objects accessed through object views are assigned Object IDs (OIDs) and can be
referenced by using Object REFs.
Note: Object REFs are reviewed later in this section.
Here is an example of an object view creation statement:
CREATE VIEW emp_view OF emp_type
WITH OBJECT OID (eno)
AS
SELECT e.empno, e.ename, e.sal, e.job
FROM emp e;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-15
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
INSTEAD-OF Triggers
DECLARE
BEGIN
EXCEPTION
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-16 Oracle iDS Forms: Build Internet Applications II
INSTEAD-OF Triggers
......................................................................................................................................................
INSTEAD-OF Triggers
INSTEAD-OF triggers provide a transparent way of modifying views that cannot be
modified directly through SQL DML statements (INSERT, UPDATE, and DELETE).
These triggers are called INSTEAD-OF triggers because, unlike other types of
triggers, Oracle fires the trigger instead of executing the triggering statement. The
trigger performs update, insert, or delete operations directly on the underlying tables.
Users write normal INSERT, DELETE, and UPDATE statements against the view, and
the INSTEAD-OF trigger works invisibly in the background to make the right actions
take place.
INSTEAD-OF triggers are activated for each row.
Note: Although you can use INSTEAD-OF triggers with any view, they are typically
required with object views.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-17
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
References to Objects
OID
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-18 Oracle iDS Forms: Build Internet Applications II
Referencing Objects
......................................................................................................................................................
Referencing Objects
Introduction
In relational databases, primary-key values are used to uniquely identify records. In
object-relational databases, OIDs provide an alternate method.
When a row in an object table or object view is created, it is assigned automatically a
unique identifier called an object ID (OID).
Object REFs
With relational tables, you can associate two records by storing the primary key of one
record in one of the columns (the foreign-key column) of another.
In a similar way, you can associate a row in a relational table to an object by storing
the OID of an object in a column of a relational table.
Or you can associate two objects by storing the OID of one object in an attribute of
another.
The stored copy of the OID then becomes a pointer, or reference (REF), to the original
object.
The attribute or column that holds the OID is of data type REF.
Note: Object columns are not assigned OIDs and cannot be pointed to by a REF.
Here is an example of a table declaration that includes a column with a REF data type:
CREATE TABLE o_emp
( empno NUMBER(4) NOT NULL,
ename VARCHAR2(10),
job VARCHAR2(10),
mgr NUMBER(4),
ly
hiredate DATE,
n
sal NUMBER(7,2),
comm
dept
NUMBER(7,2),
REF dept_type SCOPE IS o_dept) ;
e O
Us
Note: The REF is scoped here to restrict the reference to a single table, o_dept. The
I
object itself is not stored in the table; only the OID value for the object is stored there.
A
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-19
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
D-20 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................
Object Types
Both the attributes and the methods are listed under each type. Additionally, the nested
types within address_and_phone_type are displayed in an indented sublevel.
This convention is used for nested object and object type displays throughout Oracle
Forms Developer.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-21
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
D-22 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................
Object Tables
Object tables are displayed like relational tables, with the attributes of the object
displayed like columns in a relational table. Additionally, the object table type name is
displayed in parentheses after the name of the object table.
Object Columns
Object columns are displayed with the object type in parentheses after the column
name, and with the attributes of the type indented underneath the column name.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-23
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
D-24 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................
Object Views
Object views are displayed like any other view, except that the object type they are
based on is written in parentheses after the view name.
INSTEAD-OF Triggers
You can create INSTEAD-OF database triggers through the trigger creation dialog
box, just as you would any other database trigger.
INSTEAD-OF INSERT, UPDATE, and DELETE triggers allow you to directly insert,
update, and delete against object views. They can also be used with any other type of
view that does not allow direct DML.
When a view has an INSTEAD-OF trigger, the code in the trigger is executed in place
of the triggering DML code.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-25
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-26 Oracle iDS Forms: Build Internet Applications II
Displaying Oracle8i Objects in the Object Navigator
......................................................................................................................................................
Object REFs
Object types that contain attributes of type REF, and relational tables that have
columns of type REF, display the keyword REF before the name of the object type that
is being referenced.
The attributes of the referenced object type are displayed indented underneath the
column or attribute.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-27
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
Summary
Summary
I U
OA
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
D-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
New Oracle8i Data Types
Oracle8i introduced three new scalar data types and new composite data types such as
object types.
Objects
Three kinds of objects are object tables, object columns, and object views.
INSTEAD-OF triggers allow DML on object views.
Object REFs store the Object Identifier of certain types of objects.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II D-29
Appendix D: Introduction to Oracle8i Object Features
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
D-30 Oracle iDS Forms: Build Internet Applications II
................................
Menu Run-Time
Parameters
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
E-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
In this lesson, you will learn how to modify menus dynamically, as well as
how to control application security through menu access.
Objectives
After completing this lesson, you should be able to customize menu modules
by using substitution parameters.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-3
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
UN Current username
PW Current password
AD Directory name
TT Terminal type
LN Language used
nly
e O
Us
AI
Design time Run time
& O
al
n
®
r
Copyright Oracle Corporation, 2001. All rights reserved.
nte
e I
cl
ra
O
......................................................................................................................................................
E-4 Oracle iDS Forms: Build Internet Applications II
Substitution Parameters
......................................................................................................................................................
Substitution Parameters
What Is a Substitution Parameter?
A substitution parameter is a two-character variable of type CHAR that is
referenced in a menu item command or in a PL/SQL program unit, and
substituted with a value at run time. A menu module provides some
predefined parameters, which automatically exist in every menu module.
You can also create in Form Builder (valid for a given menu module) your
own user-named parameters.
ly
through built-in procedures.
Note: Substitution parameter values can be referenced in triggers and user-
On
e
defined subprograms.
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-5
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
Parameter Properties
- Name
- Label
- Maximum Length
- Case Restriction
- Menu Parameter
- Conceal Data Initial Value
- Associated Menus - Required
- Hint
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
E-6 Oracle iDS Forms: Build Internet Applications II
Defining a User-Named Substitution Parameter
......................................................................................................................................................
Property Description
Name The two-letter parameter name
Label The text prompt for the parameter value that is displayed in
the Enter Parameter Values dialog box
Case Restriction The property that converts the case of the user’s input to
either uppercase, lowercase, or none
Conceal Data The property that determines whether the user’s input is ech-
oed on the screen
Associated Menus All menu names where the parameter can be used (full-screen
menus only)
Maximum Length Value maximum length
Menu Parameter Initial Value The default value for the parameter; displayed in the parame-
ter value field when the Enter Parameter Values dialog box is
displayed
ly
Required Mandatory or not; set Yes if the value is required or No to
n
allow the parameter value to be set to Null
Hint
O
The text string displayed on the message line of the console
e
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-7
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
• QUERY_PARAMETER
• APPLICATION_PARAMETER
nly
O
– Prefix the parameter name with &
e
when entered through a dialog box
– Prefix the parameter name with :
Us
I
when entered in the PL/SQL editor
– Example: :param_name
OA
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
E-8 Oracle iDS Forms: Build Internet Applications II
Substitution Parameter Built-ins
......................................................................................................................................................
Example
This example invokes SQL*Plus and runs a command file (CF parameter).
ly
PLUS80W &UN/&PW @&CF
AI
Example
& O
l
This example invokes Report Builder and enables the user to provide the
report name.
rna
te
Query_Parameter(’&RN’);
n
Run_Product(reports, :RN, synchronous, runtime, filesystem, pl_id,
e I
null);
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-9
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
Validating Substitution
Parameter Values
MENU_SUCCESS function:
• Returns TRUE if the user does not cancel
the Enter Parameter Values dialog box
• Is used in a WHILE loop
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
E-10 Oracle iDS Forms: Build Internet Applications II
Validating a Substitution Parameter Value
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-11
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
E-12 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
Substitution Parameters
• Using &UN, &PW, &AD, &SO, &TT, and &LN
• Creating user-named substitution parameters
• Programmatically controlling substitution parameters with
QUERY_PARAMETER and APPLICATION_PARAMETER
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II E-13
Appendix E: Menu Run-Time Parameters
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
E-14 Oracle iDS Forms: Build Internet Applications II
................................
Handling Server-
SideErrors
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
F-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
This lesson covers the use of Oracle server features in Form Builder
applications. You will learn about handling Oracle server errors, including
declarative-constraint violations.
Objectives
At the end of this lesson, you should be able to:
• Handle errors raised by the Oracle server
• Obtain the cause of declarative-constraint violations
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-3
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
F-4 Oracle iDS Forms: Build Internet Applications II
Obtaining the Cause of Declarative-Constraint Violations
......................................................................................................................................................
ly
RETURN(SUBSTR(p_error_text, v_start_pos + 1,v_end_pos -
n
v_start_pos - 1));
O
END;
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-5
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
nly
O
• Replacing stored-program-unit error messages:
– Same as for database triggers, except
se
U
SQLERRM only
AI
& O
al
rn
®
nte
I
Technical Note
le
A foreign-key constraint violation can have two causes: “parent key not
c
found” or “child record found.” Therefore, two error messages are
ra
associated with one foreign-key constraint name.
......................................................................................................................................................
F-6 Oracle iDS Forms: Build Internet Applications II
Customizing Oracle Server Error Messages
......................................................................................................................................................
ly
RETURN(SUBSTR(p_error_text, 12));
n
END IF;
O
END;
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-7
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
F-8 Oracle iDS Forms: Build Internet Applications II
Example Procedure for Handling Oracle Server Errors
......................................................................................................................................................
ly
STRIP_APPLICATION_ERROR functions have already been shown earlier
n
in this lesson. The RETRIEVE_MESSAGE function retrieves a message
with a given ID from a messages table.
e O
s
Call the HANDLE_SERVER_ERROR procedure from the appropriate
triggers and program units.
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-9
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
Technical Note
Error code 40508 is insert failed. Error code 40509 is update failed. Error
code 40510 is delete failed.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
F-10 Oracle iDS Forms: Build Internet Applications II
Example Procedure for Handling Oracle Server Errors
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-11
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
F-12 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
Handling Errors Raised by the Oracle Server
• Causes: Declarative constraints, database triggers, stored program units
• Trap implicit-DML errors by using DBMS_ERROR_CODE and
DBMS_ERROR_TEXT in an On-Error trigger
• Trap explicit DML errors and stored program unit errors by using
SQLCODE and SQLERRM in a WHEN OTHERS exception handler
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II F-13
Appendix F: Handling Server-SideErrors
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
F-14 Oracle iDS Forms: Build Internet Applications II
................................
EMP_PKG Package
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix G: EMP_PKG Package
......................................................................................................................................................
Package Specification
/*******************************************************/
/* This is an example of a stored procedure that: */
/* query, insert, update, delete, and lock rows of the */
/* EMP table. */
/* A package is used to logically group the related */
/* data types and procedures */
/*******************************************************/
PACKAGE emp_pkg AS
nly
--- Define the Ref Cursor
e O
TYPE empcur IS REF CURSOR RETURN emprec;
Us
AI
O
--- Defines the Table of Records EMP
TYPE emptab IS TABLE OF emprec INDEX BY BINARY_INTEGER;
l &
rna
--- Defines the Table of Records EMP.EMPNO
nte
TYPE empnotab IS TABLE OF empnorec INDEX BY BINARY_INTEGER;
e I
cl
ra
O
......................................................................................................................................................
G-2 Oracle iDS Forms: Build Internet Applications II
Package Specification
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-3
Appendix G: EMP_PKG Package
......................................................................................................................................................
Package Body
PACKAGE BODY emp_pkg AS
/**************************/
/* QUERY USING REF CURSOR */
/**************************/
PROCEDURE empquery_refcur( block_data IN OUT empcur,
p_deptno IN NUMBER)
IS
BEGIN
OPEN block_data FOR
SELECT empno, ename, job, mgr, hiredate, sal, comm, deptno
FROM emp
WHERE deptno = NVL(p_deptno, deptno)
ORDER BY empno;
END;
. . .
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
G-4 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................
/********************************/
/* QUERY USING TABLE OF RECORDS */
/********************************/
PROCEDURE empquery( block_data IN OUT emptab,
p_deptno IN NUMBER)
IS
i NUMBER;
CURSOR empselect IS
SELECT empno, ename, job, mgr, hiredate,
sal, comm, deptno
FROM emp
WHERE deptno = NVL(p_deptno, deptno)
ORDER BY empno;
BEGIN
OPEN empselect;
i := 1;
LOOP
FETCH empselect INTO block_data(i).empno,
block_data(i).ename,
block_data(i).job,
block_data(i).mgr,
block_data(i).hiredate,
ly
block_data(i).sal,
block_data(i).comm,
On
e
block_data(i).deptno;
EXIT WHEN empselect%NOTFOUND;
Us
i := i + 1;
AI
O
END LOOP;
&
END;
. . .
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-5
Appendix G: EMP_PKG Package
......................................................................................................................................................
/**********/
/* INSERT */
/**********/
PROCEDURE empinsert(block_data IN emptab)
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
INSERT INTO emp( empno, ename, job, mgr,
hiredate, sal, comm, deptno)
VALUES( block_data(i).empno, block_data(i).ename,
block_data(i).job, block_data(i).mgr,
block_data(i).hiredate, block_data(i).sal,
block_data(i).comm, block_data(i).deptno);
END LOOP;
END;
. . .
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
G-6 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................
/**********/
/* UPDATE */
/**********/
PROCEDURE empupdate(block_data IN emptab)
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
UPDATE emp
SET ename = block_data(i).ename,
job = block_data(i).job,
mgr = block_data(i).mgr,
hiredate = block_data(i).hiredate,
sal = block_data(i).sal,
comm = block_data(i).comm,
deptno = block_data(i).deptno
WHERE empno = block_data(i).empno;
END LOOP;
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-7
Appendix G: EMP_PKG Package
......................................................................................................................................................
/**********/
/* DELETE */
/**********/
PROCEDURE empdelete(block_data IN empnotab)
IS
i NUMBER;
cnt NUMBER;
BEGIN
cnt := block_data.count;
FOR i IN 1..cnt
LOOP
DELETE FROM emp WHERE empno = block_data(i).empno;
END LOOP;
END;
/********/
/* LOCK */
/********/
PROCEDURE emplock(block_data IN empnotab)
IS
i NUMBER;
cnt NUMBER;
block_rec emprec;
ly
BEGIN
cnt := block_data.count;
On
e
FOR i IN 1..cnt
LOOP
Us
SELECT empno, ename, job, mgr,
AI
O
hiredate, sal, comm, deptno
&
INTO block_rec
al
FROM emp
rn
WHERE empno = block_data(i).empno
e
t
FOR UPDATE OF ename NOWAIT;
In
END LOOP;
cle
END;
ra
END;
......................................................................................................................................................
G-8 Oracle iDS Forms: Build Internet Applications II
Package Body
......................................................................................................................................................
To have an idea of how Form Builder works when a data block is based on a
stored procedure returning a REF CURSOR, you can run the following
script under Sql*Plus:
DECLARE
v_rec emp_pkg.emprec;
v_ref emp_pkg.empcur;
BEGIN
emp_pkg.emp_query_refcur(v_ref, 10);
LOOP
FETCH v_ref INTO v_rec;
EXIT WHEN v_ref%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(v_rec.empno);
DBMS_OUTPUT.PUT_LINE(v_rec.ename);
DBMS_OUTPUT.PUT_LINE(v_rec.job);
DBMS_OUTPUT.PUT_LINE(v_rec.mgr);
DBMS_OUTPUT.PUT_LINE(v_rec.hiredate);
DBMS_OUTPUT.PUT_LINE(v_rec.sal);
DBMS_OUTPUT.PUT_LINE(v_rec.comm);
DBMS_OUTPUT.PUT_LINE(v_rec.deptno);
END LOOP;
CLOSE v_ref;
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II G-9
Appendix G: EMP_PKG Package
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
G-10 Oracle iDS Forms: Build Internet Applications II
................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
Objectives
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-2 Oracle iDS Forms: Build Internet Applications II
Introduction
......................................................................................................................................................
Introduction
Overview
In this appendix, you will learn how to include and use ActiveX controls in
your Oracle Forms Developer application.
Objectives
After completing this lesson, you should be able to do the following:
• Explain the differences between VBX, OCX, and ActiveX controls
• Access ActiveX properties at design time and run time
• Import ActiveX control methods and events packages
• Customize event handling
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-3
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-4 Oracle iDS Forms: Build Internet Applications II
What Are VBX, OCX, and ActiveX Controls?
......................................................................................................................................................
What Is a VBX?
Short for Visual Basic custom control, a VBX is a reusable software
component designed for use in many different applications. While VBXs
can be used in other environments, they were initially created for developing
Windows applications with Visual Basic. An application developer can use a
number of selected VBXs to quickly develop an application.
What Is an OCX?
Short for OLE Custom control, an OCX is an independent program module
that can be accessed by other programs in a Windows environment. OCX
controls end with the .ocx extension. OCX controls represent Microsoft’s
second generation of control architecture, the first being VBX controls
ly
written in Visual Basic.
What Is an ActiveX?
On
ActiveX controls are a superset of OLE Custom control (OCX). ActiveX is
se
an open platform that combines desktop and Web technologies. An ActiveX
I U
A
control can be automatically downloaded and executed by a Web browser.
O
ActiveX is not a programming language, but rather a set of rules for how
&
applications should share information. Programmers can develop ActiveX
al
controls in a variety of languages, including C, C++, Visual Basic, and Java.
rn
They represent Microsoft’s third generation of control architecture, the first
e
t
being VBX controls and the second OCX controls.
In
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-5
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
Web- No No Yes
enabled
®
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-6 Oracle iDS Forms: Build Internet Applications II
Comparison of VBX, OCX, and ActiveX Controls
......................................................................................................................................................
ly
applications to VBXs
Coding
Proprietary Standard OLE2
On Standard OLE2
e
interface
No No
Us Yes
I
Web-enabled
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-7
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
• ActiveX controls:
– Dynamic library in .ocx files
– Support events, properties, and methods
• ActiveX control item:
– Container for the ActiveX control
– Single-record property set to Yes
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-8 Oracle iDS Forms: Build Internet Applications II
ActiveX in Form Builder
......................................................................................................................................................
e
multiple record blocks.You should set the Single Record property to Yes
because single records are immediately initialized when Forms run time
Us
I
starts up. For multiple records, each record is not initialized until you
navigate to the record. Without initialization, the ActiveX Control Item is
empty, giving the impression that no ActiveX control is available.
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-9
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
Creating an ActiveX
Control Item
nly
e O
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
H-10 Oracle iDS Forms: Build Internet Applications II
Implementing an ActiveX Control
......................................................................................................................................................
ly
4 Double-click the ActiveX control item.
The Properties Palette is displayed for the item.
On
e
5 Set the item properties as required.
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-11
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
nly
e O
OLE
OLE Class
Class
Us
I
Control
Control Properties
Properties
About
About Control
Control
OA
&
Control
Control Help
Help
al
rn
®
Technical Note
nte
e I
l
If you have created a container using the OCX button from the Layout
rac
Editor, then Create Control is the only available option on the Insert Object
dialog box.
......................................................................................................................................................
H-12 Oracle iDS Forms: Build Internet Applications II
Inserting an ActiveX Control in an ActiveX Control Item
......................................................................................................................................................
n
might not be exposed by the control that you are using.)
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-13
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
2 6
- Program Units
+ PackageName1 (Spec)
3 + PackageName1 (Body)
+ ...
4 5
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-14 Oracle iDS Forms: Build Internet Applications II
Importing ActiveX Control Methods and Events Packages
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-15
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
Three methods:
• Bind variable Syntax
ly
:Item(′item_name’).OCX.server_name.property
:Item( ′item_name’).OCX.server_name.property
On
e
Example
:item(′ActXitem’).OCX.Spindial.spindialctrl
Us
I
:item( ′ActXitem’).OCX.Spindial.spindialctrl
A
.1.Needleposition:=:item(’ActXitem’).OCX.
.1.Needleposition:=:item(’ActXitem’).OCX.
Spindial.spindialctrl.1.Needleposition
Spindial.spindialctrl.1.Needleposition
& O
l
++ 1;
1;
nte
e I
cl
ra
O
......................................................................................................................................................
H-16 Oracle iDS Forms: Build Internet Applications II
Setting and Getting ActiveX Control Properties
......................................................................................................................................................
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-17
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
tblname varchar2;
tblname := table_pkg.TableName(
:item(’Oblk.Oitm’).interface);
ly
properties
n
– See Control
O
Help property
e
or
documentation
Us
AI
& O
al
rn
®
nte
e I
cl
ra
O
......................................................................................................................................................
H-18 Oracle iDS Forms: Build Internet Applications II
Setting and Getting ActiveX Control Properties
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-19
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
MMVX_DMMVX.PLAY(:item
MMVX_DMMVX.PLAY(:item
((′video_ocx.video
′video_ocx.video′).INTERFACE);
′).INTERFACE);
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-20 Oracle iDS Forms: Build Internet Applications II
Invoking ActiveX Control Methods
......................................................................................................................................................
Example
/* Getting a cell value from a Spread Table ActiveX control
using the GetCellByColRow method provided in the
SpreadTable package */
DECLARE
Cur_Row number;
Cur_Col number;
OLEObj OleObj;
BEGIN
Cur_Row:=SpreadTable.CurrentRow(:ITEM(’BLK.ITM’).interface);
Cur_Col:=SpreadTable.CurrentCol(:ITEM(’BLK.ITM’).interface);
OLEObj:=SpreadTable.GetCellByColRow(:ITEM(’BLK.ITM’).interface,
Cur_Col, Cur_Row);
END;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-21
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
FORMS4W.DISPATCH_EVENT
nly
(RESTRICTED_UNALLOWED);
e O
Initialization events do not fire.
Us
• Use the When-New-Item-Instance or
AI
O
When-New-Record-Instance triggers in place.
l &
rna Copyright Oracle Corporation, 2001. All rights reserved.
®
nte
e I
cl
ra
O
......................................................................................................................................................
H-22 Oracle iDS Forms: Build Internet Applications II
Responding to ActiveX Control Events
......................................................................................................................................................
ly
There is no need to explicitly call the event procedure because it will
automatically be called following the On-Dispatch trigger code.
On
Initialization Events
se
Initialization events for ActiveX controls do not fire in Forms run time.
I U
A
These initialization events are intentionally disabled. Instead, you can use
O
When-New-Item-Instance or When-New-Record-Instance triggers in place
&
of the control’s native initialization events.
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-23
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
Handling Exceptions
. . .
WHEN FORMS_OLE_FAILURE THEN
ExceptNum :=LAST_OLE_EXCEPTION(errScr,
errDescription, errHelpfile,
errHelpContext);
. . .
Technical Note
The LAST_OLE_EXCEPTION built-in takes variables, not constants.
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-24 Oracle iDS Forms: Build Internet Applications II
Handling Exceptions
......................................................................................................................................................
Handling Exceptions
FORMS_OLE_FAILURE Exception
When a failure is detected in handling an ActiveX control method, an FRM
message appears or the FORMS_OLE_FAILURE exception is raised. When
a FORMS_OLE_FAILURE exception is raised, you can get more detailed
information regarding the cause of the exception by calling the
LAST_OLE_EXCEPTION built-in.
/*
Handling the exception raised as a result of calling:
Var_To_Number(To_Variant(’Jane’));
An exception is raised because Jane is not a number.
*/
DECLARE
errCode PLS_INTEGER;
errSrc VARCHAR2(200);
errDescription VARCHAR2(2000);
errHelpfile VARCHAR2(200);
errHelpContext PLS_INTEGER;
BEGIN
. . .
WHEN form_ole_failure THEN
errCode := LAST_OLE_EXCEPTION(errSrc,
errDescription,
ly
errHelpfile,
errHelpContext);
-- Inform the user of the problem
On
MESSAGE(errSrc||’;’||errDescription);
se
END;
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-25
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-26 Oracle iDS Forms: Build Internet Applications II
Registering an ActiveX Control
......................................................................................................................................................
Supporting Files
Most ActiveX controls require a supporting DLL, such as the Microsoft
Foundation Class run-time library, mfc40.dll. The DLL must be in the
\WINDOWS\SYSTEM directory or in the search path. If the DLL is out of
date or missing, your ActiveX control will not register properly. Most
reputable ActiveX control suppliers provide documentation regarding the
version and name of the DLLs required; some even supply and install them
along with the ActiveX controls.
se
I U
OA
l &
rna
nte
e I
cl
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-27
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
.
Summary
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-28 Oracle iDS Forms: Build Internet Applications II
Summary
......................................................................................................................................................
Summary
In this lesson, you saw how to include and use ActiveX controls in your
Oracle Developer application.
• VBX, OCX, and ActiveX controls
• Differences between controls
• ActiveX control in Form Builder
• Create an ActiveX control
• Set and get ActiveX control properties
• Invoke ActiveX control methods
• Respond to ActiveX control events
• Register an ActiveX control
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II H-29
Appendix H: Working with ActiveX Controls
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
H-30 Oracle iDS Forms: Build Internet Applications II
................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................
• SESSION_ROLES
• ROLE_ROLE_PRIVS
• ROLE_SYS_PRIVS
• ROLE_TAB_PRIVS
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
I-2 Oracle iDS Forms: Build Internet Applications II
Using Oracle Server Roles at Run Time
......................................................................................................................................................
SESSION_ROLES View
Roles that the user currently has enabled
Column Description
ROLE Name of the role
ROLE_ROLE_PRIVS View
Information about roles granted to other roles
Column Description
ROLE Name of the role
GRANTED_ROLE Role that was granted
ADMIN_OPTION Subprogram that signifies that the role was granted with the ADMIN
option
ROLE_SYS_PRIVS View
ly
Information about system privileges granted to roles
Column Description
On
e
ROLE Name of the role
PRIVILEGES System privileges granted to the role
Us
ADMIN_OPTION
I
Column that signifies the grant was with the ADMIN option
A
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-3
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................
• SESSION_ROLES
• ROLE_ROLE_PRIVS
• ROLE_SYS_PRIVS
• ROLE_TAB_PRIVS
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
I-4 Oracle iDS Forms: Build Internet Applications II
Using Oracle Server Roles at Run Time
......................................................................................................................................................
ROLE_TAB_PRIVS View
Information about table privileges granted to roles.
Column Description
ROLE Name of the role
OWNER Owner of the object
TABLE_NAME Name of the object
COLUMN_NAME Name of the column, if applicable
PRIVILEGE Object privilege granted to the role
GRANTABLE YES if the role was granted with the ADMIN option, otherwise NO
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-5
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................
• DBMS_SESSION.SET_ROLE
• DBMS_SESSION.IS_ROLE_ENABLED
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
I-6 Oracle iDS Forms: Build Internet Applications II
Procedures for Managing Roles
......................................................................................................................................................
Example
The following Pre-Form trigger uses the DBMS_SESSION package to test a
user’s role before allowing access to the application.
IF not (DBMS_SESSION.IS_ROLE_ENABLED(’ADMINISTRATIVE’) or
(DBMS_SESSION.IS_ROLE_ENABLED(’TECHNICAL’)
THEN
MESSAGE(’You are not authorized to run this application’);
PAUSE;
RAISE form_trigger_failure;
END IF;
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
Oracle iDS Forms: Build Internet Applications II I-7
Appendix I: Using Oracle Server Roles at Run Time
......................................................................................................................................................
nly
e O
Us
AI
& O
al
ern
Int
cle
ra
O
......................................................................................................................................................
I-8 Oracle iDS Forms: Build Internet Applications II