Вы находитесь на странице: 1из 139

Oracle9i Developer Suite

A Tutorial on Oracle9i Forms and Reports


Covering Developer version 9i for Windows NT/!!!/"#
Ric$ard %olowc&a'
Tutorial Version 5.2 - 1:11 PM 8/16/2011
Please feel free to use these tutorials for your own personal use, education, advancement,
training, etc. However, I kindly ask that you respect the time and effort I have put into this work by
not distributing copies, either in whole or in part, for your personal gain. You may not under any
circumstances download, cache or host copies of these tutorials on your own servers. Use of
these tutorials for commercial training requires a special arrangement with the author or authors.
Contents
1. Introduction
2. Prerequisites
3. Developer Tools
o 3.1 Starting Developer tools under Windows
4. The Oracle or!s "uilder #ain Screen
o 4.1 Oracle or!s O$%ect &avigator
o 4.2 'onnecting to the Data$ase
(. or!s Design
). 'reating a or! with a Single "loc*
o ).1 'reating a &ew "loc*
o ).2 The +a,out -ditor
o ).3 Displa,ing Properties
o ).4 Saving. /enerating and 0unning or!s
).4.1 Saving a or!
).4.2 'o!piling1"uilding a or!
).4.3 0unning a or!
).4.4 2uer, ", -3a!ple
o ).( -3ercise4 'reating a Single "loc* or!
5. 'reating a #aster6Detail or!
o 5.1 The #aster6Detail 0elationship
o 5.2 Steps to 'reate a #aster6Detail or!
5.2.1 'reate the #aster "loc*
5.2.2 'reate the Detail "loc*
o 5.3 0elation Properties o7 a #aster6Detail or!
o 5.4 Progra! 8nits in a #aster6Detail or!
o 5.( -3tending #aster6Detail or!s
o 5.) -3ercise4 'reating a #aster1Detail or!
9. +ist o7 :alues ;+O:s< and &on6"ase Ta$le ields
o 9.1 'reating a +ist o7 :alues
9.1.1 'reate a new +O: O$%ect
9.1.2 Speci7, the +O: 2uer, Te3t
9.1.3 Speci7, the 'olu!n #apping Properties
9.1.4 =ttach the +O: to the ite!
9.1.( Test the +O:
o 9.2 &on6"ase Ta$le 7ields
9.2.1 =dding a &ew Ite! to an -3isting Data
"loc*
9.2.2 'reating a Trigger
9.2.3 'reate a new +ist o7 :alues
o 9.3 -3ercise4 'reating an +O: and &on6"ase Ta$le
7ield
>. Oracle or!s Progra! 8nits and Stored Progra! 8nits
o >.1 'reating Procedures in Oracle or!s
>.1.1 =dd a new ite! to the -#P+O?-- "loc*
>.1.2 'reate a Procedure to 'ount Other
Depart!ent #e!$ers
>.1.3 'reate a Trigger to 'all the Procedure
>.1.4 Save. 'o!pile and 0un the or!
o >.2 'reating Stored Progra! 8nits ;Procedures< in
S2+@Plus
o >.3 =dditional Stored Procedures and Triggers
>.3.1 /enerating unique or consecutive
identi7iers using the ta$le
>.3.2 /enerating unique or consecutive
identi7iers using an Oracle Sequence
>.3.3 'hec*ing constraints at the client
>.3.4 =dding =lerts ;Pop6up #essages<
>.3.( =uto!atic or!s 2uer,
>.3.) Populate ite!s with de7ault values
>.3.5 =ttaching 7unctionalit, to co!!and
$uttons
>.3.9 Passing para!eters $etween 7or!s
o >.4 -3ercise4 Procedures and Triggers
1A. Oracle 0eports "asics
o 1A.1 Starting Developer tools under Windows
o 1A.2 The Oracle 0eports O$%ect &avigator
o 1A.3 'reating 0eports in Oracle 0eports
o 1A.4 'reating a Single6Ta$le 0eport
1A.4.1 Speci7, the Data #odel and +a,out
1A.4.2 Saving. /enerating and 0unning the
0eport
o 1A.( -3ercise4 'reating a 0eport
o 1A.) 'reating a #aster6Detail 0eport
1A.).1 Speci7, the #aster6Detail Data #odel
and +a,out
1A.).2 Saving and 0unning the #aster6Detail
0eport
o 1A.5 -3ercise4 'reating a #aster6Detail 0eport
o 1A.9 Para!eter 7or!s in Oracle 0eports
1A.9.1 "uilding a 'usto! Para!eter or!
11 'reating #enus in Oracle or!s
o 11.1 The Oracle or!s #enu Bierarch,
o 11.2 'reating a 'usto! #enu
() *ntroduction
This tutorial introduces the Oracle>i Developer Suite 0elease 2 that
includes Oracle or!s >.A and Oracle 0eports >.A. The !ain o$%ectives
are to de!onstrate and provide hands6on instructions on creating and
!odi7,ing data entr, and quer, 7or!s in various con7igurations. reports
and graphics.
'aveats4 Please note that Oracle tends to change things li*e !enu
ite!s. pro!pts and other s!all things $etween each !a%or ;certainl,<
and o7ten !inor release. Depending on the e3act release o7 Oracle>i
Developer Suite ,ou have. ,ou !a, 7ind so!e s!all discrepencies
$etween what is shown in this tutorial and what ,ou see on ,our screen.
) #rere+uisites
"e7ore 7ollowing this tutorial. a student !ust have a valid user account
in an Oracle server or a local installation o7 an Oracle data$ase. 'ontact
,our D"= or s,ste!s ad!inistrator to learn the details o7 how Oracle
server is set up in ,our organiCation.
I7 ,ou have a local instance o7 the Oracle data$ase. please do not use
the S?ST-# ;D"=< account to practice develop!ent. There is a good
chance ,ou can corrupt the entire data$ase $, !ista*e. ?ou are !uch
$etter o77 !a*ing use o7 the S'OTT1TI/-0 sche!a or ;even $etter<
creating a separate user ;sche!a< 7or this tutorial wor* and 7or
practicing.
One !ore word o7 caution. Oracle has designed Oracle>i as a three tier
architecture. This !eans that the data$ase ;Oracle>i server< should run
on one server. the application Server ;oracle>i =pplication Server or
Oracle>i=S 'ontainers 7or Dava ;O'4D< server as used here< runs on a
second server and the client application ;written in Oracle or!s and
0eports 7or e3a!ple< runs on a third !achine. One can get all o7 these
co!ponents to run on the sa!e !achine. $ut it requires $oth a 7ast
processor and a lot o7 0=#. Bere is one e3a!ple4
Service/Application
RA, consumed w$ile
running
Oracel>i Data$ase ;!ini!al instance< 14A #"
Oracle>i or!s "uilder 42 #"
Oracle>i 0eports "uilder 9A #"
Oracle>i or!s 0unti!e we$
launcher
12 #"
O'4D Service ;Dava< 3) #"
&etscape 4.5 running a 7or! 3( #"
Oracle>i S2+@Plus 9 #"
Total -.- ,/
There7ore. having at least (12 #" o7 real 0=# ;not swap space< is a
necessit,. 1 /" o7 0=# will ,ield signi7icantl, $etter per7or!ance. I7
,ou have less than (12 #" o7 0=#. ,ou should create a swap 7ile
;:irtual !e!or,< o7 at least 1 /".
The student should also $e 7a!iliar with OracleEs S2+@Plus tools and
should $e co!7orta$le connecting to a data$ase sche!a. creating
ta$les. inserting and !anipulating data ;with S2+ I&S-0T. 8PD=T-
and D-+-T- state!ents< and with quer,ing ta$le data ;with S2+
S-+-'T state!ents<.
*f 0ou are new to Oracle and are loo'ing for an introduction
to S123#lus please visit t$e S123#lus Tutorial #age)
This tutorial relies on the e3istence o7 a 7ew ta$les in the studentEs
sche!a. 8se the Oracle S2+@Plus tool to create three ta$les
na!ed EMPLOYEE. DEPATME!T and DEPE!DE!T with the 7ollowing
attri$utes. &ote4 This sche!a originall, appears in the $oo*4 0a!eC
-l!asri and Sha!*ant ". &avathe. Fundamentals of Database
Systems. Second -dition. =ddison6Wesle, Pu$ 'o. 1>>4.
D4#ART,4NT Ta$le
Attri5ute Data T0pe
D&=#- :=0'B=0;1(<
D&8#"-0 &8#"-0;2<
#/0SS& &8#"-0;12<
#/0ST=0TD=T- D=T-
D4#4ND4NT Ta$le
Attri5ute Data T0pe
-SS& &8#"-0;12<
D-P-&D-&TF&=#- :=0'B=0;1A<
S-G :=0'B=0;1<
"D=T- D=T-
0-+=TIO&SBIP :=0'B=0;1A<
The 7ollowing '0-=T- T="+- and I&S-0T state!ents can $e used
to create the a$ove ta$les and insert so!e $aseline data using the
Oracle S2+@Plus tool. &ote that di77erent versions o7 Oracle accept
either 2 digit or 4 digit ,ear designations in the D=T- datat,pe. It
4,#2O644 Ta$le
Attri5ute Data T0pe
&=#- :=0'B=0;9<
#I&IT :=0'B=0;2<
+&=#- :=0'B=0;9<
SS& &8#"-0;12<
"D=T- D=T-
=DD0-SS :=0'B=0;3A<
S-G :=0'B=0;1<
S=+=0? &8#"-0;5<
S8P-0SS& &8#"-0;12<
D&O &8#"-0;2<
see!s the latest versions ;Oracle9 and Oracle9i< de7ault to accept 4
digit ,ears. The I&S-0T state!ents $elow should $e 7or!atted
accordingl,.
"EATE TA#LE e$%lo&ee
'(!AME VA")A2'15*+
M,!,T VA")A2'2*+
L!AME VA")A2'15*+
--! !.M#E'12* !OT !.LL+
#DATE DATE+
ADDE-- VA")A2'/5*+
-E0 VA")A2'1*+
-ALAY !.M#E'1* !OT !.LL+
-.PE--! !.M#E'12*+
D!O !.M#E'2* !OT !.LL* 2
ALTE TA#LE e$%lo&ee ADD "O!-TA,!T %34e$%lo&ee
P,MAY 5EY 'ssn*2
"EATE TA#LE DEPATME!T
'D!AME VA")A2'15*+
D!.M#E !.M#E'2* !OT !.LL+
M6--! !.M#E'12*+
M6-TATDATE DATE* 2
ALTE TA#LE 7e%art$ent ADD "O!-TA,!T %347e%art$ent
P,MAY 5EY '7nu$8er*2
"EATE TA#LE DEPE!DE!T
'E--! !.M#E'12*+
DEPE!DE!T4!AME VA")A2'15*+
-E0 VA")A2'1*+
#DATE DATE+
ELAT,O!-),P VA")A2'12** 2
ALTE TA#LE 7e%en7ent ADD "O!-TA,!T %347e%en7ent
P,MAY 5EY 'essn+ 7e%en7ent4na$e*2
ALTE TA#LE 7e%en7ent ADD "O!-TA,!T 934e$%lo&ee
(OE,6! 5EY 'essn* E(EE!"E- e$%lo&ee 'ssn*2
ALTE TA#LE e$%lo&ee ADD "O!-TA,!T 9347e%art$ent
(OE,6! 5EY '7no* E(EE!"E- 7e%art$ent '7nu$8er*2
,!-ET ,!TO DEPATME!T VAL.E- ':E-EA"):+ 5+ ///;;5555+ :22-MAY-
1<18:* 2
,!-ET ,!TO DEPATME!T VAL.E- ':ADM,!,-TAT,O!:+ ;+ <8165;/21+ :01-=A!-
1<85:* 2
,!-ET ,!TO DEPATME!T VAL.E- ':)EAD>.ATE-:+ 1+ 888665555+ :1<-=.!-
1<11:* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':=O)!:+:#:+:-M,T):+12/;5618<+:0<-=A!-1<55:+:1/1 (O!DE!+ )O.-TO!+ T0:+
:M:+/0000+///;;5555+5* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':(A!5L,!:+:T:+:?O!6:+///;;5555+:08-DE"-1<;5:+:6/8 VO--+)O.-TO! T0:+
:M:+;0000+888665555+5* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':AL,",A:+:=:+:@ELAYA:+<<<881111+:1<-=.L-1<58:+://21 "A-TLE+ -P,!6+
T0:+ :(:+25000+<8165;/21+;* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':=E!!,(E:+:-:+:?ALLA"E:+<8165;/21+:20-=.!-1</1:+:2<1 #EY+ #ELLA,E+
T0:+ :(:+;/000+888665555+;* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':AME-):+:5:+:!AAYA!:+66688;;;;+:15--EP-1<52:+:<15 (,E OA5+ ).M#LE+
T0:+ :M:+/8000+///;;5555+5* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':=OY"E:+:A:+:E!6L,-):+;5/;5/;5/+:/1-=.L-1<62:+:56/1 ,"E+ )O.-TO!+ T0:+
:(:+25000+///;;5555+5*2
,!-ET ,!TO EMPLOYEE VAL.E-
':A)MAD:+:V:+:=A##A:+<81<81<81+:2<-MA-1<5<:+:<80 DALLA-+ )O.-TO!+ T0:+
:M:+25000+<8165;/21+;* 2
,!-ET ,!TO EMPLOYEE VAL.E-
':=AME-:+:E:+:#O6:+888665555+:10-!OV-1<21:+ :;50 -TO!E+ )O.-TO!+ T0:+
:M:+55000+!.LL+1* 2
,!-ET ,!TO DEPE!DE!T VAL.E- '///;;5555+:AL,"E:+:(:+:05-AP-
1<16:+:DA.6)TE:* 2
,!-ET ,!TO DEPE!DE!T VAL.E- '///;;5555+:T)EODOE:+:M:+:25-O"T-
1<1/:+:-O!:* 2
,!-ET ,!TO DEPE!DE!T VAL.E- '///;;5555+:=OY:+:(:+:0/-MAY-
1<;8:+:-PO.-E:*2
,!-ET ,!TO DEPE!DE!T VAL.E- '12/;5618<+:M,")AEL:+:M:+:01-=A!-
1<18:+:-O!:*2
,!-ET ,!TO DEPE!DE!T VAL.E- '12/;5618<+:AL,"E:+:(:+:/1-DE"-
1<18:+:DA.6)TE:*2
,!-ET ,!TO DEPE!DE!T VAL.E- '12/;5618<+:EL,@A#ET):+:(:+:05-MAY-
1<51:+:-PO.-E:*2
,!-ET ,!TO DEPE!DE!T VAL.E- '<8165;/21+:A#!E:+:M:+:26-(E#-
1</2:+:-PO.-E:*2
#a*e certain ,ou issue a "OMM,T2 a7ter inserting these records
otherwise ,our 7or!s and reports will not see the unco!!itted data.
-3isting out o7 S2+@Plus will also issue a 'O##IT 7or ,ou
auto!aticall,.
-) Oracle9i Developer Suite Tools
Oracle>i Developer Suite contains the 7ollowing !ain co!ponents4
1. Oracle>i or!s 6 or designing data entr, 7or!s.
2. Oracle>i 0eports 6 or designing reports.
3. Oracle>i DDeveloper 6 or developing Dava applications or applets
4. Oracle>i Warehouse "uilder and Discoverer 6 O+=P tools 7or creating data
warehouses and O+=P user inter7aces
(. Oracle>i Designer 6 OracleEs '=S- tools that include !odeling and code
generation capa$ilities.
This tutorial covers the Developer or!s and 0eports co!ponents.
In the 7ollowing section. the procedures to run Oracle or!s under #S Windows
;>91&T12AAA1GP< will $e given.
-)( Starting Developer tools under Windows
= t,pical installation o7 Oracle>i Developer Suite ;>iDS< creates several 7olders under
the Start Progra!s !enu. The two !ain 7olders are $oth na!ed a7ter the Oracle Bo!e
,ou chose to install >iDS under. = $rie7 guide to installing >iDS can $e 7ound
here4Att%://Bisnet.8aruBA.Bun&.e7u/AoloCBDa3/oraBle/install/<i7s/
Pa, particular attention to the post6installation steps regarding how the Oracle>i=S
'ontainers 7or Dava ;O'4D< service runs and on how to install the DInit plugin 7or ,our
we$ $rowser.
The !ain >iDS progra!s represented in this tutorial are 7ound under the Oracle>i
Developer Suite ho!e and include the 7ollowing ite!s4
To run the >iDS or!s "uilder under Windows . clic* on the -tart -E ProFra$s -E
OraBle<i DeGelo%er -uite - )o$e -E (or$s DeGelo%er -E (or$ #uil7er !enu
ite!.
To run the >iDS 0eports "uilder under Windows . clic* on the -tart -E ProFra$s -E
OraBle<i DeGelo%er -uite - )o$e -E e%orts DeGelo%er -E e%orts
#uil7er !enu ite!.
or older versions o7 Oracle Developer the start !enu would !ight have ite!s such
as4 DeGelo%er 2000 2.1. DeGelo%er 2000 2.0. DeGlo%er 6i and so on.
or Oracle>iDS installs in 8&IG or +inu3. use the 7ollowing scripts4
or!s "uilder
9<07es$.sA
0eports "uilder
rC8uil7er.sA
&ote4 In ,our organiCation. >iDS !a, $e installed or con7igured slightl, di77erentl,. In
particular. the progra!s !a, $e grouped under di77erent !enus. Please contact ,our
D"= or s,ste!s ad!inistrator. or re7er to an, local docu!entation to learn how to run
the >iDS tools.
7) T$e 9iDS Forms /uilder ,ain Screen
Once the appropriate !enu ite! has $een clic*ed on ;7or Windows<. the Oracle or!s
"uilder O$%ect &avigator will appear.
7)( Oracle Forms O58ect Navigator
=7ter starting up Oracle or!s. the !ain screen will $e presented.
This screen is called the Object Navigator and displa,s all o7 the 7or! ele!ents. data
$loc*s. !enu ite!s. user de7ined code li$raries. $uilt in procedures and 7unctions. and
data$ase o$%ects ;ta$les. views<. The displa, is in the 7or! o7 a collapsi$le tree. In
general. clic*ing on a9 will e3pand the current ite! to show its details. 'lic*ing on
a : will collapse the current list details.
The !enu $ar across the top provides access to al!ost all o7 the 7eatures o7 Oracle
or!s.
The (ile !enu has options to create. open. save and print 7or!s. This !enu also
includes an option to connect to the data$ase and the =d!inistration option that
is used to co!pile 7or!s and !enu code. The last option on the (ile !enu is
the EHit option that will e3it Oracle or!s "uilder.
The E7it !enu has options to cut. cop, and paste o$%ects. to invo*e an editor
and to undo an operation.
The VieC !enu toggles the o$%ect navigator displa, $etween visual ele!ents and
ownership ele!ents.
The La&out !enu has ite!s that control o$%ects on a 7or! !uch in the wa, a
drawing pac*age does. O$%ects can $e resiCed. !oved. painted and otherwise
!anipulated using ite!s on this !enu.
The ProFra$ !enu has ite!s that control 7or! co!pilation. generation and
e3ecution ;0un<. Triggers. Procedures and other P+1S2+ code can also $e
created 7ro! this !enu. The -$art TriFFers !enu option displa,s the !ost
co!!onl, used triggers according to the t,pe o7 o$%ect currentl, selected in the
o$%ect navigator.
The De8uF !enu has options 7or de$ugging 7or!s as the, are running. It
includes !enu ite!s to esta$lish $rea* points and to step over the e3ecution o7
code one line at a ti!e.
The Tools !enu has options to switch $etween several di77erent screens
including the +a,out editor. #enu editor and O$%ect &avigator. There are also
several wiCards that can $e launched 7ro! this !enu including the Data "loc*
wiCard. the +a,out wiCard. and the +O: ;+ist o7 :alues< wiCard.
The ?in7oCs !enu displa,s !enu ite!s 7or each o7 the windows ,ou have open.
", de7ault. onl, one ite! 6 the O$%ect &avigator 6 is displa,ed.
inall,. the )el% !enu can $e used to displa, help topics.
", de7ault. a $utton $ar is provided on the le7t hand side o7 the O$%ect &avigator
window. -ach $utton duplicates so!e 7unctionalit, on the !enus. or e3a!ple. clic*ing
on the top icon ;an opened 7older< is the sa!e as pulling down the (ile !enu and
choosing the O%en option. To see what a $utton !ight do i7 pressed. place the !ouse
cursor over the $utton and a short !essage will appear descri$ing the $uttonEs 7unction.
=s with earlier versions o7 Developer. in Developer >.A. a 7or!. report or graphic is
generall, re7erred to as a Module. When 7irst starting the or!s "uilder. a de7ault
!odule is created called4 MOD.LE1
The content o7 the O$%ect &avigator is $ro*en down into ) !a%or sections4
1. (or$s 6 'ontains 7or! o$%ects and all o7 their su$6o$%ects such as data $loc*s.
triggers. alerts. canvases. progra! units ;procedures and 7unctions<. para!eters
and windows. #ore than one 7or! can $e open at a ti!e.
2. Menus 6 'ontains !enu o$%ects and all o7 their su$6o$%ects such as !enu ite!s.
para!eters and progra! units. #ore than one !enu can $e open at a ti!e.
3. PL/->L Li8raries 6 These are li$raries o7 P+1S2+ code ;stored either in the
data$ase or in .%l8 7iles<. +i$raries can $e shared a!ong di77erent 7or!s and
a!ong di77erent developers.
4. O8IeBt Li8raries 6 These are li$raries containing a collection o7 o$%ects
;an,thing that can appear on a 7or!<.
(. #uilt-in PaB3aFes 6 +ists all o7 the pac*ages ;P+1S2+ procedures< availa$le
$, de7ault to all 7or!s. reports. etc.
). Data8ase O8IeBts 6 +ists all o7 the data$ase o$%ects ;Ta$les. :iews. P+1S2+
+i$raries. and Stored Progra! 8nits< in the userEs Oracle data$ase sche!a.
=s o$%ects are created. the, are displa,ed under the appropriate section. 'onte3t
sensitive !enus can $e displa,ed 7or each o$%ect $, clic*ing on an o$%ect with the right
!ouse $utton.
7) Connecting to t$e Data5ase
The 7irst step in wor*ing with an, o7 the Developer tools is to esta$lish a connection to
an Oracle data$ase. This is acco!plished $, pulling down the (ile !enu and selecting
the "onneBt !enu ite!.
ill in ,our Oracle 8serna!e and Oracle Password ;press the ta$ *e, to !ove $etween
the 7ields<.
or the Data8ase 7ield. t,pe in the service na!e 7or ,our Oracle data$ase. or e3a!ple.
i7 ,ou are using Personal Oracle +ite. the Data8ase: would $e OD#":POL,TE. I7 ,ou
have a local data$ase running on the sa!e !achine. ,ou !a, $e a$le to connect directl,
to it $, leaving this 7ield $lan*. I7 ,ou are wor*ing in a client1server environ!ent where
the Oralce server resides on another !achine. ,ou will have to con7igure the Oracle
&et9 !iddleware to esta$lish a connection with that server. ?ou would then suppl, the
&et9 service na!e in the Data$ase 7ield. =lternativel,. contact ,our s,ste!
ad!inistrator to learn the service na!e 7or ,our Oracle data$ase and provide that
in7or!ation in the Data8ase: 7ield.
'lic* on the "onneBt $utton to co!plete the connection ;8nder so!e versions o7
8&IG. the $utton is la$eled O5<. I7 the user na!e or password is !ist,ped or incorrect.
the dialog $o3 will $e re6displa,ed. "e sure to provide ,our Oracle userna!e and
password ;not ,our 8&IG host or +ocal =rea &etwor* password<.
-ach ti!e an, o7 the Developer tools are e3ecuted. the 7irst step will $e to connect to an
Oracle data$ase in this 7ashion.
.) Forms Design
= t,pical data$ase sche!a contains doCens o7 ta$les. each with several colu!ns o7
various data t,pes. We develop applications ;7or!s. reports. !enus. etc.< to !a*e the
%o$ o7 !anipulating data in those ta$les easier 7or users. In Oracle or!s. a 7or! ;or
data entr, 7or!< acts li*e a window into the data$ase sche!a. =n individual 7ocuses the
attention o7 the user to one or a 7ew o7 the ta$les at a ti!e. In addition. a 7or! can give
pro!pts so the user *nows what *ind o7 input is e3pected and how data is to $e entered
and !anipulated.
", de7ault. ever, 7or! in Oracle or!s has the capa$ilit, to quer, e3isting data in a
ta$le. !odi7, e3isting data and add new data ;records< to the ta$le. = 7or! is $uilt up
using one or !ore data blocks that correspond to ta$les in the data$ase. ields within the
data $loc* correspond to colu!ns in the data$ase ta$le. = data $loc* is si!ilar to a
DataWindow o$%ect in Power"uilder. In the 7ollowing 7igure. a t,pical 7or! is shown.
This 7or! has two data $loc*s. one 7or the EMPLOYEE ta$le. and one 7or
the DEPE!DE!T ta$le. These data $loc*s are arranged in a Master/Detail setup where a
single -!plo,ee record ;the !aster< is associated with one or !ore Dependents records
;the details<.
", de7ault. 7or!s also gives a $utton $ar and a !enu. These can $e used to scroll
through the records in a $loc*. navigate $etween $loc*s. set up and per7or! queries
against the ta$les. insert. update and delete records. clear the 7or! and e3it the 7or!.
inall,. at the $otto! o7 each 7or! is a status $ar that displa,s an, relevant pro!pts or
error !essages and an indication o7 the records in the current data $loc*.
There are 7our !ain t,pes o7 7or!s that can $e designed.
Single "loc*
or!. This
7or! contains
a single data
$loc*
corresponding
to a single
data$ase
ta$le.
Single $loc*
or! with
loo*up 7ield.
This 7or!
contains a
single data
$loc*
corresponding
to a single
data$ase ta$le
with the
addition o7
one or !ore
7ields that
displa, data
7ro! so!e
other ta$les.
Such data is
Hloo*ed upH
when the 7or!
runs.
#aster1Detail
or!. This
7or! contains
two data
$loc*s that are
arranged in a
!aster1detail
;one to !an,<
relationship.
#aster1Detail
or! with
loo*up 7ields.
This 7or! is
si!ilar to the
#aster1Detail
$ut has the
additional
loo*up 7ields
in the !aster
and1or detail
$loc*s.
There are additional variations such as a #aster1Detail1Detail 7or! with 3
$loc*s and so on. Bowever. the 7our t,pes illustrated a$ove are the !ost
co!!on ones. In this tutorial. all 7our t,pes will $e de!onstrated.
;) Creating and Running a Form wit$ a Single /loc'
In this section. the $asic steps 7or creating a $asic data entr, and quer, 7or! 7or
a single data$ase ta$le will $e covered.
In general. a Data Block on a 7or! corresponds to a ta$le in the data$ase. This
is called the Base Table 7or the data $loc*. or each ta$le displa,ed on the
7or!. a new data $loc* will $e created. or this e3a!ple. onl, one data $loc*
will $e created 7or the EMPLOYEE ta$le.
= $loc* appears on a Canvas which is contained in a indo!. There are !an,
options to control !ultiple canvas views and !ultiple windows per 7or!. In
these e3a!ples. we concentrate on a si!ple arrange!ent using a single canvas
and a single window.
There are a nu!$er o7 wa,s to create a data $loc*. One wa, is to !anuall,
de7ine the $ase ta$le and colu!ns. and their positions on the 7or!. While this is
possi$le. it can $e ver, tedious.
Oracle or!s "uilder provides two !ain wiCards ;progra!s that guide the
developer in per7or!ing co!!on tas*s< to create data $loc*s4
1. The Data Block !i"ard guides the developer through the steps o7
choosing a $ase ta$le and colu!ns.
2. The #ayout !i"ard guides the developer through arranging the $ase ta$le
and colu!ns on the 7or!.
;)( Creating a New /loc'
To create a new $loc*. pull down the Tools !enu and select the Data #loB3
CiDar7 !enu ite!. The 7ollowing dialog $o3 will appear4

'lic* on the &e3t $utton. The 7ollowing dialog $o3 will appear4

There are two t,pes o7 data $loc*s that can $e created. Ta$le1:iew and
Procedures. or this e3a!ple. choose Ta$le1:iew and clic* on the &e3t $utton.
The ne3t step is to choose a $ase ta$le and colu!ns that will $elong to the data
$loc*. The 7ollowing dialog $o3 should appear4

To associate a data$ase ta$le with the $loc*. clic* on the #roCse... $utton to
the right o7 the Ta$le or :iew 7ield. The 7ollowing dialog $o3 will pop up.
#a*e sure the "urrent .ser and Ta8les $uttons are selected = list o7 ,our
ta$les will appear. I7 no list o7 ta$les appears. !a*e certain ,ou have created
the ta$les and inserted data as directed in the Prerequisites section 2. I7 ,ou are
still logged in to S2+@Plus. !a*e certain ,ou issue a H'O##ITIH state!ent to
co!!it all o7 the changes to the sche!a.
Bighlight the na!e o7 the data$ase ta$le ;-#P+O?-- in this e3a!ple< and
clic* on the O5 $utton.
The wiCard should reappear with the na!e o7 the ta$le and a list o7 availa$le
colu!ns displa,ed. To include a colu!n in the data $loc*. highlight the colu!n
na!e and clic* on the right arrow. The na!e o7 the colu!n should !ove over
to the right hand side.
or this e3a!ple. select the &=#-. +&=#-. SS&. "D=T-. S=+=0? and
D&O as in the 7ollowing 7igure4

'lic* on the &e3t $utton. a dialog $o3 will appear allowing ,ou to na!e the
data $loc*. In general. it is $est to si!pl, use the na!e o7 the ta$le as the na!e
o7 the data $loc* as shown $elow4

'lic* the &e3t $utton once !ore and the 7inal dialog $o3 7or the Data "loc*
wiCard will appear4

In this e3a!ple. we want to continue on to the +a,out wiCard in order to
speci7, how the new 7or! will appear. #a*e sure the "reate tAe 8loB3+ tAen
Ball tAe La&out CiDar7 option is selected and clic* on the inish $utton.
The data $loc* will $e created ;as can $e seen in the O$%ect &avigator in the
$ac*ground<. The o$%ects created include the -#P+O?-- data $loc*
containing ite!s 7or each o7 the colu!ns that were selected in the third step o7
the wiCard.
Once the new data $loc* and ite!s are created. the 7irst dialog $o3 in the
+a,out wiCard will appear4

'lic* on the &e3t $utton and the 7ollowing dialog $o3 will appear4

The la,out 7or a data $loc* !a, $e placed on an, e3isting canvas. In this case.
there are no e3isting canvases so the onl, option availa$le is to create a new
canvas.
'lic* on the &e3t $utton to displa, the 7ollowing dialog $o34

In this dialog $o3. the colu!ns 7ro! a given $ase ta$le on a data $loc* can $e
added to the la,out. Since we are la,ing out the -#P+O?-- data $loc*. it is
highlighted auto!aticall,. #ove all o7 the =vaila$le 'olu!ns over to the
Displa,ed Ite!s side $, clic*ing on the dou$le right arrow and clic* on the
&e3t $utton.
In this dialog $o3. the 7ield la$els. 7ield siCes and 7ield heights can $e altered.
'hange the 7ield la$els as shown $elow and clic* on the &e3t $utton4

The 7ollowing dialog $o3 will appear4

There are two !ain st,les 7or 7or!s. = Ta5ular la,out arranges the 7ield la$els
across the top o7 the 7or! with a nu!$er o7 records $elow as in a spreadsheet.
= Form la,out places the 7ield la$els to the le7t o7 the 7ields. /enerall, onl,
one record is displa,ed at a ti!e.
or this e3a!ple. choose a or! la,out and clic* on the &e3t $utton.
In the 7ollowing dialog $o3. t,pe a title 7or the 7ra!e ;around the data $loc*<
and chec* the option to include a scroll $ar.
The nu!$er o7 records displa,ed 7or a Form la,out should $e 1. The nu!$er o7
records displa,ed in a Tabular la,out can $e !ore than 1.

'lic* on the &e3t $utton and the 7inal dialog $o3 7or the +a,out wiCard will
appear.

'lic* on the inish $utton to create the la,out. = new 'anvas will $e created
with the new $loc* and all o7 the 7or! ite!s added in the la,out wiCard.
=t this point the +a,out -ditor should appear and the new 7or! with the data
$loc* will appear.
;) T$e 2a0out 4ditor
To view the actual 7or! and its $loc*s and 7ields. pull down the Tools !enu
and select the La&out E7itor !enu ite! ;i7 it not alread, displa,ed<.
In the +a,out -ditor. 7ields and la$els can $e !oved around $, clic*ing and
dragging. Other te3t. lines and $o3es. etc. can $e added using the tool palette on
the le7t side o7 the window.
So!e co!!on operations on the +a,out -ditor include4
#ove a 7ield or a 7ield la$el $, clic*ing and dragging the ite! with the
le7t !ouse $utton.
'hange the te3t o7 a la$el $, choosing the te3t tool $utton 7ro! the
tool $ar and then clic*ing on a la$el. To stop editing the la$el. clic*
an,where outside o7 the la$el te3t.
=dd te3t to the $loc* $, choosing the te3t tool $utton 7ro! the tool
$ar and then clic*ing on a open area. T,pe the new te3t. To change the
7ont. highlight the te3t. pull down the (or$at !enu and clic* on
the (ont !enu ite!.
To change the te3t color o7 a la$el. use the pointer tool to highlight a
la$el and then clic* on the TeHt "olor palette $utton to choose
the color.
'hange the width o7 a 7ield $, clic*ing on the 7ield. Then drag one o7 the
handles ;s!all $lac* $o3es around the 7ield< to re6siCe the 7ield.
or e3a!pe. on the e!plo,ee 7or!. ,ou !a, wish to !a*e the &=#-
7ield wider to acco!odate longer 7irst na!es.
8se the Joo! In tool to Coo! in to the 7or! ;e.g.. !a*e ever,thing
appear larger<. Or use the Joo! Out tool to Coo! out o7 the 7or!.
;)- Displa0ing #roperties
While in the +a,out -ditor. dou$le clic*ing on an o$%ect will $ring up that
o$%ectEs $ro$erties. Optionall,. clic*ing on an o$%ect with the right !ouse
$utton will $ring up a s!all !enu which has the Properties !enu ite! on it.
The 7ollowing 7igure shows the properties 7or the (!AME ite!.
-ach t,pe o7 o$%ect has a slightl, di77erent set o7 properties. or e3a!ple.
dou$le clic*ing on the -#P+O?-- data $loc* in the O$%ect &avigator ;pull
down the Tools !enu and choose O$%ect &avigator< will displa, that data
$loc*Es properties.
So!e properties o7 interest 7or a data $loc* include4
W%4R4 Clause 6 speci7, a WB-0- clause to 7ilter the selection o7
rows 7ro! the $ase ta$le.
ORD4R /6 Clause 6 speci7, an O0D-0 "? clause to alter the
displa,ed order o7 the records.
Delete Allowed< *nsert Allowed< 1uer0 Allowed and =pdate
Allowed 6 toggle these properties to allow or prevent the action. or
e3a!ple. settingDelete Allowed to (AL-E prevents users 7ro! deleting
records 7ro! the corresponding $ase ta$le using this 7or!.
There are nu!erous other properties that a77ect the 7onts. colors. siCe and
position o7 o$%ects in the $loc*.
;)7 Saving< Compiling and Running Forms
or!s can $e saved in 7iles in a director, o7 ,our choosing. The Hsource codeH
7or a 7or! is stored in a 7ile with a .9$8 e3tension. Com$iled 7or!s have
a .9$He3tension.
8nder #S Windows. 7or!s can $e saved in a 7older ;su$director,< on the local
hard dis*. on a 7ile server or on a 7lopp, dis*. It is desira$le to !aintain
separate su$directories ;7olders< 7or 7or!s associated with di77erent pro%ects.
One signi7icant ite! to $e aware o7 is that Oracle or!s will have di77icult,
running an, 7or! saved in a 7older that has spaces or punctuation other than the
underscore character in the na!e. or e3a!ple. it is co!!on in Windows to
%ust save 7iles in H#, Docu!entsH. Bowever. since this has a space in the
na!e. the 7or! will not run.
There7ore. i7 ,ou are developing on a local !achine. it is reco!!ended that
,ou at least !a*e a si!ple director, such as ":J9or$s or A:J9or$s i7 using a
7lopp, dis* and save all 7or!s 7iles there.
;)7)( Saving a Form
To save a 7or!. pull down the (ile !enu and select the -aGe !enu ite!.
8nder #S Windows. this dialog $o3 loo*s li*e4
&ote that in ,our co!pan, or organiCation. 7or!s and other 7iles !a, have to
$e saved on 7lopp, dis* or in a special director,. The a$ove 7igure is si!pl, an
e3a!ple.
*t is critical t$at 0ou do not save t$e file wit$ spaces in t$e file name. In
addition. ,ou should save the 7iles ina local director, where the director,
na!e;s< have no spaces in the the!. I7 ,ou save the 7ile in H#, Docu!entsH 7or
e3a!ple. or on the Windows des*top. ,ou will $e una$le to run or test the
7or!s.
ill in a 7ile na!e in the (ile !a$e: 7ield. "e sure it contains no spaces and that
it ends with .9$8
'lic* on the -aGe $utton to save the 7ile. or this e3a!ple. use the 7ile
na!e e$%lo&ee.9$8
To save this 7or! on a 7lopp, dis* in the A: drive. use the 7ile
na!e4 A:Je$%lo&ee.9$8
To enhance porta$ilit, o7 7or!s across di77erent operating s,ste!s. use 7ile
na!es that $egin with a letter. contain no spaces or punctuation ;e3cept 7or the
underscore character<. have all lower case letters and are relativel, short.
Reminder> Do not use spaces in the na!es o7 the 7ile or the na!es o7 an,
7olders ;directories<.
I7 ,ou are wor*ing on a 7or! and wish to save it under a different 7ile na!e.
7ollow the sa!e steps as a$ove. onl, select the -aGe As !enu ite! in place o7
the -aGe!enu ite!. or e3a!ple. i7 ,ou have 7inished wor*ing on the
-!plo,ee 7or! and wish to save o77 a cop, $e7ore adding so!e code or
progra!!ing so!e progra! units. the -aGe As !enu ite! can $e used to save
o77 a cop, $e7ore proceeding.
;)7) Compiling//uilding a Form
"e7ore a 7or! can $e e3ecuted ;run<. it !ust $e Com$iled and Built. 'o!piling
runs a P+1S2+ co!piler on all o7 the procedures and triggers in the 7or!.
"uilding ;or co!piling the 7ile< creates the .9$H 7ile that is then used to run the
7or!.
To co!pile a 7or!. 7irst !a*e sure the 7or! is saved. Pull down
the ProFra$ !enu and select the "o$%ile Mo7ule !enu ite!.
I7 a 7or! has errors ;e.g.. in the P+1S2+ code. or i7 the data$ase sche!a
changes< the, will $e displa,ed in a window as the, are encountered. = record
o7 the co!pilation process. including error !essages. is *ept in a 7ile with
a .err e3tension. or e3a!ple. i7 the 7or! is na!ed e$%lo&ee then the record o7
the co!pilation will $e stored in e$%lo&ee.err
=lternativel,. Oracle or!s de7aults to auto!aticall, co!piling the 7or! each
ti!e it is e3ecuted ;run< 7ro! the 7or!s "uilder as will $e de!onstrated in the
ne3t step. or !ore details on the de7ault $ehavior. pull down the Tools !enu
and chec* the Pre9erenBes !enu ite!.
;)7)- Running a Form
=s discussed in the introduction section. Oraclce>i or!s are intended to urn in
a three tier architecture. The data$ase acts as the $ac*6end tier. The Oracle>i=S
'ontainers 7or Dava ;O'4D< service acts as the !iddle tier and a we$ $rowser
;Internet -3plorer (.3 or a$ove or &etscape &avigator 4.5 or a$ove< ta*es on
the role o7 the user6inter7ace tier.
8nless this environ!ent has alread, $een esta$lished. a local client6side O'4D
service !a, $e used in place o7 the !iddle tier.
"e7ore running a 7or!. the O'4D service should $e started. 8se the Start #enu
to navigate to4 -tart -E ProFra$s -E OraBle<i DeGelo%er -uite - )o$e -E
(or$s DeGelo%er -E -tart ,";= ,nstanBe
= 'o!!and pro!pt will open ;in Windows 2AAA< si!ilar to the 7ollowing4
&ote that $, de7ault. O'4D runs on port 9999. I7 this con7licts with another
service or i7 ,ou have 7irewall so7tware that prevents opening up such ports.
,ou will need to change the con7iguration o7 either O'4D. ,our 7irewall
so7tware or $oth.
I7 ,ou receive an error when running O'4D. it !a, $e $ecause another O'4D
instance is alread, running. I7 ,ou are uncertain. save ,our wor* and re$oot the
P'. Then run a single instance o7 O'4D.
With O'4D con7igured and running. and the 7or! designed and saved. it can $e
e3ecuted. To run the 7or!. pull down the ProFra$ !enu and select the un
(or$!enu ite!. This will launch ,our de7ault we$ $rowser which will then
connect to O'4D ;port 9999< on the local !achine. OracleEs DInitiator will load
and the 7or! should appear.
8se the various !enus and ite!s to quer, the 7or!. enter new data and save
new and changed data. Please read the section $elow on 2uer, ", -3a!ple to
see how to quer, data 7ro! the underl,ing ta$les and populate the 7ields in the
7or!.
I7 O'4D service is not running. an error !essage si!ilar to the 7ollowing will
$e displa,ed4
I7 ,ou see error 0#61A142. !a*e sure the O'4D Instance is running. +oo* in
the Windows Start #enu 7older where ,ou started or!s "uilder. There should
$e a !e!u ite! called4 -tart O";= ,nstanBe. 0un that progra! ;a DOS $o3
will appear< and !a*e sure it loo*s si!ilar to the e3a!ple a$ove. I7 the O'4D
Instance gives errors. it !a, $e $ecause ,our co!puter has a personal 7irewall
;such as that included in Windows GP Service Pac* 2<. #a*e certain ,ou
con7igure ,our personal 7irewall to allow local connections to port 9999.
I7 ,ou have previousl, not installed the latest DInitiator. ,our $rowser will
launch with the 7ollowing !essage4
'lic* on the H/et the Plug6inH $utton and 7ollow the instructions to install it.
&ote that the %init.e3e 7ile is actuall, installed with Oracle>i Developer Suite.
0e!inder4 I7 ,ou saved ,our 7or! in a 7older that has spaces in the na!e. or i7
,our 7ile na!e has spaces. the 7or! will not load in the we$ $rowser. In such
cases. ,ou !a, see error4 (M-<0<28 Positional %ara$eter a9ter 3e& on
Bo$$an7 line. I7 this occurs. si!pl, use the HSave =sH ite! on the ile !enu to
save the 7or! under a new na!e with no spaces. Then tr, to run the 7or! again.
Technical &otes and Possi$le -rrors4
The height and width settings 7or the Dava applet that displa,s the 7or!s
are set in the 9or$sCe8.B9F 7ile located in J9or$s<0JserGer director,
under the Oracle>iDS installation ho!e. -dit the 9or$sCe8.B9F 7ile with
a te3t editor and scroll down to Section /* Values 9or tAe (or$s a%%let
%ara$eters:
'hange the widthK and heightK para!eters accordingl, and save the 7ile.
?ou a!, need to restart the O'4D server.
-rror (M-18125: "oul7 not 9in7 tAe Ce8 8roCser appears i7 ,ou do not
have a we$ $rowser installed or ,our we$ $rowser is not 7ound in the
P=TB. I7 ,ou are certain ,ou have a we$ $rowser installed. set its
location in the Pre7erences section in the or!s $uilder ;-dit 6L
Pre7erences 6L 0unti!e ta$<.
-rror (M-101;2: TAe )TTP listener is not runninF on... appears i7
the O'4D is not running. Start the O'4D Instance.
;)7)7 1uer0 /0 4?ample
When a Developer or! is 7irst e3ecuted. no records will appear. That is. the
$lan* 7or! will appear with no data in the 7ields. This is si!ilar to running a
word processor where the opening screen is $lan*. ro! this $lan* or e!pt,
7or!. the user can i!!ediatel, $egin to enter new data records $, si!pl,
t,ping the! in.
Bowever. in !an, cases. the user would 7irst li*e to see i7 there are an, records
in the data$ase. To do this. the user !ust %uery the data$ase using the quer,
capa$ilities that are $uilt into ever, Oracle 7or!. This will $ring a cop, o7 the
records 7ro! the data$ase into the 7or!.
When a tool such as S2+@Plus is used. the user !ust 7or! the S2+ quer, $,
t,ping it directl, in. In the case o7 e!$edded S2+. the S2+ state!ents are
progra!!ed into the host language ;such as H'H or Dava< and auto!aticall,
e3ecuted 7or the user. In the case o7 Oracle or!s. co!ple3 queries can $e
7or!ulated and su$!itted to the data$ase using a technique called 2uer, ",
-3a!ple or 2"-. In 2"-. the na!e o7 the ta$le or ta$les is 7i3ed as are the
na!es o7 the colu!ns that will $e returned 7ro! the ta$les. The user can suppl,
their own criteria $, suppl,ing values 7or the 7ields. These values $eco!e part
o7 the quer, that is su$!itted to the data$ase on $ehal7 o7 the user.
2uer,ing a 7or! in Oracle or!s is a two step process. 'lic*ing on the 2uer,
$utton or choosing Enter >uer& 7ro! the >uer& !enu places the 7or! in &nter
'uery !ode. In enter quer, !ode. the 7or! is cleared and the user can navigate
in the various 7ields. -3a!ple values can $e supplied as criteria 7or the quer,.
or e3a!ple. a user loo*ing 7or all e!plo,ees in the 0-S-=0'B depart!ent
!ight t,pe a H(H in the D&O 7ield while in enter quer, !ode.
'lic*ing on the 2uer, $utton a second ti!e ;or pulling down the >uer& !enu
and choosing EHeBute >uer&< e3ecutes the current quer, using an, supplied
data as criteria in a WB-0- clause. I7 no criteria are supplied. then all records
in the ta$le will $e displa,ed. 'ontinuing the a$ove e3a!ple. suppl,ing a H(H
7or the D&O 7ield while in enter quer, !ode would cause the 7ollowing S2+
quer, to $e su$!itted to the data$ase4
-ELE"T 9na$e+ lna$e+ ssn+ 87ate+ salar&+ 7no
(OM e$%lo&ee
?)EE 7no K 52
#ost o7 the co!!ands on the !enus and on the $utton $ar can also $e
activated using special *e, co!$inations or 7unction *e,s. or e3a!ple. within
the Dava $ased 7or!s displa, pressing the (11 7unction *e, places the 7or! in
-nter 2uer, !ode. Pressing the "TLL(11 7unction *e, e3ecutes a quer,. ;&ote4
Please chec* the Belp !enu to see i7 the *e,s in ,our s,ste! are the sa!e<. To
see a list o7 *e,s and their 7unctions. pull down the )el% !enu and choose
the 5e&s option.
Once data has $een queried. it is retrieved 7ro! the data$ase and stored in a
$u77er in the associated data $loc* on the 7or!. This !eans that a local cop, o7
the data now e3ists in the clientEs !e!or,. =ppropriate loc*s are placed on the
data so that the client !aintains a consistent view o7 the data in the associated
ta$les.
The user can navigate through the data in a $loc* $, pressing the up and down
arrow *e,s to scroll $etween records. To change data in a 7or!. the user can
T=" to the 7ield o7 interest. and t,pe over the e3isting data.
To enter new data into the 7or!. the user can scroll to the last record and then
down once !ore to !ove to a $lan* record. Data can then $e t,ped into the
7ields and the T=" *e, can $e pressed to !ove $etween 7ields on the 7or!.
To save $oth changed and new records on a 7or!. pull down the ABtion !enu
and choose the -aGe !enu ite!. =n, records that have $een changed are
collected and su$!itted to the data$ase as S2+ 8PD=T- state!ents. =n, new
records are collected and su$!itted to the data$ase as I&S-0T state!ents.
These state!ents are su$!itted as a single logical unit o7 wor*. Thus i7 a
7ailure occurs during an, o7 the state!ents. the entire transaction will $e rolled
$ac*.
I7 the user atte!pts to clear the $loc* or e3it the 7or! and there are so!e
changes that have not ,et $een applied to the data$ase. the, will $e pro!pted to
co!!it the changes $e7ore e3iting or clearing the 7or!. The $loc* is cleared
when the -nter 2uer, !ode is invo*ed. = $loc* can also $e cleared using
the "lear #loB3and "lear (or$ !enu ite!s.
To e3it 7ro! a running 7or!. pull down the ABtion !enu and select
the EHit !enu ite!. Warning> Do not simpl0 close t$e we5 5rowser as t$is
will leave a @ava Applet process running and t$is will loc' 0our form A)fm?
fileB)
=s a review. here are a 7ew $asic 7unctions that can $e per7or!ed $, de7ault in
an, or!4
Forms
function
Notes
2uer,ing a
7or!
To see all records in the ta$le. si!pl, H-3ecute 2uer,H ;via 2uer, !enu or
$, pressing 9 in Windows<.
To 7ilter the record. Henter quer,H !ode. speci7, the quer, para!eters in
the 7ields and then H-3ecute 2uer,H.
Inserting new
records
Scroll to the last record and then scroll once !ore to get a $lan* record.
T,pe in data 7or each 7ield and then co!!it these changes $, pulling down
the ABtion !enu and choose the -aGe !enu ite!.
or !aster1detail 7or!s ;discussed $elow< 7irst either quer, a !aster record
or insert and save a !aster record ;in the !aster data $loc*<. then navigate
to the detail $loc* and insert new records there.
8pdating
e3isting
records
2uer, the data$ase and scroll to the record o7 interest. 'hange the values in
the 7ields and then save the changes.
or !aster1detail 7or!s. changes to the *e, in the !aster $loc* !a, $e
prevented i7 detail records e3ist ;thus insuring relational integrit,<.
Deleting 2uer, the data$ase and scroll to the record o7 interest. Pull down the
records
0ecords !enu and choose Delete record. Then save the changes.
or !aster1detail 7or!s. atte!pting to delete a !aster record when detail
records e3ist t,picall, results in an error. In such cases. all o7 the detail
records should $e deleted 7irst and then the !aster record should $e a$le to
$e deleted.
-3iting the
or!
Pull down the ABtion !enu and choose the EHit !enu ite!. -3isting in
this wa, will release an, Dava processes that !ight loc* up ,our 7or!s
7iles.
;). 4?ercise> Creating a a Single /loc' Form
or this e3ercise. create a si!ple data entr, 7or! 7or the D-P=0T#-&T ta$le
with the 7ollowing characteristics4
Select and displa, all o7 the colu!ns in the D-P=0T#-&T ta$le.
In the la,out wiCard. use the Ta$ular la,out and displa, ( 0ecords in the
7or!. =dd a scroll$ar.
In the +a,out -ditor. !a*e the D&=#- 7ield a $it wider to
acco!!odate longer depart!ent na!es.
'hange the Properties o7 the D-P=0T#-&T $loc* so that that data is
O0D-0 "? D&=#-.
Save the 7or! under the 7ile na!e4 7e%art.9$8
The resulting 7or! should loo* li*e the 7ollowing4
8se the enter quer, !ode and e3ecute quer, 7unctions to quer, the depart!ent
ta$le 7or a speci7ic depart!ent na!e and1or nu!$er.
C) Creating a ,aster:Detail Form
In this section. the $asic steps 7or creating a #aster1Detail 7or! are introduced.
= #aster1Detail 7or! is a 7or! that has two $loc*s arranged in a !aster6detail
relationship.
C)( T$e ,aster:Detail Relations$ip
The #aster6Detail relationship is a co!!on relationship $etween entities in a
$usiness. In an -ntit,60elationship diagra!. these are shown as HOne to #an,H
relationships. In a ph,sical data$ase design. a single Master record re7erences
one or !ore detail records in another ta$le. = record in the detail ta$le will
relate to e3actl, one !aster record in the !aster ta$le. =nother na!e 7or this
relationship is called parent6child. -3a!ples o7 this relationship include4
= 'usto!er Order with !an, OrderIte!s.
= Depart!ent with !an, -!plo,ees.
=n -!plo,ee with !an, Dependents.
= 'o!pan, with !an, "ranch O77ices.
= 0ecipe with !an, 0ecipeSteps.
=n Inventor, location with !an, Inventor, Ite!s.
Oracle or!s i!ple!ents the !aster6detail relationship using two data $loc*s.
The 7irst $loc* corresponds to the !aster ta$le and the second $loc*
corresponds to the detail ta$le. There are two !a%or 7unctions in a #aster6
Detail 7or!4
Oracle or!s coordinates values $etween the two $loc*s through a
series o7 7or! and $loc* level triggers.
Oracle or!s guarantees that the detail $loc* will displa, onl, records
that are associated with the current record in the !aster $loc*.
&ote that a #aster6Detail 7or! is si!pl, one wa, o7 viewing the data in two
related ta$les. or!s do not a77ect the sche!a in ter!s o7 creating. dropping or
en7orcing data$ase level re7erential integrit, constraints.
C) Steps to Create a ,aster:Detail Form
In this section. a set o7 step $, step instructions 7or creating a #aster6detail
7or! are given. The 7or! will allow a user to quer, a given depart!ent in the
co!pan, and then will displa, all o7 the e!plo,ees in that co!pan,.
The sche!a used is the sa!e one suggested in the Prerequisites section at the
$eginning o7 this tutorial. &otice that the D&O colu!n in the EMPLOYEE ta$le
gets its values 7ro! the D&8#"-0 colu!n in the DEPATME!T ta$le. In other
words. to %oin the two ta$les in a quer,. one !ight speci7, a WB-0- clause
such that4EMPLOYEE.D!O K DEPATME!T.D!.M#E.
C))( Create t$e ,aster /loc'
In the O$%ect &avigator. clic* on the (or$s $ranch at the ver, top. 'reate a new
7or! $, pulling down the (ile !enu and choosing the !eC !enu ite!. Then
choose (or$ 7ro! the 7l,out !enu.
8sing the sa!e steps given in the prior section on ). 'reating a or! with a
Single "loc*. create a new $loc* na!ed DEPATME!T that contains all o7 the
colu!ns in the DEPATME!T ta$le. "rie7l,4
1. Pull down the Tools !enu and choose the Data "loc* wiCard.
2. 'reate a data $loc* 7or a ta$le1view.
3. Speci7, the D-P=0T#-&T ta$le and select all o7 the colu!ns
;D&=#-. D&8#"-0. #/0SS& and #/0S=0TD=T-<.
4. 'reate the data $loc* and then go on to the +a,out wiCard.
(. =ppl, the Depart!ent data $loc* to a new canvas.
). =dd all o7 the colu!ns as Displa,ed Ite!s.
5. 'hange the la$els to4
Dept. &a!e
Dept. &u!$er
#gr. Ssn
#gr. Start Date
9. 'hoose a Form la,out.
>. Speci7, a 7ra!e title o7 HDepart!entsH and select onl, 1 record to $e
displa,ed.
1A. Save the 7or! as 7e%te$%.9$8 and then co!pile and run it to !a*e sure it
is wor*ing properl,.
11. 8se the 2"- 7eatures to retrieve onl, those depart!ents with
D&8#"-0 greater than 2. Then. do another 2"- quer, to retrieve onl,
those depart!ents with the letter ) in their na!e ;tr, M)M<.
=7ter this 7irst step. the 7e%te$% 7or! should loo* li*e the 7ollowing4

C)) Create t$e Detail /loc'
&ow that we have the !aster $loc* D-P=0T#-&T created. we can now
create the detail $loc* -#P+O?-- and associate it with the !aster $loc*.
Per7or! the 7ollowing steps4
1. 0eturn to the O$%ect &avigator ;pull down the Tools !enu and
choose O8IeBt !aGiFator<.
2. In the O$%ect &avigator. clic* on the Data "loc*s $ranch o7 the
D-PT-#P 7or! ;do not clic* on the depart!ent data $loc*. however<.
3. Pull down the Tools !enu and choose the Data "loc* wiCard.
Note( I7 the D-P=0T#-&T data $loc* ;or an, o7 its ite!s< is still
selected. activating the Data "loc* wiCard will cause the e3isting $loc*
to $e edited instead o7 creating a new $loc* ;which is what is required in
this part o7 the tutorial<.
4. Select the -#P+O?-- ta$le and include the &=#-. +&=#-. SS&.
"D=T-. S=+=0? and D&O colu!ns.
(. "ecause at least one data $loc* alread, e3ists in the 7or!. the ne3t step
in the wiCard will $e to create a relationship $etween the e3isting data
$loc* ;D-P=0T#-&T in this case< and the new $loc* $eing created.
The wiCard can construct the relationship $ased on ta$le level constraints
it learns 7ro! the data$ase sche!a. or e3a!ple. in the '0-=T-
T="+- and =+T-0 T="+- state!ents given at the start o7 this
tutorial. 7oreign *e, constraints were speci7ied $etween D-P=0T#-&T
and -#P+O?--. and $etween -#P+O?-- and D-P-&D-&T.
Bowever. such relationships are not alwa,s i!ple!ented in ta$le level
constraints.
The developer can also speci7, the relationship !anuall,. In this case.
the relationship will $e speci7ied !anuall,.
De6select the Auto-Ioin 7ata 8loB3s option.
'lic* on the "reate elationsAi% $utton to list the availa$le data
$loc*s.
In the ne3t dialog $o3 0elation T,pe. choose #ase7 on a Ioin
Bon7ition and clic* the O5 $utton.
When the list o7 $loc*s appears. choose the D-P=0T#-&T data $loc*.
=rrange the Detail Ite! ;D!O< and #aster Ite! ;D!.M#E< such as that the
%oin condition $eco!es4 EMPLOYEE.D!O K DEPATME!T.D!.M#E
). &a!e the data $loc* -#P+O?--.
5. 'reate the data $loc* and then call the +a,out wiCard.
9. "e sure to choose the e3isting canvas ;'=&:=S4 in this e3a!ple< and
include all o7 the ite!s e)ce$t t*e DNO as displa,ed.
The D&O colu!n ;ite!< will still $e a part o7 the -#P+O?-- data
$loc*. however. it will not $e displa,ed to the user.
>. Touch up the la$els 7or the 7ields and choose the Tabular la,out.
1A. /ive the ra!e Title as H-!plo,eesH and select ( 0ecords displa,ed
with A distance $etween records.
11. Save the 7or! ;it should alread, have the na!e 7e%te$%.9$8< and then
co!pile and run it. &ote that a7ter co!pilation. an, errors encountered
will $e displa,ed.
The 7ollowing 7igure shows the !aster6detail 7or! running4
&otice that $, scrolling the !aster $loc* D-P=0T#-&T to a new depart!ent
nu!$er ;using the up and down arrow *e,s<. the e!plo,ees 7or that depart!ent
are auto!aticall, queried and displa,ed.
To navigate $etween the #aster and Detail $loc*s. use4
To go to the ne3t $loc*4 Press "TL-PaFeDoCn or pull down
the #loB3 !enu and choose !eHt
To go to the previous $loc*4 Press "TL-PaFe.% or pull down
the #loB3 !enu and choose PreGious
C)- Relation #roperties of a ,aster:Detail Form
There are a nu!$er o7 properties in a !aster6detail 7or! that can $e changed to
suit particular $ehavior o7 the 7or!. In the 7igure $elow. the O$%ect &avigator
has several new o$%ects on it including +elations.
To view the properties 7or the D-P=0T#-&TF-#P+O?-- relation. open up
the D-P=0T#-&T $loc* and then open the 0elations $loc* $, clic*ing on
the Ls,!$ols. Then clic* on the D-P=0T#-&TF-#P+O?-- relation with
the right !ouse $utton and select Properties.
There are several interesting properties in the relations propert, sheet4
Name 6 The na!e o7 the 0elation. This is t,picall, !ade up o7 the
na!es o7 the $loc*s.
Relation T0pe 6 The t,pe o7 the relation4 Doin or 0e7.
= Doin relation uses the t,pical S2+ %oin ;in the Where clause< to $ring
the two ta$les ;data $loc*s< together. The +ef relation t,pe is used 7or
a$stract data t,pes and o$%ect re7erences.
Detail Data /loc' 6 The na!e o7 the detail data $loc* speci7ied when
the detail data $loc* was created.
@oin Condition 6 This is the %oin condition in e77ect 7or queries to the
data$ase. This was speci7ied when the detail data $loc* was created.
Delete Record /e$avior 6 8sed to speci7, how the deletion o7 a record
in the !aster $loc* a77ects records in the detail $loc*. It supports the
7ollowing settings4
o &on6isolated4 Prevents the deletion o7 a !aster record i7
associated detail records e3ist in the data$ase.
o Isolated4 Deleting the !aster record will not a77ect the associated
detail records in the data$ase.
o 'ascading4 Deletes the !aster record and auto!aticall, deletes
an, associated detail records.
Coordination : Deferred 6 Indicates when detail records should $e
queried when a !aster record is queried.
o ?es4 or! does not quer, the detail records until the user
navigates to the detail $loc*.
o &o4 Detail records are 7etched i!!ediatel, when a user queries
the !aster record.
De7erred is so!eti!es set to ?es in cases where there are a lot o7 detail
records 7or each !aster record. In such cases. a lot o7 data !ust $e
queried and delivered to the client each ti!e a new record is displa,ed in
the !aster $loc*. When De7erred is set to ?es. the user can scroll down
to the !aster record o7 interest and then navigate to the detail $loc*
;'T0+6PageDown< to quer, the related detail records.
Coordination : Auto:+uer0 6 =pplied to de7erred queries onl,
o ?es4 the quer, is auto!aticall, e3ecuted when the user navigates
to the detail $loc*.
o &o4 the quer, !ust $e e3ecuted !anuall, $, the user a7ter the,
navigate to the detail $loc*.
#revent ,asterless operation 6 Speci7ies whether users are allowed to
quer, or insert records in a detail $loc* when no !aster record is in
place.
o ?es4 8sers !a, not quer, or insert when no !aster record is in
place.
o &o4 8sers !a, quer, or insert when no !aster record is in place.
These settings are used to HtuneH the overall per7or!ance o7 a !aster6detail
7or!. =s !entioned a$ove. in cases where a large nu!$er o7 detail records are
associated with each !aster record. it is a good idea to set coordination6
De7erred to ?es to avoid unnecessar, trans7ers o7 data $etween the server and
client. This will also speed up the displa, o7 !aster records as the user can
7reel, scroll through the! without a pause to quer, and deliver the detail
records.
C)7 #rogram =nits in a ,aster:Detail Form
When a #aster6detail 7or! is created. three $asic ,rogram -nits ;P+1S2+
Procedures< are created $, de7ault. These procedures are used to coordinate the
quer, and navigation o7 the detail records when the !aster record is changed
;e.g.. when the user scrolls to a di77erent !aster record<. updated or deleted.
The procedures can $e seen listed in the O$%ect &avigator4
P+1S2+ is OracleEs procedural language e3tensions to S2+. To view the
P+1S2+ code 7or a Progra! 8nit. clic* on the na!e o7 the progra! unit with
the right !ouse $utton and then choose PL/->L E7itor 7ro! the pop6up !enu.
The code 7or the 'B-'MFP='M=/-F=I+80- procedure is show here4
The 'B-'MFP='M=/-F=I+80- procedure chec*s to see i7 a prior 7or!
co!!and or S2+ state!ent was success7ul or i7 it 7ailed.
"elow is the P+1S2+ code 7or the 28-0?F#=ST-0FD-T=I+S procedure.
The te3t a7ter the -- ;two !inus signs< are co!!ents.
PO"ED.E >uer&4Master4Details'rel4i7 elation+7etail ")A* ,-
ol7$sF ")A'2*2 -- Ol7 MessaFe LeGel -ettinF
rel7e9 ")A'5*2 -- elation De9erre7 -ettinF
#E6,!
--
-- ,nitialiDe LoBal Varia8le's*
--
rel7e9 :K 6et4elation4Pro%ert&'rel4i7+ DE(EED4"OOD,!AT,O!*2
ol7$sF :K :-&ste$.MessaFe4LeGel2
--
-- ,9 !OT De9erre7+ 6oto 7etail an7 eHeBute tAe Nuer&.
--
,( rel7e9 K :(AL-E: T)E!
6o4#loB3'7etail*2
"AeB34PaB3aFe4(ailure2
:-&ste$.MessaFe4LeGel :K :10:2
EHeBute4>uer&2
:-&ste$.MessaFe4LeGel :K ol7$sF2
EL-E
--
-- elation is 7e9erre7+ $ar3 tAe 7etail 8loB3 as un-Boor7inate7
--
-et4#loB34Pro%ert&'7etail+ "OOD,!AT,O!4-TAT.-+ !O!4"OOD,!ATED*2
E!D ,(2
E0"EPT,O!
?)E! (or$4TriFFer4(ailure T)E!
:-&ste$.MessaFe4LeGel :K ol7$sF2
A,-E2
E!D >uer&4Master4Details2
The 28-0?F#=ST-0FD-T=I+S procedure is e3ecuted whenever the user
navigates to the detail $loc* in a !aster detail 7or!. I7 the De7erred
'oordination propert, is set to 7alse. then the detail $loc* is auto!aticall,
queried.
inall,. the '+-=0F#=ST-0FD-T=I+S procedure is called each ti!e a new
!aster record is retrieved ;e.g.. when the user scrolls to a di77erent !aster
record< or deleted. In this case. i7 an, o7 the detail records have $een inserted.
updated or deleted. the changes !ust $e saved into the data$ase $e7ore the
detail $loc* can $e cleared. I7 there are an, outstanding changes to $e saved.
the user will $e pro!pted to save those changes $e7ore the detail $oc* is
cleared.
C). 4?tending ,aster:Detail Forms
#aster6Detail 7or!s can $e e3tended to include additional levels o7 details. or
e3a!ple. consider a 'usto!er listing with detail on Orders a custo!er has
placed. or each Order. there are then !an, Ite!s. =n e3tension to the a$ove
e3a!ple would $e to include the D-P-&D-&TS o7 the e!plo,ees as a details
o7 the -#P+O?--S $loc*. The steps outlined a$ove can $e repeated allowing
several levels o7 detail to $e added. -ach additional level o7 detail will add a
new $loc* that is related to the level a$ove it.
C); 4?ercise> Creating a ,aster/Detail Form
or this e3ercise. create a #aster1Detail 7or! using the -#P+O?-- and
D-P-&D-&T ta$les. -!plo,ee will $e the #aster $loc* and Dependents will
$e the Detail $loc*. The %oin condition $etween the two ta$les is where the
SS& colu!n o7 -#P+O?-- is equal to the -SS& colu!n o7 D-P-&D-&T.
The 7ollowing is an outline o7 the steps4
1. 'reate the -!plo,ee data $loc* and include the &=#-. +&=#-.
SS&. =DD0-SS and S-G 7ields on the 7or!. 8se the or! la,out and
onl, displa, one record at a ti!e.
2. /o $ac* to the O$%ect &avigator and select the HData "loc*sH tree. #a*e
sure the -#P+O?-- $loc* is not selected and run the Data "loc*
WiCard again.
3. 'reate the Dependents data $loc* and include all o7 the colu!ns.
or the !aster1Detail relationship. de6select the HautoH option. use a Doin
relationship. choose the -#P+O?-- data $loc* as the #aster and
setDEPE!DE!T.E--! K EMPLOYEE.--! 7or the %oin relationship.
4. In the +a,out WiCard 7or the Dependents data $loc*. displa, all o7 the
7ields e)ce$t t*e &SSN field. The -SS& 7ield will re!ain part o7 the data
$loc* $ut it will not $e visi$le on the 7or!. 'hoose a Ta$ular st,le and
displa, 4 up to records at once with A space $etween each record.
(. Save the 7or! using the na!e4 e$%7e%n.9$8
The co!pleted 7or! should loo* li*e the 7ollowing4
2uer, the !aster $loc* and practice navigating $etween the two $loc*s using
the 'T0+6PageDown and 'T0+6Page8p *e,s.
While in the -!plo,ee $loc*. scroll to the -!plo,ee na!ed D-&&I-0
W=++='-. navigate to the Dependents $loc* and add a new record 7or a SO&
na!ed =&D0-W $orn on 2A6O'T61>)2. &avigate $ac* to the -!plo,ee
$loc* and atte!pt to scroll to another e!plo,ee record. = pro!pt should $e
displa,ed to save the new Dependent record.
While in the #aster $loc* 7or -!plo,ees. scroll to an e!plo,ee who has so!e
dependents. Tr, to delete the -!plo,ee record and see i7 an error !essage
appears.
inall,. alter the -#P+O?--FD-P-&D-&T relation properties and set the
'oordination6De7erred to ?es and then run the 7or!. &otice now that the detail
records will not $e displa,ed auto!aticall,. &avigate to the Dependents $loc*
and hit the -3ecute quer, $utton ;or pull down the >uer& !enu and
chooseEHeBute<. &otice that onl, those Dependent records !atching the
-!plo,ee are displa,ed.
D) 2ist of Ealues A2OEsB and Non:/ase Ta5le Fields
It is cu!$erso!e 7or a user to have to re!e!$er various codes and nu!$ers
while entering data into a data entr, 7or!. or e3a!ple. in the -!plo,ee 7or!.
it !ight $e di77icult to have all o7 the depart!ent nu!$ers !e!oriCed when
inserting new e!plo,ee data.
One solution to this pro$le! is to !a*e a list o7 appropriate values availa$le
when the user navigates to Depart!ent &u!$er 7ield ;D&O<. In Oracle or!s.
these are called +ist o7 :alues ;+O:s<. The ne3t section will illustrate creating
+O:s 7or 7ields. These e3a!ples are $ased on the single $loc* -!plo,ee 7or!
created at the $eginning o7 this tutorial.
To prepare 7or this part o7 the tutorial. close an, 7or!s ,ou currentl, have open
$, pulling down the (ile !enu and selecting the "lose !enu ite!.
Once all o7 the 7or!s are closed. pull down the (ile !enu and choose
the O%en !enu ite! to open up the e$%lo&ee.9$8 7or! that was created
previousl,.
= +ist o7 :alues is $ased on a +ecord .rou$. In Oracle or!s. a record group
is a quer, that returns so!e collection o7 records. 0ecord groups can $e used to
populate $loc*s or +O:s and the, can $e used in procedures. When the user
navigates to an ite! with an +O: attached to it. the +O: *e, ;> in #S
Windows< can $e pressed to call up the +O:. =t that ti!e. the quer, associated
with the record group is e3ecuted and the results are displa,ed in a pop up
window. Once the user !a*es a selection 7ro! the list. the value or values are
returned to the 7or! and placed in the appropriate 7ields.
In the e3a!ple $elow. a record group and +O: 7or the D&O ;depart!ent
nu!$er< 7ield in the -!plo,ee ta$le will $e created.
D)( Creating a 2ist of Ealues
'reating a +ist o7 :alues requires 4 $asic steps.
D)()( Create a new 2OE O58ect
To create an +O:. clic* on the +O:s node in the O$%ect &avigator. Then pull
down the E7it !enu and choose the "reate !enu ite!. = dialog $o3 will
appear as*ing i7 ,ou would li*e to create the +O: !anuall, or i7 ,ou would
li*e to use the +O: WiCard.
'hoose H8se the +O: WiCardH and clic* the OM $utton. The 7irst step o7 the
+O: WiCard will appear as $elow4
The de7ault is set to create a new 0ecord /roup $ased on a quer,. #a*e sure
this selection is highlighted and then clic* the &e3t $utton.
In !ost cases. ,ou will not have a record group created previousl,. Bowever.
one can $e created on the 7l, at this point $, speci7,ing a quer,. In this
e3a!ple. enter the +O: quer, as 7ollows4 -ELE"T 7nu$8er (OM 7e%art$ent
Then clic* on the &e3t $utton.
The ne3t step is to speci7, which colu!ns in the record group will $e returned
to 7or use $, the +O:. In this e3a!ple. we onl, return D&8#"-0 so select
that colu!n as shown $elow and clic* &e3t.
The ne3t step is to speci7, the displa, properties o7 the +O: colu!ns and also
to !ap the +O: ite! to the 7ield on the 7or!.
To !ap the +O: colu!n to a 7ield. clic* on the D&8#"-0 entr, and then
clic* on the H+oo* up return Ite!H $utton. Bighlight the -#P+O?--.D&O
7ield and clic* on the OM $utton.
&ote that i7 ,our +O: contains !ore than one ite!. at this ti!e ,ou would also
!ap the! as well ;this is not the case with this e3a!ple. $ut in the ne3t
e3a!ple we will need to !ap two +O: colu!ns<. 'lic* on the &e3t $utton.
Speci7, a title 7or +O: window ;e.g.. H+ist o7 Depart!ent &u!$ersH<. =t this
point ,ou !a, also speci7, the siCe and positioning o7 the +O:. or this
e3a!ple. leave the! as the de7aults and clic* the &e3t $utton.
The advanced properties relate to how the records should $e 7etched 7or the
+O:. I7 there are !an, hundreds or thousands o7 possi$le records returned $,
the +O:. ,ou !a, consider changing these options. Otherwise. 7or this
e3a!ple. si!pl, clic* &e3t.
In this 7inal step. the +O: is returning so!e colu!ns and the, were assigned to
7ields on the 7or! in a previous step. =t this point. we need to associate the
+O: with a particular ite! on the 7or!. or e3a!ple. $, assigning the +O: to
the -#P+O?--.D&O 7ield. the user will $e a$le to call up the +O: onl,
when the cursor is positioned in the -#P+O?--.D&O 7ield. 'hoose
-#P+O?--.D&O and clic* the &e3t $utton.
inall,. clic* inish to create the 0ecord /roup and the +O:.
In the 7igure $elow. the +O: has $een created. = de7ault na!e o7 +O:) was
given to $oth the +O: and to its associated record group. Depending on what
other parts o7 this tutorial ,ou have co!pleted. the de7ault na!e !a, $e
slightl, di77erent.
Save. 'o!pile and 0un the 7or!. When entering new data. navigate to the
D&O ;Depart!ent nu!$er< 7ield. &otice at the $otto! o7 the 7or!. a !essage
appears4List o9 Values indicating a list o7 values is availa$le 7or this 7ield.
8nder 8&IG and under the Dava $ased applet. the *e, to displa, the list o7
values is 'ontrol6l ;hold down the control *e, ;'trl< and press the letter +<. To
see the appropriate *e,s to press. pull down the )el% !enu and choose
the 5e&s ite!.
"elow is an e3a!ple o7 the list o7 values 7or the D&O ite! on the -!plo,ee
7or!.
D) Non:/ase Ta5le fields
In the previous e3a!ple o7 adding a +ist o7 :alues. the supplied list o7
appropriate values can $e use7ul in cases where the values the!selves are sel76
e3planator,. Bowever. in the prior e3a!ple. the depart!ent nu!$ers !a, not
have !eaning to the user.
It would $e !ore help7ul to include the na!e o7 the depart!ent $oth in the pop6
up list o7 values and on the 7or!. Bowever. the depart!ent na!e is not part o7
the -#P+O?-- ta$le or data $loc*. Thus we need a wa, to displa, this
in7or!ation on the -#P+O?-- data $loc* in a non base table field.
=dding this ite! and !a*ing it 7unctional will ta*e several steps4
1. irst the new ite! will have to $e added to the -#P+O?-- data $loc*.
WeEll call this new ite! D-PT&=#-.
2. &e3t. the D-PT&=#- 7ield should $e populated with the depart!ent
na!e each ti!e the value o7 the D&O 7ield changes. = triFFer will $e
created to handle this 7unctionalit,.
3. inall,. the list o7 values will $e changed to include the Depart!ent
na!e in the +O:.
D))( Adding a New *tem to an 4?isting Data /loc'
Switch to the +a,out -ditor $, clic*ing on the Tools !enu and selecting
the La&out E7itor !enu ite!.
'lic* on the Te3t Ite! tool and create a new 7ield on the
-#P+O?-- $loc* $, clic*ing and dragging the !ouse ne3t to the D&O
ite!.
Displa, the properties 7or the new Te3t Ite! $, dou$le clic*ing on it.
'hange its na!e to D-PT&=#-. 'hange the 7ollowing properties 7or
D-PT&=#-4
4na5led> ?es
Fe05oard Naviga5le> &o
Data5ase *tem> &o
1uer0 Onl0> &o
#rimar0 Fe0> &o
*nsert Allowed> &o
1uer0 Allowed> &o
=pdate Allowed> &o
", setting Me,$oard &aviga$le to No. we prevent the user 7ro! ta$$ing
into this 7ield. Since this 7ield is not used 7or data entr, or quer,ing. this
prevents the potential con7usion.
The Data$ase Ite! propert, is set to No which indicates that this 7iled
does not !ap to an actual colu!n in the -#P+O?-- ta$le.
The re!aining properties are all set to No to *eep the 7ield 7ro!
participating in an, o7 these activities4 Delete. Insert. 8pdate and 2uer,.
=t this point. the new ite! D-PT&=#- has $een added to the -#P+O?--
data $loc* as a non6$ase ta$le 7ield.
Save the 7or! at this point $, pulling down the (ile !enu and choosing
the -aGe option.
D)) Creating a Trigger
&e3t. we will create a trigger to populate the D-PT&=#- 7ield whenever the
value o7 D&O changes. Triggers in Oracle or!s have 7our general 7or!s4
PE- Trigger 7ires $e7ore an event is e3ecuted.
PO-T- Trigger 7ires a7ter an event is e3ecuted.
?)E!- Trigger 7ires in place o7 the e3ecution o7 an event.
5EY- Trigger 7ires when a particular *e, is pressed.
In this e3a!ple. we would li*e to populate the D-PT&=#- 7ield with the
appropriate depart!ent na!e %ust a7ter the D&O 7ield changes on the
-#P+O?-- $loc*. Thus we will use a PO-T-")A!6E trigger on
the :EMPLOYEE.D!O 7ield.
Switch to the O$%ect &avigator view $, clic*ing on the Tools !enu and
choosing the O8IeBt !aGiFator !enu ite!.
Open up the -#P+O?-- data $loc* and the D&O ite!.
'lic* on the Triggers propert, and create a new trigger $, pulling down
the E7it !enu and choosing the "reate !enu ite!.
= list o7 possi$le trigger na!es appears. 'hoose the PO-T-")A!6E trigger
and clic* on the OM $utton.
When the P+1S2+ editor appears. t,pe the 7ollowing P+1S2+ code4

-- Po%ulate tAe non-8ase ta8le 9iel7 :EMPLOYEE.DEPT!AME


-- usinF a Galue 9ro$ tAe DEPATME!T ta8le.
#E6,!
-ELE"T D!AME
,!TO :EMPLOYEE.DEPT!AME
(OM DEPATME!T
?)EE DEPATME!T.D!.M#E K :EMPLOYEE.D!O2
E!D2
Ite!s on a $loc* are preceded $, a 7ull colon to di77erentiate the! 7ro!
colu!ns in a ta$le.
'o!pile the trigger $, clic*ing on the 'o!pile $utton ;this icon is in the
upper le7t corner o7 the P+1S2+ editor window<.
'lose the P+1S2+ editor $, clic*ing on the 'lose $utton.
Save. co!pile1$uild and run the 7or! to test the 7unctionalit,. &otice that when
the -#P+O?-- $loc* is queried. the associated depart!ent na!e now appears
in the new D-PT&=#- 7ield. -ach ti!e the D&O 7ield is changed. the POST6
'B=&/- trigger will 7ire and will 7etch the appropriate D&=#- colu!n 7ro!
the D-P=0T#-&T ta$le and place it in the 4D-PT&=#- 7ield on the 7or!.
D))- Create a new 2ist of Ealues
inall,. a new list o7 values should $e created to displa, $oth the depart!ent
nu!$er and na!e when the user calls up the +O:.
I7 ,ou co!pleted the previous section on creating the si!ple +O:. use the
O$%ect &avigator to delete this +O: $e7ore proceeding with this section.
ro! the O$%ect &avigator. clic* on the +O:s 7or the -#P+O?--
7or!. Pull down the E7it !enu and choose the "reate !enu ite!.
'hoose the +O: WiCard.
T,pe the 7ollowing S2+ state!ent into the 1uer0 Te?t 7ield4
-ELE"T DEPATME!T.D!.M#E+ DEPATME!T.D!AME (OM DEPATME!T
Then clic* on the &e3t $utton.
Include $oth the D&8#"-0 and D&=#- colu!ns 7ro! the 0ecord
/roup in the +O:.
#ap the D&8#"-0 +O: colu!n to the 4-#P+O?--.D&O te3t ite!
and !ap the D&=#- +O: colu!n to the 4-#P+O?--.D-PT&=#-
te3t ite! ;created in the previous section<.
/ive a title 7or ,our list o7 values and return $oth D&8#"-0 and
D&=#- 7ro! the +O:.
inall,. Save. 'o!pile and 0un the 7or!. &ote that displa,ing the +O:
7or the D&O ite! now causes $oth the depart!ent nu!$er and the na!e
to appear.
D)- 4?ercise> Creating an 2OE and Non:/ase ta5le field
or this e3ercise. create a new. single data $loc* 7or! $ased on all o7 the
colu!ns in the D-P=0T#-&T ta$le. Then add a non6$ase ta$le 7ield 7or the
last na!e o7 the depart!ent !anager and create an +O: to populate it4
'reate a new 7or! called 7e%art$F.9$8 that includes all o7 the colu!ns
in the D-P=0T#-&T ta$le. In the la,out wiCard. use
the Ta$ular la,out anddispla, ( 0ecords in the 7or!. =dd a scroll$ar.
In the +a,out -ditor. create a new te3t ite! called #/0F+=STF&=#-
in the D-P=0T#-&T data $loc*. "e sure the D-P=0T#-&T $loc* is
selected when the new ite! is created. 'hange the properties o7
#/0F+=STF&=#- so it is not a Data$ase ite!.
=dd a te3t la$el to this new #/0F+=STF&=#- 7ield.
'reate a list o7 values called +O:F#/0 $ased upon the quer,4
-ELE"T ssn+ lna$e (OM e$%lo&ee
#ap the e!plo,ee.ssn colu!n to the 4D-P=0T#-&T.#/0SS& 7ield.
#ap the e!plo,ee.lna!e colu!n to the
4D-P=0T#-&T.#/0F+=STF&=#- 7ield.
'reate a POST6'B=&/- trigger on the #/0SS& ite! so that when it
changes. the 7ollowing code will e3ecute4
-ELE"T lna$e
,!TO :DEPATME!T.M64LA-T4!AME
(OM e$%lo&ee
?)EE e$%lo&ee.ssn K :DEPATME!T.M6--!2
This will auto!aticall, populate the non $ase ta$le 7ield
#/0F+=STF&=#- on the 7or! when the 7or! is queried.
The 7or! should loo* li*e the 7ollowing4
9) Oracle Forms #rogram =nits and Stored #rogram
=nits
Oracle or!s provides a !echanis! to store procedures ;called Progra! 8nits<
written in the P+1S2+ language within a 7or!. Progra! 8nits can $e used to
add 7unctionalit, that is not possi$le through Structured 2uer, +anguage
;S2+< or through the Oracle or!s inter7ace. So!e e3a!ples o7 Progra! 8nits
were given in the discussion on Progra! 8nits in a #aster6Detail or!. ",
storing a Progra! 8nit within a 7or!. !an, $loc*s in the 7or! can ta*e
advantage o7 the sa!e procedure which reduces code duplication and i!proves
the !aintaina$ilit, o7 the code.
Procedures written in P+1S2+ !a, also $e stored within the Oracle Data$ase
itsel7 as an o$%ect in the sche!a. Such Stored Progra! 8nits ;also called Stored
Procedures< are ideal 7or situations where highl, standardiCed $usiness rules or
applications logic !ust $e i!ple!ented across !an, 7or!s or applications. In
addition. procedures that require several queries $e !ade to the data$ase !a,
$e $est i!ple!ented in the data$ase as this reduces the networ* tra77ic and can
signi7icantl, i!prove per7or!ance. = user !a, create stored procedures with
the Oracle S2+@Plus co!!and line tool.
Oracle or!s can !a*e calls to $oth internal Progra! 8nits as well as to
Stored Progra! 8nits. This 7le3i$ilit, allows application designers e3tensive
control over the e3ecution o7 applications and 7acilitates per7or!ance tuning.
In the 7ollowing sections. e3a!ples o7 Oracle or!s Progra! 8nits and Stored
Progra! 8nits will $e given.
9)( Creating #rogram =nits in Oracle Forms
In this section. we will aug!ent the -#P+O?-- 7or! $, adding a count o7
other !e!$ers o7 a given e!plo,eeEs depart!ent. To add this 7unctionalit,. we
will add a new 7ield ite! to the -#P+O?-- $loc*. write a Procedure in
P+1S2+ to gather the data and then write a Trigger that will call the Procedure
each ti!e a new -!plo,ee record is queried.
9)()( Add a new item to t$e 4,#2O644 /loc'
=dd a new ite! on the -#P+O?-- $loc* to store the count o7 other
e!plo,ees in the depart!ent. See the section on =dding a &ew Ite! to an
-3isting "loc* 7or details.
'all this 7ield OT%4RG,4,/4RS. "e sure it is a non6data$ase 7ield and that
a user will not $e a$le to navigate there. insert. update or delete data in the
7ield. /o to the Properties and chec* each o7 the!4
4na5led> True
Naviga5le> &o
Data5ase *tem> &o
1uer0 Onl0> &o
#rimar0 Fe0> &o
*nsert Allowed> &o
1uer0 Allowed> &o
=pdate Allowed> &o
=dd a la$el to this 7ield $, switching to the +a,out -ditor. choosing the te3t
tool and clic*ing ne3t to the OTB-0F#-#"-0S 7ield.
9)() Create a #rocedure to Count Ot$er Department ,em5ers
In this step. create a Progra! 8nit ;procedure< in Oracle or!s to count the
nu!$er o7 other !e!$ers in the sa!e depart!ent. or this procedure. we will
pass in a para!eter called I&F-#P+O?--FSS& that will contain an
e!plo,eeEs social securit, nu!$er. The procedure will return a value in the
para!eter O8TF'O8&TFOTB-0F#-#"-0S that will contain the nu!$er
o7 other e!plo,ees who are in the sa!e depart!ent.
To create this procedure. switch to the O$%ect &avigator and scroll down to
the #rogram =nits $ranch. Pull down the E7it !enu and choose
the "reate !enu ite!. = dialog $o3 will appear as*ing ,ou to na!e the new
procedure. T,pe in the na!e OT)E4DEPATME!T4MEM#E- and clic* on the OM
$utton.
=t this point. the P+1S2+ editor will appear. T,pe in the 7ollowing procedure
$od,. =n e3planation o7 each part o7 the procedure is given a7terwards4
-- 6iGen an E$%lo&ee:s --!+ return tAe nu$8er o9 otAer e$%lo&ees
-- in tAe sa$e 7e%art$ent.
PO"ED.E OT)E4DEPATME!T4MEM#E- ',!4EMPLOYEE4--! ,! !.M#E+
O.T4"O.!T4OT)E4MEM#E- O.T !.M#E* ,-
TEMP4"O.!T !.M#E2 -- PlaBeAol7er 9or Bount
#E6,!
TEMP4"O.!T :K 02 -- ,nitialiDe to 0
-- Tr& an7 9ill TEMP4"O.!T CitA tAe Bount o9 otAer
-- E$%lo&ees in tAe 7e%art$ent
-ELE"T "O.!T'O*
,!TO TEMP4"O.!T
(OM EMPLOYEE
?)EE EMPLOYEE.D!O K
'-ELE"T EMPLOYEE.D!O
(OM EMPLOYEE
?)EE EMPLOYEE.--! K ,!4EMPLOYEE4--!*2
-- -ee i9 Ce Fot a $eaninF9ul result
,( '!VL'TEMP4"O.!T+ 0* PE 0* T)E!
O.T4"O.!T4OT)E4MEM#E- :K 'TEMP4"O.!T - 1 *2
EL-E
O.T4"O.!T4OT)E4MEM#E- :K 02
E!D ,(2
E!D2
The procedure is written in three !ain sections. =n, lines starting with -- are
co!!ents and are ignored $, Oracle 7or!s.
The heading 7or the procedure de7inition indicates that one para!eter.
I&F-#P+O?--FSS&. is a &8#"-0 data t,pe and the procedure should
e3pect a value to $e passed in. The other para!eter.
O8TF'O8&TFOTB-0F#-#"-0S. is also a &8#"-0 data t,pe and a
value will $e passed $ac* to the calling progra! through it.
To 7inish o77 the procedure header. the T-#PF'O8&T varia$le is declared 7or
use within this procedure onl,.
The "-/I& state!ent starts the $od, o7 the procedure. T-#PF'O8&T is
initialiCed to A and then a quer, is per7or!ed on the data$ase to 7ind the total
nu!$er o7 e!plo,ees in the sa!e depart!ent as the e!plo,ee whose SS& was
supplied to the procedure.
The result in T-#PF'O8&T is chec*ed to see i7 it is a &8++ value. I7
T-#PF'O8&T is not &8++ and it is not A. then
O8TF'O8&TFOTB-0F#-#"-0S is set to equal T-#PF'O8&T61.
Otherwise O8TF'O8&TFOTB-0F#-#"-0S is set to A.
The last -&D state!ent ends the $od, o7 the procedure.
"e sure to chec* to see that the procedure co!piles $, clic*ing on
the "o$%ile $utton. =n, errors in the procedure will $e highlighted. So!e
co!!on pro$le!s include 7orgetting to use :K in an assign!ent state!ent ;li*e
the Pascal language< and leaving o77 the E!D ,( to 7inish up ,( ...
T)E! state!ents.
When done. clic* on the "lose $utton to close the P+1S2+ editor.
9)()- Create a Trigger to Call t$e #rocedure
'reate a trigger to call the OTB-0FD-P=0T#-&TF#-#"-0S procedure.
In the O$%ect &avigator. open up the -#P+O?-- $loc* and the SS& ite!.
Bighlight the Trigger $ranch 7or the SS& ite!. pull down the E7it !enu and
choose the "reate !enu ite!.
= pop up list o7 trigger na!es will appear. 'hoose POST6'B=&/- and clic*
on the OM $utton to open the P+1S2+ editor 7or this new trigger. T,pe in the
7ollowing code 7or the POST6'B=&/- trigger on the SS& ite!4
DE"LAE
return4Bount !.M#E2
#E6,!
-- "all tAe (or$s ProBe7ure to Fet tAe
-- Bount o9 otAers in tAe 7e%art$ent.
OT)E4DEPATME!T4MEM#E-':EMPLOYEE.--!+ return4Bount*2
-- AssiFn tAe return Bount to tAe 9iel7 on
-- tAe EMPLOYEE 8loB3.
:EMPLOYEE.OT)E4MEM#E- :K return4Bount2
E!D2
=gain. clic* on the "o$%ile $utton to $e sure the trigger co!piles correctl, and
then clic* on the "lose $utton to return to the O$%ect &avigator.
9)()7 Save< Compile//uild and Run t$e Form
To this point. we have added a new non6$ase ta$le 7ield to the -#P+O?--
$loc*. written a procedure ;Progra! 8nit< to count other e!plo,ees in the
sa!e depart!ent and added a trigger to call the procedure each ti!e a new
e!plo,ee record is queried.
To save ,ou wor*. use the -aGe As !enu ite! on the (ile !enu and save this
7or! under the na!e4 e$%4$e$8.9$8
Save. 'o!pile1"uild. and 0un the 7or! to chec* its 7unctionalit,. &ote that
when scrolling to a new e!plo,eeEs record. the OTB-0F#-#"-0S 7ield is
auto!aticall, populated with values indicating the nu!$er o7 other e!plo,ees
in the sa!e depart!ent.
9) Creating Stored #rocedures in S123#lus
In the previous e3a!ple. we added a procedure ;Progra! 8nit< in Oracle
or!s to per7or! a quer, on the data$ase. The procedure is stored as part o7
the 7or!Es source code and is co!piled when the 7or! is $uilt. 8pon
e3a!ination. each call o7 this procedure produces4
1. = local call 7ro! the POST6'B=&/- trigger to the procedure passing
an e!plo,eeEs SS&.
2. = re!ote access 7ro! the procedure to the data$ase passing a S2+
quer,.
3. = re!ote return 7ro! the data$ase containing a count.
4. = s!all a!ount o7 processing in the procedure ;I ... TB-&<.
(. = local return 7ro! the procedure to the trigger.
In this e3change. the highest costs are incurred $, the networ* tra77ic required
to go $ac* and 7orth $etween client and server ;steps 2 and 3<. The lowest costs
are incurred $, the local calls $etween trigger and procedure and the local
processing ;steps 1. 4 and (<.
In this e3a!ple. the S2+ 2uer, in steps 2 and 3 does not return a signi7icant
a!ount o7 data. Bowever. there are situations where. i7 a large a!ount o7 data
were to $e returned 7or each quer,. such queries would severel, i!pact
per7or!ance.
One solution to this pro$le! is to !ove the queries and as !uch processing as
possi$le HcloserH to the data in the data$ase. Thus our e3a!ple 7or this section
will $e to i!ple!ent the OTB-0FD-P=0T#-&TF#-#"-0S procedure in
the Oracle data$ase. To achieve this. we will need to use Oracle S2+@Plus ;a
co!!and6line tool< to create a stored procedure.
+og in to S2+@Plus and enter the 7ollowing '0-=T- P0O'-D80-
state!ent. =lternativel,. save this state!ent in a te3t 7ile and e3ecute it using
the -TATco!!and in S2+@Plus.
"EATE PO"ED.E OT)E4DEPATME!T4MEM#E-
',!4EMPLOYEE4--! ,! !.M#E+
O.T4"O.!T4OT)E4MEM#E- O.T !.M#E* A-
-- 6iGen an E$%lo&ee:s --!+ return tAe nu$8er o9 otAer e$%lo&ees
-- in tAe sa$e 7e%art$ent.
TEMP4"O.!T !.M#E2 -- PlaBeAol7er 9or Bount
#E6,!
TEMP4"O.!T :K 02 -- ,nitialiDe to 0
-- Tr& an7 9ill TEMP4"O.!T CitA tAe Bount o9 otAer
-- E$%lo&ees in tAe 7e%art$ent
-ELE"T "O.!T'O*
,!TO TEMP4"O.!T
(OM EMPLOYEE
?)EE EMPLOYEE.D!O K
'-ELE"T EMPLOYEE.D!O
(OM EMPLOYEE
?)EE EMPLOYEE.--! K ,!4EMPLOYEE4--!*2
-- -ee i9 Ce Fot a $eaninF9ul result
,( '!VL'TEMP4"O.!T+ 0* PE 0* T)E!
O.T4"O.!T4OT)E4MEM#E- :K 'TEMP4"O.!T - 1 *2
EL-E
O.T4"O.!T4OT)E4MEM#E- :K 02
E!D ,(2
E!D2
=7ter t,ping in this state!ent. $e sure to .! the co!!and in the S2+@Plus
$u77er $, t,ping .! or $, t,ping the 7orward slash /
&ote4 While creating a stored procedure. ,ou !a, receive an error si!ilar to
the 7ollowing4
OA-010/1: insu99iBient %riGileFes
This indicates the D"= has not granted ,ou the authoriCation to create stored
procedures. Please contact ,our D"= to o$tain this authoriCation.
To see i7 the procedure co!piled correctl,. loo* in view 8S-0F-00O0S as
7ollows4
->LE -ELE"T O (OM user4errors2
no roCs seleBte7
I7 the !essage no roCs seleBte7 appears. then no errors were 7ound in the
trigger.
=nother alternative is to use the S2+@Plus co!!and called sAoC errors. =7ter
su$!itting a trigger or a stored procedure. an, errors 7ound during co!pilation
can $e displa,ed using the sAoC errors co!!and.
In so!e versions o7 S2+@Plus. the sAoC errors co!!and will not wor* due to
a lac* o7 $u77er !e!or, on the client co!puter. =n error !essage !a, appear
as in the 7ollowing e3a!ple4
->LE "EATE PO"ED.E test A-
2 #E6,!
/ -ELE"T -Y-DATE ,!TO :te$% (OM 7ual2
; E!D2
5 /
?arninF: ProBe7ure Breate7 CitA Bo$%ilation errors.
->LE sAoC errors
8u99er oGer9loC. .se -ET Bo$$an7 to re7uBe AAY-,@E or inBrease
MA0DATA.
!o errors.
I7 the 8u99er oGer9loC !essage appears. set the =00=?SIJ- varia$le to a
lower nu!$er such as 2 with the 7ollowing co!!and4
->LE -ET AAY-,@E 2
Then use the sAoC errors co!!and as descri$ed4
->LE sAoC errors
Errors 9or PO"ED.E TE-T:
L,!E/"OL EO
-------- --------------------------------------------
//2/ PL--000;<: 8a7 8in7 Garia8le :TEMP:
To see what stored procedures ,ou have created. quer, the 8S-0FSO80'-
view in the data dictionar,.
The onl, !a%or di77erence $etween the stored procedure created in the data$ase
sche!a through S2+@Plus and the procedure created in Oracle or!s is the
wa, the header is 7or!atted. 'reating a stored procedure uses the 7ollowing
s,nta34
CREATE PROCEDURE OT)E4DEPATME!T4MEM#E-
',!4EMPLOYEE4--! ,! !.M#E+
O.T4"O.!T4OT)E4MEM#E- O.T !.M#E* AS
'ontrast this with the procedure done in Oracle or!s4
PROCEDURE OT)E4DEPATME!T4MEM#E-
',!4EMPLOYEE4--! ,! !.M#E+
O.T4"O.!T4OT)E4MEM#E- O.T !.M#E* IS
Once the OTB-0FD-P=0T#-&TF#-#"-0S procedure ;Progra! 8nit< has
$een created in S2+@Plus. it is stored as an o$%ect in ,our sche!a and will
re!ain there until a DOP PO"ED.E OT)E4DEPATME!T4MEM#E- state!ent is
issued. =n, Oracle or!. 0eport or other procedure can !a*e calls to
OTB-0FD-P=0T#-&TF#-#"-0S as i7 it were a local procedure.
To see the stored procedure in action. open the e$%4$e$8.9$8 7or! and re!ove
;delete< the Progra! 8nit ;procedure< OTB-0FD-P=0T#-&TF#-#"-0S
7ro! it. Save the 7or!. co!pile. generate and run it.
The POST6'B=&/- trigger on 4-#P+O?--.SS& will auto!aticall, !a*e a
call to the stored procedure version o7 OTB-0FD-P=0T#-&TF#-#"-0S
located in the sche!a.
To view the availa$le Stored Progra! 8nits 7ro! within Oracle or!s. switch
to the O$%ect &avigator and open up the Data5ase O58ects tree. ro! there. a
list o7 sche!as ;users< will appear. Scroll down to ,our userna!e and open it
up. Then open up the Stored Progra! 8nits tree. = list o7 ,our stored procedure
should then appear.
9)- Additional Stored #rocedures and Triggers
There are countless wa,s in which stored procedures and triggers can $e used
to en7orce $usiness rules and to process data in an application. In this section. a
7ew o7 the !ost co!!onl, used triggers and procedures are descri$ed.
9)-)( Henerating uni+ue or consecutive identifiers using t$e ta5le
#an, o7 the *e,s used in ta$les are $ased on a nu!$er sequence. or e3a!ple.
in our D-P=0T#-&T ta$le. the D&8#"-0 is an integer that should increase
7or each new depart!ent. To auto!aticall, generate a new D&8#"-0. create
a quer, to capture the largest current D&8#"-0 value and add 1 to it. Then
assign this new value to the D&8#"-0 ite! in the D-P=0T#-&T data
$loc*. = trigger to do this could $e created at the $loc* level and should
e3ecute $e7ore an, new record is inserted into the data$ase. = PE-
,!-ET trigger on the D-P=0T#-&T data $loc* would $e used 7or this
e3a!ple4
#E6,!
-ELE"T MA0' 7nu$8er * L 1
,!TO :7e%art$ent.7nu$8er
(OM 7e%art$ent2
E!D2
= P0-6I&S-0T trigger e3ecutes %ust $e7ore the I&S-0T state!ent 7or a new
record is sent to the data$ase.
9)-) Henerating uni+ue or consecutive identifiers using an Oracle
Se+uence
One pro$le! with the a$ove !ethod is that !an, users wor*ing on the sa!e
7or! to insert new records will run into concurrenc, pro$le!s. or each new
record to $e inserted. a 7ull ta$le scan !ust $e done to 7ind the largest
identi7ier.
One solution to this pro$le! is to use an Oracle Sequence. =n Oracle Sequence
is a sche!a o$%ect that *eeps trac* o7 a si!ple integer and auto!aticall,
incre!ents this counter when it is accessed.
or e3a!ple. in our D-P=0T#-&T ta$le. the D&8#"-0 is an integer that
should increase 7or each new depart!ent. To auto!aticall, generate a new
D&8#"-0. create an Oracle Sequence using the S2+@Plus tool4
"EATE -E>.E!"E 7e%art$ent4seN
,!"EME!T #Y 1
-TAT ?,T) 1
MA0VAL.E <<<<<
!O"Y"LE2
The a$ove 7e%art$ent4seN sequence will $egin counting 7ro! 1 and incre!ent
$, 1 until it reaches >>>>>. =7ter that. accessing the sequence will produce an
error. This is reasona$le since it is highl, unli*el, an organiCation will ever
have !ore than >>>>> depart!ents.
The ne3t step is to assign the ne3t value o7 the sequence to the D&8#"-0
ite! in the D-P=0T#-&T data $loc*. = trigger to do this would $e created at
the $loc* level and should e3ecute $e7ore an, new record is inserted into the
data$ase. = PE-,!-ET trigger on the D-P=0T#-&T data $loc* would $e
used 7or this e3a!ple4
#E6,!
-- 6et tAe neHt Galue 9or D!.M#E 9ro$ tAe
-- 7e%art$ent4seN seNuenBe.
-ELE"T 7e%art$ent4seN.neHtGal
,!TO :7e%art$ent.7nu$8er
(OM 7ual2
E!D2
The 7ual ta$le is a du!!, ta$le that contains e3actl, one record ;row<. We can
use it in a S-+-'T...I&TO state!ent to consistentl, return a single value.
TheneHtGal accessed in the sequence will return the current sequence value and
then auto!aticall, incre!ent it to the ne3t value.
= P0-6I&S-0T trigger e3ecutes %ust $e7ore the I&S-0T state!ent 7or a new
record is sent to the data$ase.
Oracle Sequences are not applica$le 7or !aster6detail 7or!s such as purchase
orders where an ite! nu!$er needs to $e assigned in the detail ta$le. or
e3a!ple. purchase order ite!s are t,picall, nu!$ered4 1+ 2+ /.... The ne3t
PO will also nu!$er the ite!s 1+ 2+ /+ .... =n Oracle Sequence is designed
to deliver unique identi7iers 7or pri!ar, *e,s and should not $e used 7or such
ite! nu!$ers.
9)-)- C$ec'ing constraints at t$e client
In an, data$ase s,ste!. it is alwa,s desira$le to constrain the values certain
colu!ns can ta*e on. It is possi$le to add constraints to the data$ase ta$les
the!selves in order to en7orce constraints. however. the en7orce!ent onl, ta*es
place when a transaction reaches the data$ase. In addition. !an, constraints on
the data that involve values o7 data 7ro! other ta$les !a, not $e easil,
i!ple!ented as ta$le constraints.
#an, t,pes o7 constraints on data can $e chec*ed in the client using triggers.
or e3a!ple. in an -#P+O?-- data entr, 7or!. we !a, want to en7orce a
constraint that no e!plo,ee can act as their own supervisor. Thus 7or an,
record. SS& !a, not equal S8P-0SS&. To i!ple!ent such a constraint. add
the S8P-0SS& ite! to the -#P+O?-- 7or! ;or si!pl, create a new 7or!
7ro! scratch using the wiCard that includes $oth SS& and S8P-0SS&
colu!ns< and then create a ?)E!-VAL,DATE-,TEM trigger on the S8P-0SS& ite!
in the -#P+O?-- data $loc*4
#E6,!
,( ':-.PE--! K :--!* T)E!
ME--A6E':E$%lo&ees $a& not su%erGise tAe$selGesQ:*2
A,-E (OM4T,66E4(A,L.E2
E!D ,(2
E!D2
The O0#FT0I//-0F=I+80- will cause the e3ecution o7 the ite!
validation to $e halted and the user will have to change the S8P-0SS& $e7ore
!oving on to another ite!.
9)-)7 Adding Alerts A#op:up ,essagesB
In the previous e3a!ple. the #-SS=/- procedure is used to displa, the error
along the status $ar at the $otto! o7 the or!s window. = $etter approach !a,
$e to 7orce the userEs attention to the pro$le!. This can $e acco!plished $,
creating a pop6up dialog $o3 that 7orces the user to read the !essage and clic*
an OM $utton ;or so!e other $utton<. In Oracle or!s. this is called an =lert.
To set up an =lert4
8se the O$%ect &avigator to displa, the =lerts area. Pull down the
&avigator !enu and choose 'reate. 'lic* on the de7ault na!e that is
given 7or the new alert ;so!ething li*e =+-0T4< and rena!e
it4 -.PEV,-O4ALET
"ring up the Propert, Palette 7or this =lert and 7ill in the 7ollowing
properties4
Title> Supervisor =lert #essage
,essage> -!plo,ees !a, not supervise the!selvesN
Alert St0le> STOP
/utton ( 2a5el> OM
+eave the /utton 2a5el and the /utton - 2a5el $lan*
Default Alert 5utton> "utton 1
+eave all o7 the other properties with their de7aults and close the
Propert, palette.
'hange the a$ove ?)E!-VAL,DATE-,TEM trigger on the S8P-0SS& ite! in
the -#P+O?-- data $loc* to4

DE"LAE
return4alert !.M#E2
#E6,!
,( ':-.PE--! K :--!* T)E!
return4alert :K -)O?4ALET ':-.PEV,-O4ALET:*2
A,-E (OM4T,66E4(A,L.E2
E!D ,(2
E!D2
The SBOWF=+-0T procedure calls up the speci7ied alert and o$tains
the return value ;$ased on the $utton the user clic*s on< to assign to a
local varia$le called return4alert.
"elow is an e3a!ple o7 the =lert in action4
In general. =lerts !a, provide several di77erent $uttons 7or the user to clic* on.
or e3a!ple. to con7ir! e3iting a 7or!. a POST6O0# trigger !ight invo*e
an H=re ,ou sure ,ou want to -3itH =lert with H?esH and H&oH $uttons. Or. to
con7ir! deleting a record. a P0-6'O##IT trigger !ight invo*e an H=re ,ou
sure ,ou want ot delete this -!plo,eeOH =lert with H?esH and H&oH $uttons.
"ased on the returnFalert value. either a co!!it or roll$ac* !ight $e issued.
9)-). Automatic Forms 1uer0
=s discussed earlier in the tutorial. $, de7ault. when a 7or! runs. the underl,ing
ta$le data is not auto!aticall, queried and displa,ed. It is up to the user to
e3ecute a quer,. 7or e3a!ple. $, pulling down the quer, !enu and choosing
-3ecute.
To auto!ate this process. create a WB-&6&-W6O0#6I&ST=&'- trigger
that navigates to the !aster data $loc* and then issues the -G-'8T-F28-0?
$uilt6in procedure. or e3a!ple. assu!ing the !aster $loc* is na!ed
H-#P+O?--H. the 7ollowing code will cause a quer, to $e e3ecuted
i!!ediatel, a7ter the 7or! opens4
#E6,!
6O4#LO"5':EMPLOYEE:*2
E0E".TE4>.EY2
E!D2
9)-); #opulate items wit$ default values
There are !an, cases where de7ault values can $e suggested 7or certain data
ite!s $ased upon values alread, supplied in other data ite!s. The !ethod here
is to use a POST6IT-# or WB-&6:=+ID=T-6IT-# trigger to populate
another 7ield. onl, i7 the other 7ield is currentl, $lan*. or e3a!ple. to populate
the S8P-0SS& data ite! o7 the -#P+O?-- $loc* $ased upon the #/0SS&
o7 the e!plo,eeEs depart!ent. the 7ollowing WB-&6:=+ID=T-6IT-# trigger
code !ight $e used on the D&O data ite!4
#E6,!
,( :-.PE--! ,- !.LL T)E!
-ELE"T 7e%art$ent.$Frssn
,!TO :e$%lo&ee.su%erssn
(OM 7e%art$ent
?)EE 7e%art$ent.7nu$8er K :e$%lo&ee.7no2
E!D ,(2
E!D2
&ote that the I state!ent uses :-.PE--! ,- !.LL to chec* to see i7 an, value
has $een supplied 7or S8P-0SS&. I7 nothing was t,ped into the S8P-0SS&
data ite!. then its value is &8++. I7 the user t,pes an,thing at all into the
S8P-0SS& data ite!. then the I state!ent will evaluate to 7alse and no value
will $e suggested.
9)-)C Attac$ing functionalit0 to command 5uttons
'o!!and $uttons can $e added on a 7or! to carr, out 7unctions such as e3iting
a 7or!. co!!itting1saving changed records and so on. The $asic co!!and
$utton o$%ect contains properties 7or the $utton +a$el ;the te3t provided on the
$utton itsel7<. =dditional properties include visual attri$utes including the
a$ilit, to displa, a $it!ap i!age in place o7 the $uttonEs nor!al appearance.
Once a $utton has $een ph,sicall, placed on a 7or!. 7unctionalit, is added $ut
writing a ?)E!-#.TTO!-PE--ED trigger. =s one !ight e3pect. this trigger
e3ecutes when the user clic*s on the $utton. So. 7or e3a!ple. to create a $utton
to e3it the 7or! when the user clic*s on it the ?)E!-#.TTO!-PE--ED trigger
!ight loo* li*e4
DE"LAE
return4alert !.M#E2
#E6,!
return4alert :K -)O?4ALET ':E0,T4ALET:*2
,( 'return4alert K alert48uttin1* T)E!
E0,T4(OM2
E!D ,(2
E!D2
The a$ove code assu!es there is an =lert called -GITF=+-0T with two
$uttons4 H?esH and H&oH. I7 the user clic*s on the 7irst $utton ;H?esH< then the
-GITFO0# procedure is called and the 7or! will e3it ;close<. I7 the user
clic*s on an, other $utton. then the =lert will close and the 7or! will re!ain
open.
9)-)D #assing parameters 5etween forms
There are !an, occasions that require the passing o7 data 7ro! one 7or! to
another. One such e3a!ple is when we quer, a certain record on one 7or! and
then wish to call up another 7or! with the sa!e record auto!aticall, retrieved.
In general. data values can $e passed $etween 7or!s using /+O"=+ varia$les
;treat 4/+O"=+ as a $loc* availa$le in all 7or!s< or $, using Para!eter lists.
In the e3a!ple. $elow. the para!eter list 7eatures will $e used to de!onstrate
how data can $e passed 7ro! one 7or! to another.
or this e3a!ple. we wil !a*e use o7 two 7or!s4 = $asic -#P+O?-- 7or!
with all 7ields and the -#P+O?--1D-P-&D-&T !aster1detail 7or! ;created
in aprevious e3ercise 6 the 7ile na!e should have $een e$%7e%n.9$8<. The idea
is to place to $utton on the -#P+O?-- 7or! that when pressed. will call the
-#P+O?--1D-P-&D-&T 7or! and auto!aticall, quer, the dependents 7or
the e!plo,ee $eing viewed on the -#P+O?-- 7or!. The !ain steps are4
On the -#P+O?-- 7or!. create a $utton and la$el it H2uer,
DependentsH.
'reate a WB-&6"8TTO&6P0-SS-D trigger with the 7ollowing code
;co!!ents are enclosed in the code<4

DE"LAE
-- DeBlare %l4i7 as tAe i7enti9ier 9or tAe %ara$eter list
%l4i7 Para$List2
#E6,!
-- -ee i9 tAat %ara$eter list alrea7& eHists. ,9 so+ 7estro& it
%l4i7 :K 6et4Para$eter4List':t$%7ata:*2
,( !OT ,74!ull'%l4i7* T)E!
Destro&4Para$eter4List' %l4i7 *2
E!D ,(2
-- "reate a 9resA %ara$eter list O/
%l4i7 :K "reate4Para$eter4List':t$%7ata:*2

-- A77 a neC %ara$eter to tAis list Balle7 EMPLOYEE--!


-- AssiFn tAis %ara$eter tAe Burrent Galue o9 tAe :--! 9iel7
A774Para$eter'%l4i7+ :EMPLOYEE--!:+ TE0T4PAAMETE+ :--!*2

-- !oC run a neC 9or$ Balle7 :e$%7e%n: '$ust 8e in tAe sa$e


-- 7ireBtor& as tAe e$%lo&ee 9or$ Ce are noC e7itinF.*
-- Pass alonF tAe i7enti9ier o9 our %ara$eter list '%l4i7*
un4Pro7uBt'(OM-+ :e$%7e%n:+ -Y!")O!O.-+ .!T,ME+
(,LE-Y-TEM+ %l4i7+ !.LL*2

-- !ote: ,n neCer Gersion o9 (or$s+ &ou $a& nee7 to Ball


-- 9or$si7 :K (,!D4(OM4O#=E"T':e$%7e%n:*2
-- GieC49or$s :K .!4(OM4O#=E"T'9or$si7+ %l4i7*2
-- or i9 runninF a e%ort 9ro$ a 9or$ &ou $a& nee7 to Ball:
-- re%orti7 :K (,!D4EPOT4O#=E"T':$&re%ort:*2
-- GieC4re%ort :K .!4EPOT4O#=E"T're%orti7+ %l4i7*2
-- !ote tAat :$&re%ort: $ust 8e Breate7 un7er tAe e%orts entr&
in tAe
-- O8IeBt !aGiFator in (or$s
E!D2

&ote4 In >iDS. ,ou !a, need to use either 08&F0-PO0TFO"D-'T or
08&FO0#FO"D-'T.
I!portant note4 ?ou !a, also have to include the 7ull path o7 to the 7ile
na!e o7 the 7or! ,ou are launching with the 0unFProduct 7unction call.
or e3a!ple4
un4Pro7uBt'(OM-+ :7:J$&9ilesJe$%7e%n:+ -Y!")O!O.-+ .!T,ME+
(,LE-Y-TEM+ %l4i7+ !.LL*2
I7 ,ou receive error (M-;0010 "annot rea7 9or$ e$%7e%n.9$H then ,ou
will need to include the 7ull director, path to where ,our 7or!s are
located.
'o!pile and save this 7or!.
&ow open up the e$%7e%n ;-#P+O?--1D-P-&D-&T< 7or!.
8sing the O$%ect &avigator. create a new P=0=#-T-0 called
-#P+O?--SS&. This para!eter will auto!aticall, $e assigned a value
$ased on the para!eter list passed to the 7or! $, the a$ove
08&FP0OD8'T procedure call.
'reate a new trigger called WB-&6&-W6O0#6I&ST=&'-. This
trigger will e3ecute whenever the 7or! is 7irst run.

DE"LAE
-- DeBlare a 9or$s 8loB3 i7enti9er
8l34i7 #loB32
#E6,!
-- O8tain tAe 8loB3 ,D o9 tAe EMPLOYEE 8loB3. TAis is tAe
-- Master 8loB3 in tAe e$%7e%n $aster/7etail 9or$.
8l34i7 :K (in74#loB3':EMPLOYEE:*2
,( !OT ,74!ull'8l34i7* T)E!
-- "AeB3 to $a3e sure our %ara$eter Aas a Galue. ,9 tAis 9or$
-- Cere eHeBute7 8& itsel9+ tAen tAe %ara$eter Cill 8e null.
-- ,9 tAis 9or$ is Balle7 9ro$ EMPLOYEE tAen tAe %ara$eter
Cill
-- 8e %asse7 alonF an7 assiFne7 to :PAAMETE.e$%lo&eessn
,( ':PAAMETE.e$%lo&eessn is not null* T)E!
-- -inBe Ce AaGe a %ara$eter+ use it to alter tAe ?)EE
"lause
-- %ro%ert& so tAat it 8eBo$es ?)EE
ssnK:PAAMETE.e$%lo&eessn
-ET4#LO"54POPETY'8l34i7+DE(A.LT4?)EE+:ssnK: RR
:PAAMETE.e$%lo&eessn*2
-- !aGiFate to tAe EMPLOYEE 8loB3 an7 eHeBute a Nuer&
auto$atiBall&
6O4#LO"5':EMPLOYEE:*2
E0E".TE4>.EY2
E!D ,(2
E!D ,(2
E!D2

'o!pile and save the e$%7e%n 7or!.
&ow run the -#P+O?-- 7or!. quer, an e!plo,ee record and clic* on
the H2uer, DependentsH $utton. The e$%7e%n 7or! should appear with
the dependents auto!atical, queried.
The a$ove e3a!ples are %ust a 7ew o7 the great !an, things one can do with
Oracle or!s. The on6line help that ships with or!s contains !an, e3a!ple
7or!s and e3a!ple pieces o7 code ;see the or!s P+1S2+ 0e7erence< that go
7ar $e,ond the si!ple techniques de!onstrated a$ove.
9)7 4?ercise> #rocedures and Triggers
The 7ollowing are so!e suggested e3ercises using various co!$inations o7
triggers and procedures4
8se a si!ple Depart!ent data entr, 7or! and create an Oracle Sequence
;using S2+@Plus< that will generate new Depart!ent nu!$ers 7or the
D-P=0T#-&T ta$le. =dd the requisite P0-6I&S-0T trigger code to
insert a unique D&8#"-0 each ti!e a new depart!ent record is
created.
=dd a WB-&6&-W6O0#6I&ST=&'- trigger to the a$ove
Depart!ent 7or! that will auto!aticall, quer, the D-P=0T#-&T ta$le
when this 7or! is opened.
8se a si!ple -!plo,ee data entr, 7or! and create an alert that displa,s
a warning i7 an e!plo,eeEs salar, is larger than their supervisorEs. In a
WB-&6:=+ID=T-6IT-# trigger. run a quer, to chec* i7 the
e!plo,eeEs salar, is greater than their supervisorEs and i7 so. show the
alert.
8se the -!plo,ee1Dependent #aster1Detail 7or! ,ou created in e3ercise
5.) and put in so!e validation code that will chec* to !a*e sure i7 a
D-P-&D-&T is a SO& or D=8/BT-0. then the D-P-&D-&TEs
"D=T- !ust $e less than the -#P+O?--Es "D=T-. I7 this is not the
case. show an alert.
=7ter ,ou learn how to create 0eports ;see the ne3t section< create a
si!ple D-P=0T#-&T data entr, 7or! with a $utton that. when
pressed. will run a report 7or that depart!ent ;show all e!plo,ees 7or
e3a!ple< $, passing along the D&8#"-0 as a para!eter.
&ote that ,ou will need to use so!e code in ,our $utton si!ilar to the
7ollowing4
DE"LAE
re%orti7 EPOT4O#=E"T2
GieC4re%ort VA")A2'100*2
re%ort4result VA")A'/0*2
re%4status VA")A2'20*2
-- DeBlare %l4i7 as tAe i7enti9ier 9or tAe %ara$eter list
%l4i7 Para$List2

#E6,!
-- !OTE: ,n or7er to launBA a re%ort 9ro$ (or$s+ &ou $ust AaGe
tAe e%orts serGer
-- runninF on &our loBal $aBAine.
-- At a DO- %ro$%t t&%e: rCserGer -install loBalAost
autostartK&es
-- TAis Cill install a re%orts serGer 9or &our $aBAine
'loBalAost* an7 start it u%.

-- !eHt+ Breate a e%orts O8IeBt in (or$s O8IeBt !aGiFator.
-- TAis is na$e7 SMYEPOTS 9or tAis eHa$%le. TAis re%orts
-- o8IeBt Cill AaGe %ro%erties inBlu7inF tAe %atA to tAe aBtual
-- re%ort 9ile '.r79 9ile* &ou Cant to run.

%l4i7 :K 6et4Para$eter4List':t$%7ata:*2
,( !OT ,74!ull'%l4i7* T)E!
Destro&4Para$eter4List' %l4i7 *2
E!D ,(2
-- "reate a 9resA %ara$eter list
%l4i7 :K "reate4Para$eter4List':t$%7ata:*2

-- A77 a neC %ara$eter to tAis list Balle7 MYD!.M#E


-- !ote tAat in tAe re%ort 8einF Balle7 'e$%re%ort.r79* tAe
-- re%ort Nuer& sAoul7 use :MYD!.M#E in tAe ?)EE Blause
-- as in -ELE"T O (OM e$%lo&ee ?)EE 7no K :MYD!.M#E
-- AssiFn tAis %ara$eter tAe Burrent Galue o9 tAe :D!.M#E 9iel7
A774Para$eter'%l4i7+ :MYD!.M#E:+ TE0T4PAAMETE+ :D!.M#E*2

-- !oC eHeBute tAe re%ort o8IeBt. TAis o8IeBt $ust 8e Breate7


-- in tAe O8IeBt !aGiFator un7er EPOT- 'Iust 8eloC SeBor7
6rou%sS*

re%ort4result :K .!4EPOT4O#=E"T':MYEPOT:+ %l4i7*2

-- "AeB3 on tAe re%ort status an7 loo% until it is 7one


re%4status :K EPOT4O#=E"T4-TAT.-'re%ort4result*2
?),LE re%4status in ':.!!,!6:+:OPE!,!64EPOT:+:E!>.E.ED:*
LOOP
re%4status :K re%ort4o8IeBt4status're%ort4result*2
E!D LOOP2
-- ?Aen tAe re%ort is 7one+ o%en u% a neC Cin7oC an7 7is%la& it
,( re%4status K :(,!,-)ED: T)E!

?E#.-)O?4DO".ME!T':Att%://loBalAost:8888/re%orts/rCserGlet/FetIo8
i7:RR su8str're%ort4result+instr're%ort4result+:4:+-
1*L1*RR:T:RR:serGerKloBalAost:+:48lan3:*2
E!D ,(2

E!D2

(!) Oracle Reports /asics


We now turn our attention to another Developer tool called Oracle 0eports.
The Oracle 0eports "uilder allows the developer to create sophisticated reports
in a variet, o7 la,outs and contains !an, custo!iCation 7eatures. In this
section. the $asic steps 7or creating a si!ple report and a #aster6Detail report
will $e given.
(!)( Starting Developer tools under Windows 9./9D/NT/!!!/"#
= t,pical installation o7 Developer creates several 7olders under the Start
Progra!s !enu.
To run Oracle>i 0eports "uilder under Windows. clic* on the -tart -E
ProFra$s -E OraBle<i DeGelo%er -uite - )o$e -E e%orts DeGelo%er -E
e%orts #uil7er !enu ite!.
8nder 8&IG. run the rC8uil7er.sA script.
=n initial screen will appear4
'lic* on the 'ancel $utton to proceed directl, to the O$%ect &avigator.
(!) T$e Oracle Reports O58ect Navigator
The Oracle 0eports !ain screen is called the O$%ect &avigator ;si!ilar to
Oracle or!s< and can $e seen in the 7ollowing 7igure4
The !ain sections o7 the O$%ect &avigator are4
1. Reports which include4
o Data ,odel 6 'ontains in7or!ation a$out queries used 7or a
report.
o We5 Source 6 = we$ page or we$ service that returns a data set.
o #aper 2a0out 6 'ontains in7or!ation a$out how a paper or
screen a report is 7or!atted including headers. 7ooters. !argins.
7onts. etc.
o #aper #arameter Form 6 'ontains in7or!ation a$out the initial
screen that is displa,ed when a 7or! 7irst runs.
o Report Triggers 6 P+1S2+ code that can $e e3ecuted $e7ore.
during or a7ter a report has $een e3ecuted.
o #rogram =nits
o Attac$ed 2i5raries
2. Templates 6 -3isting te!plates that can $e used to create new reports.
3. #2/S12 2i5raries 6 +i$raries o7 P+1S2+ code.
4. De5ug Actions 6 =ctions the de$ugger is scheduled to trac*.
(. Stac' 6 The current state o7 e3ecution o7 a procedure.
). /uilt:in #ac'ages 6 The $uilt6in pac*ages alread, in the data$ase.
5. Data5ase O58ects 6 Ta$les. sequences. views. etc.
=s with Oracle or!s. the 7irst step in using Oracle 0eports is to 'onnect to an
Oracle server. This is acco!plished $, pulling down the (ile !enu and
selecting the "onneBt !enu ite!.
ill in ,our Oracle 8serna!e and Oracle Password ;press the ta$ *e, to !ove
$etween the 7ields<.
or the Data8ase 7ield. t,pe in the service na!e 7or ,our Oracle data$ase. or
e3a!ple. i7 ,ou are using Personal Oracle +ite. the Data8ase: would
$eOD#":POL,TE. 'ontact ,our s,ste! ad!inistrator to learn the service na!e 7or
,our Oracle data$ase and provide that in7or!ation in the Data8ase: 7ield.
'lic* on the "onneBt $utton to co!plete the connection ;8nder so!e versions
o7 8&IG. the $utton is la$eled O5<. I7 the user na!e or password is !ist,ped or
incorrect. the dialog $o3 will $e re6displa,ed. "e sure to provide ,our Oracle
userna!e and password ;not ,our 8&IG host password<.
(!)- Creating Reports in Oracle Reports
'reating reports 7ollows a 4 step process4
1. De7ine the Data #odel 6 This step speci7ies which queries should $e run
on the data$ase including how !ultiple queries are related and how the,
are grouped. This step !ust $e done $, hand. 2ueries that have $een
created elsewhere can $e i!ported into Oracle 0eports.
2. De7ine the +a,out 6 This step speci7ies the la,out o7 the report including
the overall orientation o7 quer, results and the suppression o7 repeating
groups. There are a nu!$er o7 de7ault report la,outs that can
auto!aticall, $e applied to a data !odel.
3. 'reate and1or 'usto!iCe the Para!eter or! 6 I7 so!e user input is
required in order to run the report. then a para!eter 7or! !ust $e
custo!iCed. =ll reports have a de7ault para!eter 7or!.
4. ;optional< 'reate an, triggers or progra! units that will $e e3ecuted with
the report.
Oracle 0eports version 3.A. )i and >iDS all support a wiCard that ta*es the
developer through all o7 these steps. This approach will $e de!onstrated ne3t.
(!)7 Creating a Single:Ta5le Report
In this section. we go through the steps 7or creating a report that views the
contents o7 a single ta$le.
(!)7)( Specif0 t$e Data ,odel and 2a0out
The 7irst step is to speci7, the data !odel and la,out o7 the report. We will use
the 0eport wiCard to acco!plish this. ro! the O$%ect &avigator. pull down
theTools !enu and choose e%ort CiDar7...
The 7irst screen 7or the reports wiCard will appear as $elow4
The 7irst option is to decide the t,pe o7 report to $e created. Oracle 0eports can
$e created to displa, on a we$ page ;inside o7 a we$ $rowser<. or $, using the
!ore traditional Oracle 0eports runti!e. The latter is called the HPaper
+a,outH. or this e3a!ple. $oth t,pes o7 la,outs will $e created. #a*e certain
the H'reate $oth We$ and Paper +a,outH option is selected and clic* the &e3t
$utton.
The ne3t step in the wiCard pro!pts 7or the st,le o7 the report and 7or the
0eport Title.
The eight la,out choices include4
1. Ta$ular 6 Si!ple ta$le with colu!n headings at the top and data records
in consecutive rows $elow.
2. or! 6 'olu!n headings on the le7t hand side with data values ne3t to
the! on the right.
3. #ailing +a$el 6 &o colu!n headings and records grouped into repeating
sections siCed to print directl, to a sheet o7 !ailing la$els.
4. or! +etter 6 =r$itrar, place!ent o7 data ite!s within a te3t $od,.
(. /roup6+e7t 6 = #aster1Detail1Detail st,le where the !aster records are
grouped on the le7t hand side with details to the right.
). /roup6=$ove 6 = #aster1Detail1Detail st,le where the !aster records
appear a$ove the detail records.
5. #atri3 6 'olu!n la$els on $oth the le7t and the top with data values in
the !iddle. Si!ilar to a spreadsheet.
9. #atri3 with /roup 6 = co!$ination o7 #aster1Detail ;/roup6=$ove<
and #atri3.
or this report. t,pe in H-!plo,ee 0eportH as the title. choose
the Ta5ular +a,out and clic* on the &e3t $utton.
The ne3t step is to speci7, the T,pe o7 quer, the report will $e $ased on.
The 7ive choices are4
1. -3press Server 2uer, 6 a quer, $ased on a stored Oracle -3press Server
;O+=P<
2. DD"' 2uer, 6 = 2uer, posed to a DD"' ;Dava Data"ase 'onnectivit,<
Source
3. S2+ 2uer, 6 = traditional S2+ quer, to an Oracle data$ase
4. Te3t 2uer, 6 = quer, posed against a te3t data source
(. G#+ 2uer, 6 = quer, posed against an G#+ data source ;the
Docu!ent T,pe De7inition ;DTD< o7 the G#+ data source is also
required to use this t,pe o7 quer,<.
or this e3a!ple. choose the HS2+ 2uer,H and clic* the ne3t $utton.
The ne3t step is to speci7, the quer, that will 7or! the $asis o7 the report. In
this case. t,pe the 7ollowing quer, in the S2+ 2uer, State!ent4 te3t $o34
-ELE"T (!AME+ L!AME+ --!+ -ALAY+ D!O
(OM EMPLOYEE 2
or 7uture re7erence. one could also invo*e the graphical 2uer, "uilder at this
step. or choose to i!port a S2+ quer, 7ro! a te3t 7ile.
Once the S2+ S-+-'T state!ent is entered. clic* on the &e3t $utton to !ove
to the ne3t step. &ote4 I7 ,ou did not 'onnect to the data$ase. ,ou will $e
pro!pted 7or the 8serna!e. Password and Data$ase.
In the ne3t wiCard dialog $o3. speci7, which colu!ns 7ro! the S2+ 2uer, will
$e displa,ed in the report output. To speci7, all colu!ns. clic* on the dou$le
right arrow to $ring all o7 the /vailable Fields to the Dis$layed Fields side.
'lic* on the &e3t $utton to !ove to the ne3t dialog $o3.
In the ne3t step. aggregate 7unctions can $e applied to the 7ields on the report.
or this e3a!ple. we will displa, the average salar, as well as a count o7
e!plo,ees. Bighlight the S=+=0? 7ield and clic* on the /verage $utton. Then
highlight the SS& 7ield and clic* on the Count $utton.
The ne3t dialog $o3 allows ,ou to change the 7ield la$els and displa, widths
7or various 7ields in the report.
=s a 7inal step. a design te!plate can $e applied to the report. Design te!plates
include speci7ications 7or 7onts. colors and la,out o7 the report. or this
e3a!ple. choose the H"lueH prede7ined te!plate and then clic* on the inish
$utton.
=7ter a short dela,. the 0eports +ive Previewer will appear showing the report.
It is possi$le to !a*e changes to the la,out o7 the report ;7onts. colors.
positions o7 headings and titles. etc.< $, using the tool palettes and tool $ars.
When ,ou have 7inished touching up the report. close the 0eports +ive
Previewer and the O$%ect &avigator will reappear. To edit the report again. pull
down the Tools !enu and choose e%ort E7itor.
(!)7) Saving< Henerating and Running t$e Report
To save a report. pull down the (ile !enu and choose the -aGe option. This is
si!ilar to saving an Oracle or!. The source code 7or Oracle 0eports are saved
in 7iles with an .r79 7ile na!e e3tension. 'o!piled and generated reports are
saved with a .re% e3tension.
or this e3a!ple. save this report as e$%lo&ee.r79
&ote that report 7iles can also $e saved as static BT#+ or G#+ 7iles as well as
Dava Server Pages ;.%sp< 7iles.
Once the report is saved. it can $e run $, pulling down the ProFra$ !enu and
choosing the un ?e8 La&out or un Pa%er La&out !enu ite!. The Paper
+a,out option will displa, the current report directl, within a window inside o7
0eports "uilder as was seen at the end o7 the report wiCard. The We$ +a,out
will ta*e the current report with a snapshot o7 the data as it is now in the
data$ase and save it to an BT#+ 7ile. The de7ault we$ $rowser will then $e
launched to displa, the 7ile. This is shown in the 7igure $elow4
=s the report is running. an =ctivit, screen will appear giving an indication o7
the processing that is currentl, underwa,.
The =ctivit, will go through 3 stages4 'lient =ctivit, while the queries are
prepared. Server =ctivit, when the queries are e3ecuted and 7inall, 'lient
=ctivit, as the report is 7or!atted. When this is 7inished. the report will appear
on screen.
(!). 4?ercise> Creating a Report
or this e3ercise. create a report to displa, all o7 the records in the
D-P=0T#-&T ta$le including a %oin with the -#P+O?-- ta$le to displa,
the last na!e o7 the depart!ent !anager.
Start up the 0eport wiCard. 8se HDepart!entsH as the title and enter the
7ollowing S2+ State!ent as the quer,4
-ELE"T 7nu$8er+ 7na$e+ $Frstart7ate+ $Frssn+ lna$e+ salar&
(OM 7e%art$ent+ e$%lo&ee
?)EE 7e%art$ent.$Frssn K e$%lo&ee.ssn2
Su!!ariCe the report with an average o7 the Salar, colu!n.
Save the new report as 7e%art$F.r79
The 7inished report should loo* so!ething li*e the 7ollowing4
(!); Creating a ,aster:Detail Report
In this section. the steps 7or creating a report that views the contents o7 two
ta$les in a #aster6Detail ;one to !an,< relationship are given. To avoid an,
con7usion. Save and 'lose an, e3isting reports $e7ore proceeding.
(!);)( Specif0 t$e ,aster:Detail Data ,odel and 2a0out
=s in the single6ta$le report. we $egin $, speci7,ing the data !odel and la,out
7or the #aster6Detail report $, using the 0eport WiCard.
Invo*e the wiCard $, pulling down the Tools !enu and choosing e%ort
CiDar7. ollowing these steps to co!plete the wiCard4
1. 'hoose $oth We$ and Page +a,outs
2. or the 0eport Title use4 Depart!ents and -!plo,ees
3. or the +e$ort Style. choose .rou$ /bove.
4. 'hoose a S2+ State!ent and the S2+ 2uer,4
5. -ELE"T D!AME+ (!AME+ L!AME+ -ALAY
6. (OM DEPATME!T+ EMPLOYEE
1. ?)EE DEPATME!T.D!.M#E K EMPLOYEE.D!O
9. Designate the D&=#- 7ield as a .rou$ field ;+evel 1<. 'lic* on the
D&=#- 7ield and then on the right arrow $utton.
>. Displa, all 7ields in the report.
1A. 'hoose =verage Salar, as a Totals 7ield. 'lic* on the S=+=0? 7ield
and then clic* on the =verage $utton.
11. Touch up the 7ields and la$els as 7ollows4
12. (iel7s an7 Totals La8els
1/. D!AME De%art$ent !a$e
1;. (!AME (irst !a$e
15. L!AME Last !a$e
16. -ALAY -alar&
11. AGF-ALAY%erD!AME AGeraFe:
18. AGF-ALAY%ere% AGeraFe (or all E$%lo&ees:
1>. 8se the "lue pre6de7ined te!plate.
ro! this point. clic* on inish to displa, the +ive 0eport Preview4
(!);) Saving< Henerating and Running t$e ,aster:Detail Report
=t this point. the report can $e saved and -3ecute ;0un<.
or this e3a!ple. save the #aster6Detail report as 7e%t4e$%.r79
(!)C 4?ercise> Creating a ,aster:Detail Report
In this e3ercise. a !aster6detail report will $e created that displa,s each
-#P+O?-- record. with a group o7 D-P-&D-&T $elow.
'reate a new 0eport using the wiCard. /ive a title4 H-!plo,ees and
Their DependentsH
Select the /roup =$ove report t,pe and use the 7ollowing S2+ quer,4
-ELE"T e$%lo&ee.9na$e+ e$%lo&ee.lna$e+
e$%lo&ee.87ate A- E$%#7ate+
e$%lo&ee.seH A- E$%-eH+ 7e%en7ent.7e%en7ent4na$e+
7e%en7ent.87ate A- De%#7ate+
7e%en7ent.seH A- De%-eH+ 7e%en7ent.relationsAi%
(OM e$%lo&ee+ 7e%en7ent
?)EE e$%lo&ee.ssn K 7e%en7ent.essn2
&ote the use o7 colu!n aliases ;=S< to di77erentiate the $date and se3
colu!ns.
Select the lna$e+ 9na$e+ e$%seH+ e$%87ate 7ields as the H/roup 1H
7ields. These should all $e 7ro! the -#P+O?-- ta$le.
Select all 7ields to displa, in the report and do not select an, 7ields 7or
the calculate totals step.
Touch up the report in the live previewer to 7it on one screen.
Save the report as 7ile4 e$%7e%en.r79
The report should loo* si!ilar to the 7ollowing when co!pleted4
(!)D #arameter forms in Oracle Reports
or each o7 the Oracle 0eports e3a!ples thus 7ar. all o7 the records in the
respective ta$les were returned as part o7 the report. Bowever. there !a, $e
situations where onl, a su$set o7 the data$ase records are required. In these
cases. we would li*e to pro!pt the user to enter so!e criteria that can $e used
to 7ilter the report. In Oracle 0eports. a ,arameter Form 7ul7ills this role.
Para!eter 7or!s are si!ple Oracle 7or!s that pro!pt the user 7or so!e
in7or!ation $e7ore a report is e3ecuted. This in7or!ation can $eco!e part o7
the WB-0- clause in the report quer, and is used to 7ilter the records returned
in the report. Para!eters in Oracle 0eports can either $e 7illed in $, the user on
a para!eter 7or! or can $e 7illed in auto!aticall, $, passing the para!eters in
7ro! another Oracle or!s 7or! ;see the e3a!ple o7 para!eter passing in the
previous section on Oracle or!s<.
In the 7ollowing e3a!ple. a si!ple para!eter 7or! is auto!aticall, created $,
Oracle 0eports to restrict a quer, on the -#P+O?-- ta$le $, showing onl,
e!plo,ees in a given depart!ent nu!$er ;D&O< supplied $, the user.
1. 'reate a new report using the report wiCard. Speci7, H-!plo,eesH as the
report title and use a Ta$ular report la,out.
2. 8se the 7ollowing S2+ quer, e3actl, as written. &ote the use o7 the 7ull
colon in the WB-0- clause.
/. -ELE"T O
;. (OM e$%lo&ee
5. ?)EE e$%lo&ee.7no K :D!O4PAAMETE2
In the a$ove quer,. 4D&OFP=0=#-T-0 is the na!e o7 a run ti!e
para!eter. When the report is e3ecuted. the user will suppl, a value 7or
this para!eter thus co!pleting the WB-0- clause 7or the quer,.
'lic*ing on the !eHt $utton will produce the 7ollowing alert4
). 'hoose all o7 the colu!ns ;7ields< 7or displa, in the report. Do not
choose an, 7ields 7or su!!ar, in7or!ation.
5. When the report wiCard is 7inished. the report and para!eter 7or! ;$ased
upon the para!eters given in the S2+ quer,< will $e created. =s the live
previewer is running. the new para!eter 7or! will $e displa,ed4
or this e3a!ple. choose depart!ent ( ;t,pe the nu!$er ( in the 7ield<
and press the enter *e,. &otice that onl, e!plo,ees in depart!ent ( are
displa,ed in the live previewer.
(!)D)( /uilding a Custom #arameter Form
=t this point. whenever the report is run. a de7ault para!eter 7or! showing the
D&OFP=0=#-T-0 will $e displa,ed. Bowever. it is possi$le to create a
custo! para!eter 7or! as shown in the 7ollowing steps.
1. Switch to the O$%ect &avigator. pull down the Tools !enu and choose
the Para$eter (or$ #uil7er. This is shown $elow4
= nu!$er o7 $uilt6in s,ste! para!eters are displa,ed and can $e
highlighted $, clic*ing on the! with the right !ouse $utton. &ote that at
the $otto! o7 this list is the D&OFP=0=#-T-0 and it should alread,
$e selected.
2. or this e3a!ple. in addition to the D&OFP=0=#-T-0 also select the
D-ST?P-. D-S&=#- and 'OPI-S para!eters. Then clic*
the O5 $utton. = new para!eter 7or! will $e auto!aticall, created.
3. Save the report as e$%%ara$.r79. When the 7or! is e3ecuted ;pull down
the ProFra$ !enu and choose un e%ort<. the new para!eter 7or! will
$e displa,ed as shown $elow4
In the a$ove e3a!ple. 1 cop, o7 the report will $e sent to the printer
na!ed HBP +aserDet 4AAA SeriesH. The report will onl, show e!plo,ees
in depart!ent 4.
Other Destination T,pe options include Screen. ile and -6!ail.
Para!eter 7or!s can $e highl, custo!iCed to include list o7 values user
pro!pts and other user67riendl, 7eatures. The techniques used 7or Oracle or!s
can $e easil, applied to para!eter 7or!s in Oracle 0eports.
(() Creating ,enus in Oracle Forms
Please note that as o7 #a,. 2AA4. I have onl, done a $asic update o7 this section
to re7lect the new 7eatures o7 >iDS. There7ore. the 7ollowing section has no
7igures. has not $een tested and !a, not wor* at all.
&ote4 The properties 7or #enus in di77erent versions o7 or!s see! to change with ever, !inor revision.
Please *eep in !ind. the version o7 or!s ,ou are wor*ing with !a, di77er slightl, 7ro! what is shown in
this tutorial.
Thus 7ar. we have covered the $asics 7or creating 7or!s and reports using
Oracle Developer. So!e advanced 7eatures such as using stored procedures
;Progra! 8nits< have also $een introduced.
In a co!plete Data$ase S,ste!. the applications consist o7 !an, 7or!s and
reports that !ight $e used $, a nu!$er o7 users. =ccess to 7or!s and reports is
t,picall, acco!plished through menus. In Oracle Developer. !enus can $e
created to guide users into 7or!s and reports o7 interest. #enus are designed as
part o7 the Oracle or!s "uilder.
In Oracle or!s. ever, 7or! runs with one o7 the 7ollowing4
1. The de7ault !enu which includes the =ction. -dit. "loc*. ield. 0ecord.
2uer,. Window. Belp !enus. The structure o7 the de7ault !enu cannot
$e changed.
2. = custo! !enu that ,ou de7ine as a separate !odule and then attach to
the 7or! 7or runti!e e3ecution.
3. &o !enu at all.
The de7ault !enu is part o7 the 7or! !odule. Bowever. custo! !enu !odules
are separate 7ro! 7or! !odules. So. when a single67or! application runs using
a custo! !enu. there will $e two e3ecuta$le 7iles4
an .(M0 7or! !odule
an .MM0 !enu !odule
In a !ulti67or! application. #ultiple 7or!s can share the sa!e !enu. or each
7or! can invo*e a di77erent !enu.
To e3plicitl, speci7, the de7ault !enu in or!s4
1. Select the na!e o7 the 7or!1!odule in
the O$%ect &avigator. 'lic* with the
right !ouse $utton and
choose Pro%erties 7ro! the pop6up
!enu.
2. In the ,enu ,odule propert,. t,pe
D-=8+TPS#=0T"=0 to get the
To e3plicitl, speci7, the de7ault !enu
in older versions o7 Developer4
1. Select the na!e o7 the
7or!1!odule in the O$%ect
&avigator. 'lic* with the right
!ouse $utton and
choose Pro%erties 7ro! the
pop6up !enu.
de7ault !enu and a $utton $ar $elow it.
I7 ,ou want the 7or! to run without a
!enu. leave the ,enu ,odulepropert,
$lan*.
2. In the ,enu ,odule propert,.
t,pe D-=8+T.
I7 ,ou want the 7or! to run
without a !enu. leave the ,enu
,odulepropert, $lan*.
The de7ault !enu is suita$le 7or control over the current 7or! $eing e3ecuted.
however. it does not contain custo! !enu ite!s pertaining to a speci7ic
application. In the 7ollowing section. the steps to create a custo! !enu
structure will $e introduced.
(()( T$e Oracle Forms ,enu %ierarc$0
The Oracle or!s !enu hierarch, contains three o$%ect categories4
1. ,enu modules 6 +i*e 7or! !odules. a !enu !odule can contain its
own ite!s ;!enus and !enu ite!s<. progra! units and other o$%ects.
2. ,enus 6 Including !ain !enus. individual !enus. and su$!enus
-) ,enu items
(() Creating a Custom ,enu
Designing a custo! !enu requires 7ive $asic steps4
1. 'reating a !enu !odule
2. 'reating !enus and !enu ite!s
3. =ssigning co!!ands to !enu ite!s
4. Saving and generating ;'o!piling< the !enu !odule ;creates the .!!3
7ile<
(. =ttaching a !enu !odule to a 7or!
(())( Creating a ,enu ,odule
The 7irst step in designing a custo! !enu is to create a !enu !odule. There
are several wa,s to create a new !enu !odule4
1. Pull down the (ile !enu. highlight the !eC !enu ite! and then select
the Menu !enu ite!.
2. &avigate down to the ,enus su$tree in the O$%ect &avigator. pull down
the E7it !enu and choose the "reate !enu ite!.
= new !enu !odule will $e created and a de7ault na!e will $e assigned. 'lic*
on this de7ault !enu na!e and assign it a !ore !eaning7ul na!e such
as $&$enu.
(()) Creating menus and menu items
'reating !enus and !enu ite!s can $e acco!plished using the ,enu 4ditor.
To activate the !enu editor. 7irst highlight the na!e o7 ,our !enu. then pull
down theTools !enu and clic* on the Menu E7itor ite!.
The !ain !enu ite!s go across the top o7 the screen. To add a new !enu
across the top. clic* on the /uild Across icon on the tool$ar4
Su$6!enus and !enu ite!s appear $elow each one. To add a new su$6!enu or
!enu ite!. clic* on the /uild Down icon on the tool$ar4
To change the na!e o7 a !enu or !enu ite!. clic* in the !enu o$%ect and
over6write the na!e that appears there.
8sing the icons. create and re6la$el several !enus and !enu ite!s to appear as
7ollows4
Once this is co!pleted. the $asic !enu structure will $e in place. The ne3t step
is to add 7unctionalit, to each !enu ite!.
(())- Assigning Commands to ,enu *tems
The de7ault $ehavior 7or clic*ing on an, !enu is 7or that !enuEs ite!s to $e
displa,ed. The ne3t step is to assign co!!ands to each o7 the !enu ite!s so
that when a user clic*s on a !enu ite!. a 7or!. report or S2+@Plus script is
e3ecuted.
To assign a co!!and to a !enu ite!4
1. Select the desired !enu ite! in the #enu -ditor. 'lic* with the right
!ouse $utton and choose Pro%erties to $ring up the properties o7 that
!enu ite!.
&ote4 The pop6up !enu !a, show Pro%ert& Palette
2. The properties o7 interest here are4
o Command t0pe> Indicates what *ind o7 co!!and should $e run4
or!. 0eport. P+1S2+. other !enu. In general. the P+1S2+
co!!and t,pe is used to launch Oracle or!s and Oracle
0eports. The speci7ic or! and 0eport co!!and t,pes are
!aintained 7or $ac*wards co!pati$ilit, onl,.
o ,enu *tem Code ;or Command Te?t<4 The te3t o7 the actual
co!!and to run.
To run a 7or! 7ro! the !enu ite!. choose Command T0pe P+1S2+.
Dou$le clic* on the ,enu *tem Code ;or Command Te?t< propert,
and t,pe in the P+1S2+ editor4
#E6,!
.!4POD."T'(OM-+ :e$%lo&ee:+ -Y!")O!O.-+ .!T,ME+
(,LE-Y-TEM+ ::+ ::*2
E!D2
08&FP0OD8'T is a P+1S2+ $uilt6in 7unction that runs another Oracle
Developer product. The para!eters to 08&FP0OD8'T are4
o Product4 O0#S or 0-PO0TS
o Docu!ent1#odule4 na!e o7 the 7ile in single quotes ;&ote that
,ou !a, also provide an e3plicit path to the .7!3 7ile here<
o 'o!!and #ode4 S?&'B0O&O8S or =S?&'B0O&O8S
o -3ecuta$le #ode4 08&TI#-
o +ocation4 I+-S?ST-# or D=T="=S-
o Para!eter +ist4 = list o7 para!eters to pass to the 7or! or &8++
o Displa,4 T,pe o7 displa, to show the product on. 'an $e &8++ to
indicate the current displa,. &ote4 Starting with or!s (.A. ;which
uses P+1S2+ version 2.3< ,ou !a, not use &8++ in the call to
08&FP0OD8'T here. ?ou !ust use two single quotes
;indicating a Cero length character string<.
'o!pile this code $, clic*ing on the "o$%ile $utton. Then close the
P+1S2+ editor.
0epeat the a$ove steps 7or each !enu ite!.
= 7inal !enu ite! should $e created to -3it the application. 'all the
!enu4 4?it Application and enter the 7ollowing P+1S2+ code4
#E6,!
E0,T4(OM2
E!D2
-GITFO0# is a $uilt6in procedure that e3its the current 7or!.
= :iew o7 the co!plete $&$enu is show $elow4
(())7 Save and Henerate t$e ,enu ,odule
=t this point. all o7 the !enu structure has $een created and co!!ands 7or each
!enu ite! have $een speci7ied. The !enu !odule !ust now $e saved to a 7ile
;with a .$$8 e3tension< and /enerated or 'o!piled.
To save the !enu !odule. !a*e sure the na!e o7 the !enu is highlighted. pull
down the ile !enu and choose the -aGe !enu ite!. Speci7, a 7ile na!e with
a .$$8e3tension. This is the Hsource codeH 7or the !enu. or this e3a!ple. use
the 7ile na!e $&$enu.$$8.
#re:Oracle9iDS Oracle 9iDS
To generate or co!pile the !enu !odule. pull down
the (ile !enu. clic* on the A7$inistration !enu ite!
and choose 6enerate 7ro! the 7l,out !enu. In so!e
versions o7 the or!s "uilder. the !enu ite! !ight $e
called "o$%ile (ile.
To generate or co!pile the
!enu !odule. pull down
the ProFra$ !enu and
choose 6enerate Mo7ule.
/enerating or co!piling a !enu !odule results in a 7ile with a .$$H e3tension.
In this e3a!ple. the generated !enu !odule $eco!es4 $&$enu.$$H
(()). Attac$ing a ,enu ,odule to a Form
= custo! !enu !ust $e attached to a 7or! in order to $e displa,ed. T,picall,.
a 7or! with no data entr, on it is used as the !ain screen to host the custo!
!enu.
The 7ollowing steps are di77erent depending on the version o7 or!s $eing
used.
For Oracle Forms version 7). For Oracle Forms version ;i Aand laterB
1. 'reate a new 7or! with no $loc*s or
ite!s on it. Pull down the(ile !enu.
select !eC and then select (or$.
2. Displa, the properties 7or the 7or!
and set the ,enu ,odulepropert, to
the 7ile na!e o7 the !enu !odule
;see previous step<. or this e3a!ple.
it should $e4 $&$enu.$$H
3. #a*e sure the =se File propert, is set
to True.
4. Save the 7or! as
7ile 8lan39or$.9$8 and generate this
7or!. ;&ote ,ou should save the this
7or! in the sa!e drive and director,
1. 'reate a new 7or! with no $loc*s or
ite!s on it. Pull down
the (ile !enu. select !eC and then
select (or$.
'lic* on the na!e o7 the 7or! in the
o$%ect navigator and rena!e it
as8lan39or$.
2. Open up the propert, palette 7or the
7or! and set the 7ollowing
properties4
,enu Source4 ile 6 The !enu
in7or!ation will co!e 7ro! a 7ile.
,enu ,odule4 $&$enu.$$H 6 The
7ile na!e o7 the co!piled !enu
!odule. ?ou !a, have to give the
e3plicit path to this .$$H 7ile. or
e3a!ple. i7 this 7ile is on ,our =4
drive then t,pe a:J$&$enu.$$H
as ,our !enuEs .$$H 7ile<.
(. 0un the 7or!.
3. Save the 7or! as
7ile 8lan39or$.9$8 and generate
this 7or!. ;&ote ,ou should save the
this 7or! in the sa!e drive and
director, as ,our !enuEs .$$H 7ile<.
4. 0un the 7or!.
&otice that when running this $lan* 7or!. the de7ault !enu is replaced $,
the $&$enu #enu #odule.
The $lan* 7or! that is used to host the !enu need not $e $lan*. ?ou !a, wish
to use the +a,out -ditor to place so!e graphics and a title o7 the application on
the canvas.
=nother use 7or this space would $e 7or so!e si!ple instructions the user can
read to get started with the data$ase application.
Please 7eel 7ree to use these tutorials 7or ,our own personal use. education.
advance!ent. training. etc. Bowever. I *indl, as* that ,ou respect the ti!e and
e77ort I have put into this wor* $, not distri$uting copies. either in whole or in
part. 7or ,our personal gain. ?ou !a, not under an, circu!stances download.
cache or host copies o7 these tutorials on ,our own servers. 8se o7 these
tutorials 7or co!!ercial training requires a special arrange!ent with the author
or authors.
=ll !aterial 'op,right 1>>562AA4 0. BolowcCa*

Вам также может понравиться