Oracle Forms 10g

download Oracle Forms 10g

of 32

description

Oracle Forms 10g

Transcript of Oracle Forms 10g

  • 5/23/2018 Oracle Forms 10g

    1/32

    Oracle Forms 10g release 2 : Demos, Tips and Techniques

    Home page

    1. Introduction

    Here is a collection of Oracle Forms 10g sample dialogs extracted from a complete OracleForms tutorial.This tutorial has been written in French and it would be too time consuming to translate it all inEnglish.This is the reason why I hae only extracted and translated these sample dialogs.The purpose of this article is not to teach how to build a new form from scratch. It intends toshow some of the main adanced features of the product.To clearly understand in details how these dialogs wor!" you will hae to open them in theForms #uilder and examine them thoroughly.Howeer" in this article" I am going to explain the best I can the most important mechanismsof each sample.These sample hae been tested with an Oracle Forms 10g release 10.1.$.0.$ on an Oracle%atabase 10g Express Edition &elease 10.$.0.1.0.

    2. Description of the sample dialogs

    2.1 Main screen

    http://sheikyerbouti.developpez.com/index_en/http://sheikyerbouti.developpez.com/index_en/
  • 5/23/2018 Oracle Forms 10g

    2/32

    T'TO(FO&)*.F)#

    This dialog is the entry point of the samples. +lic! on a button to start the correspondingdialog.

  • 5/23/2018 Oracle Forms 10g

    3/32

    2.2 an!ases

    TE*T(+,-,*.F)#

    This sample shows three types of canas /

    The content canas light green The stac!ed canas white The tab canas dar! green

    *tac!ed canasA stacked canvas is displayed atopor stacked onthe content canvas assigned to thecurrent window. Stacked canvases obscure some part of the underlying content canvas, and

    often are shown and hidden programmatically. You can display more than one stackedcanvas in a window at the same time, stac!ed canas allows to scroll a big canas in a delimited window.In this sample" the stac!ed canas +(E)2(1 is twice bigger than its iewport.The "Do#n$button allows to moe the stac!ed canas programatically/Set_View_Property('CV_EMP_1', VIEWPORT_Y_POS_ON_CANVAS, 140)

  • 5/23/2018 Oracle Forms 10g

    4/32

    Here are the properties of this stac!ed canas/%ie#portiewport 3 position 44iewport 5 position 11iewport 6idth $1$iewport Height 178&h'sicaliewport 3 position on canas 0iewport 5 position on canas 06idth $1$Height (2)

    The second *tac!ed canas +(E)2(7 demonstrates how to integrate in a Tab canas/

  • 5/23/2018 Oracle Forms 10g

    5/32

    2.( *loc+s2.(.1 *loc+ ased on a comple- !ie#

    TE*T(#9O+('E.F)#

    This sample show how you can base a bloc! on a iew that aggregate the columns of seeral

    tables in this case" %E2T and E)2 and when you can insert" update and delete from thetarget tables from this iew.The code that handles the target table is located in a program unit" called from the threebloc!:leel triggers/

    O-:I-*E&T O-:'2%,TE O-:9O+;

  • 5/23/2018 Oracle Forms 10g

    6/32

    This is the code of the ins_upd_emp_deptprocedure/PROCE!"RE i#$_%p&_ep_&ept IS N!%y PS_INTE*ER + 0 -E*IN .. T/e !EPT .. -e2i#

    See3t 1 I#to N!%y ro !"A W5ere e6i$t$( $ee3t &ept#o 7ro &ept w5ere &ept#o +EMP_!EPT8!EPTNO ) .. o%#& .9 %p&/te .. Me$$/2e('"p&/te !EPT t/e') "P!ATE !EPT SET !NAME +EMP_!EPT8!NAME W:ERE !EPTNO +EMP_!EPT8!EPTNO E63eptio# W5e# #o_&/t/_7o%#& T5e# .. Not 7o%#& .9 i#$ert .. Me$$/2e('I#$ert i#to !EPT t/e') INSERT INTO !EPT ( !EPTNO, !NAME )

    VA"ES ( +EMP_!EPT8!EPTNO, +EMP_!EPT8!NAME ) E#&

    .. T/e EMP .. -e2i# See3t 1 I#to N!%y ro !"A W5ere e6i$t$( $ee3t ep#o 7ro ep w5ere ep#o +EMP_!EPT8EMPNO ) .. o%#& .9 %p&/te .. Me$$/2e('"p&/te EMP t/e') "P!ATE EMP SET ENAME +EMP_!EPT8ENAME W:ERE EMPNO +EMP_!EPT8EMPNO E63eptio#

    W5e# #o_&/t/_7o%#& T5e# .. Not 7o%#& .9 i#$ert .. Me$$/2e('I#$ert i#to EMP t/e') INSERT INTO EMP ( EMPNO, ENAME ) VA"ES ( +EMP_!EPT8EMPNO, +EMP_!EPT8ENAME ) E#& EN!

  • 5/23/2018 Oracle Forms 10g

    7/32

    2.(.2 *loc+ ased on stored procedures

    TE*T(#9O+(2&O+.F)#

    This sample demonstrates how a bloc! can be based on stored procedures.This feature can be implemented in two ways/

    , &EF +'&*O& , 29

  • 5/23/2018 Oracle Forms 10g

    8/32

    #loc!1 E)2" &EF +'&*O& and O-:xxx triggers

    The uer' Data /ource T'peis set to &rocedureand the uer' Data /ourceameindicates the name of the >uery procedure.The insert" update" delete and loc! orders are managed in the corresponding On:xxx triggers/Example of O-:I-*E&T trigger/!ECARE REp ep_p;28ep_re3-E*IN

    REp8ep#o + +ep8ep#o REp8e#/e + +ep8e#/e REp8

  • 5/23/2018 Oracle Forms 10g

    9/32

    This bloc! uses a collection of records with the emp.pkg.emp_!ueryprocedure.

    TYPE ept/ IS TA-E O ep_re3 IN!E> -Y -INARY_INTE*ER

    PROCE!"RE ep_?%ery(ep_&/t/ IN O"T ept/) IS

    ii N"M-ER C"RSOR ep$ee3t IS SEECT ep#o, e#/e,

  • 5/23/2018 Oracle Forms 10g

    10/32

  • 5/23/2018 Oracle Forms 10g

    11/32

    2.(.( *loc+ ased on a relational tale that contains a collection

    TE*T(+O99E+TIO-.F)#

    In this dialog" we can see how to handle a table that contains a nested table collection.There is no standard buit:in to base a bloc! on a collection" but we will see how easy it is towor! with this sort of ob@ect ia the O-:xxx triggers.Here is the description of the table ,&TI+9E*CREATE TA-E ARTICES

    ( CO!E VARC:AR(0 -YTE), I-EE VARC:AR(100 -YTE), PRI> N"M-ER(B,), TETOT N"M-ER(B,0),

    CASES TA-_TYP_CASE )NESTE! TA-E CASES STORE AS CASES_NTRET"RN AS VA"E

    T,#(T52(+,*E is a table of ob@ects of type / T52(+,*E3re/te or rep/3e TYPE TYP_CASE AS O-DECT( EMP VARC:AR(10), TE N"M-ER)

    In this sample" the first bloc! ,&TI+9E* displays the standard columns of the ,&TI+9E

    table and the second bloc! detail displays the columns of its nested table.

  • 5/23/2018 Oracle Forms 10g

    12/32

    &opulate the detail loc+ nested taleThe detail bloc! +,*E* is dynamically populated each time a master record change in a6hen:-ew:&ecord:Instance of the master bloc!/!e3/re

    CRe? V/r35/r(F) -e2i# I7 +ARTICES8CO!E I$ #ot #% T5e# .. !y#/i3 ?%ery o7 $e3o#&/ry o3; .. CRe? + '(SEECT 3/$e$8EMP, 3/$e$8TE ROM TA-E ( SEECT 3/$e$ ROM/rti3e$ W:ERE 3o&e ''' GG +ARTICES8CO!E GG ''') 3/$e$)' *o_-o3;('CASES' ) Ce/r_-o3; Set_Block_Property( 'CASES', !ER"_#AA_S%!RCE_&AE, LC$Re ) ; .. pop%/te t5e o3; .. E6e3%te_%ery *o_-o3;('ARTICES') E$e *o_-o3;('CASES' ) Ce/r_-o3;

    *o_-o3;('ARTICES') E#& i7

    E#&

    #ecause it is not possible to create a new article with a -'99 collection" we hae to handlethe insertion into the ,&TI+9E table in a O-:I-*E&T trigger/................................................................ we /re &oi#2 /# e6pi3it i#$ert e3/%$e t5e #ew re3or& .... 3/##ot 3o#t/i# / N" 3oe3tio# ................................................................INSERT INTO ARTICES ( CO!E, I-EE, PRI>, TETOT, CASES ) VA"ES ( +ARTICES8CO!E, +ARTICES8I-EE, +ARTICES8PRI>, +ARTICES8TETOT, AB_"P_CASE() insert *n empty collection )

    Indeed" if we insert a -'99 collection" it will be no longer possible to insert anything in thenested table.Then after" it is easy to manage the detail records with the O-:xxx triggers of the +,*E*bloc!/O-:I-*E&T/.. I#$ert t5e row i# t5e 3oe3tio# ..INSERT INTO TA-E(

    SEECT 3/$e$ ROM

  • 5/23/2018 Oracle Forms 10g

    13/32

    /rti3e$ W:ERE 3o&e +ARTICES8CO!E)V/%e$( TYP_CASE( +CASES8EMP, +CASES8TE )

    )

    O-:%E9ETE/.. !eete row i# t5e 3oe3tio# ..!EETE ROM TA-E(

    SEECT 3/$e$ ROM /rti3e$ W:ERE 3o&e +ARTICES8CO!E

    ) 3/$e$W:ERE 3/$e$8ep +CASES8EMP

    etc.

  • 5/23/2018 Oracle Forms 10g

    14/32

    2.(.) *loc+ ased on multiple data sources

    TE*T(%,T,(*O'&+E*.F)#

    I this sample dialog" we can see how to base a bloc! on seeral tables that share an identicalstructure.see the A,-IE&" FE&IE& and ),&* tables created by the install.sqlscriptThe list item is populated with the name of three tables that share the same structure/

    Then" the source table of the bloc! is changed dynamically in the 6hen:9ist:+hanged trigger/I7 +CTR8C:OI> i$ #ot #% T5e#

  • 5/23/2018 Oracle Forms 10g

    15/32

    +2o/835oi6 + +3tr835oi6 3e/r_7or +3tr835oi6 + +2o/835oi6 .. 35/#2e t5e %ery !/t/ So%r3e .. Set_Block_Property('ES+', !ER"_#AA_S%!RCE_&AE, glo-*l.C%/0 ); 2o_o3;('TEST') e6e3%te_?%ery

    E#& i7

  • 5/23/2018 Oracle Forms 10g

    16/32

    2.(.3 *loc+ ased on an o4ect tale that contains a collection of references

    TE*T(O#AET*.F)#

    9etBs see how to manage an ob@ect table that contains a collection of references.This sample is based on the ob@ect table ,&TI+9E(O#A that contains a collection ofreferences/

    3re/te or rep/3e TYPE RE_TYP_EMP AS O-DECT( re7_ep RE TYP_EMP)3re/te or rep/3e TYPE TA-_RE_TYP_EMP AS TA-E O RE_TYP_EMP3re/te or rep/3e TYPE TYP_ARTICES AS O-DECT( CO!E VARC:AR (0), I-EE VARC:AR (100), PRI> N"M-ER (B,), TETOT N"M-ER (B), REMP TA-_RE_TYP_EMP .. 3oe3tio#)CREATE TA-E ARTICES_O-D O TYP_ARTICES

  • 5/23/2018 Oracle Forms 10g

    17/32

    NESTE! TA-E REMP STORE AS REMP_NTRET"RN AS VA"E

    The tip is the same that the one used to manage the relational table with nested table/

    : , when:-ew:&ecord:Instance trigger on the master bloc! to populate the detail bloc! thecollection of references/!e3/re CRe? V/r35/r(F) -e2i# I7 +ARTICES8CO!E I$ #ot #% T5e# .. !y#/i3 ?%ery o7 $e3o#&/ry o3; .. CRe? + '(SEECT ep8re7_ep8ep EMP, ep8re7_ep8?te TE ROM TA-E( SEECT REMP ROM /rti3e$_o< W:ERE CO!E ''' GG+ARTICES8CO!E GG ''') ep W:ERE ep8re7_ep8/rt ''' GG +ARTICES8CO!E GG ''')' *o_-o3;('CASES' )

    Ce/r_-o3; .. 35/#2e t5e %ery !/t/ So%r3e N/e .. Set_Block_Property( 'CASES', !ER"_#AA_S%!RCE_&AE, LC$Re ) ; .. pop%/te t5e o3; .. E6e3%te_%ery *o_-o3;('ARTICES') E$e *o_-o3;('CASES' ) Ce/r_-o3; *o_-o3;('ARTICES') E#& i7

    E#&

    : ,n O-:I-*E&T trigger to insert a new record with an empty collection/

    ......................................................... We /re &oi#2 /# ipi3it i#$ert e3/%$e t5e #ew .... re3or& 3/##ot 3o#t/i# / N" 3oe3tio# .........................................................INSERT INTO ARTICES_O-DVA"ES( TYP_ARTICES ( +ARTICES8CO!E, +ARTICES8I-EE, +ARTICES8PRI>, +ARTICES8TETOT, AB_RE1_"P_EP()

    ))

    The collection of references is managed with the corresponding O-:xxx trigger of the detailbloc!/O-:I-*E&T/.. I#$ert / row (RE) i# t5e 3oe3tio# ..!e3/re CRe? V/r35/r(F) -e2i#

    CRe? + 'INSERT INTO TA-E ( SEECT rep ROM ARTICES_O-D W:ERE 3o&e ''' GG +ARTICES8CO!E GG''')

  • 5/23/2018 Oracle Forms 10g

    18/32

    VA"ES ( RE_TYP_EMP ( (SEECT RE(/) ROM EMP_O-D / W:ERE /8ART ''' GG +ARTICES8CO!E GG ''' AN! /8EMP ''' GG +CASES8EMP GG''') ) )'

    or$_!&( CRe? )

    E#& O-:%E9ETE/.. !eete t5e row (RE) o7 t5e 3oe3tio# ..!EETE ROM TA-E ( SEECT rep ROM ARTICES_O-D W:ERE 3o&e +ARTICES8CO!E ) epW:ERE ep8re7_ep8/rt +ARTICES8CO!EA#& ep8re7_ep8ep +CASES8EMP

  • 5/23/2018 Oracle Forms 10g

    19/32

    2.) Items

    2.).1 &rincipal items

    TE*T(ITE)*.F)#

    Here is a description of the main items.+lic! eerywhere on each item to see some information messages and some particularbehaiours.

  • 5/23/2018 Oracle Forms 10g

    20/32

    2.).2 5ist items

    TE*T(9I*TE*.F)#

    9etBs study and handle the three sorts of list item and also the different ways to populatethem.In this sample" the three list items are synchroniCed. +hange the alue of the first list and itwill adapt the content of the second then the content of the third.For each new list alue" the corresponding alue and label are displayed.

    a The first list item is populated with the &?()OI* record group/.. i$t 1 ..

    err3o&e + Pop%/te_*ro%p( 'R*_MOIS' )

    CEAR_IST('-OC8ISTE1') P%P!LAE_L/S('BL%C+.L/SE2', 'R3_%/S' ); .. See3t t5e 7ir$t H/%e .. +-OC8ISTE1 + *et_i$t_Eee#t_V/%e('-OC8ISTE1', 1 )

    b Then init the second list item

    .. "p&/te t5e wee;$ i$t .. err3o&e + Pop%/te_*ro%p( 'R*_SEMAINES' )

    CEAR_IST('-OC8ISTE') P%P!LAE_L/S('BL%C+.L/SE+', 'R3_SEA/&ES' );

    .. See3t t5e 7ir$t H/%e .. +-OC8ISTE + *et_i$t_Eee#t_V/%e('-OC8ISTE', 1 )

    c That finally init the third list item/PROCE!"RE I#it_i$te IS C! V/r35/r(1) C!/y V/r35/r(0) -E*IN .. "p&/te t5e &/y$ i$t ..

    C! + '01J01J00' Ce/r_i$t( '-OC8ISTE' )

  • 5/23/2018 Oracle Forms 10g

    21/32

    or i IN 088F oop SEECT to_35/r( To_&/te(C!, '!!JMMJYYYY' ) @ (i @((To_#%er(+-OC8ISTE).1) K L)), 'M!/y !! Mo#t5' ) I#to C!/y ROM &%/

    A44_List_Element('BL%C+.L/SE5', i 6 2, LC$#*y, LC$#*y ) ;

    E#& oop

    .. See3t t5e 7ir$t H/%e ..

    +-OC8ISTE + *et_i$t_Eee#t_V/%e('-OC8ISTE', 1 ) E63eptio# W5e# Ot5er$ t5e# N% EN!

  • 5/23/2018 Oracle Forms 10g

    22/32

    2.).( Image items

    ,9#')(2HOTO.F)#

    This dialog is the main part of the ensemble that allows to search" attach and display images.5ou can build a photo album based on a one imageBs column table.

    CREATE TA-E P:OTOS ( E*EN!E VARC:AR(100 -YTE), P%% BL%B &% &!LL E&ABLE, ORMAT VARC:AR(0 -YTE) NOT N" ENA-E, CRE!IT VARC:AR(0 -YTE) NOT N" ENA-E, IEN VARC:AR(100 -YTE), I!ENTIIANT N"M-ER(,0) NOT N" ENA-E,

    NOM VARC:AR(0 -YTE), CONSTRAINT P:OTO_P PRIMARY EY (I!ENTIIANT) ENA-E )

    It shows two ways to search a filename on the local machine with and without 6ebutil.

    #y clic!ing on a picture" you can naigate on another canas to display the detail of thepicture/

  • 5/23/2018 Oracle Forms 10g

    23/32

  • 5/23/2018 Oracle Forms 10g

    24/32

    +H,&?E(2HOTO.F)#

    The get6file6namesample dialog is only a Dpure exercice of style " because it is so easy topic!:up a file with the "ile_#pen_$ialog(6ebutil function.This sample is interesting to see how to use the %#S&(and &'&_)#(functions to get thelist of the local machine dries and their content.

  • 5/23/2018 Oracle Forms 10g

    25/32

    +H,&?E(2HOTO(6E#'TI9.F)#

    ,nother dialog to store the picture and its properties.

  • 5/23/2018 Oracle Forms 10g

    26/32

    2.).) 7a!a *ean component

    TE*T(?&,2H.F)#

    Here is a sample to demonstrate how to handle a bean area.This dialog use the Oracle Forms?raph Aaa #ean that is part of the Oracle Forms demos.5ou can download the Forms?raph.@ar file on the OT- pagehttp/

  • 5/23/2018 Oracle Forms 10g

    27/32

    2.).3 alculated items

    TE*T*(+,9+'9.F)#

    9etBs see how to use the calculated items.The first calculated item use the /ummar'calculation mode/

    The third one use a Formulacalculation mode

  • 5/23/2018 Oracle Forms 10g

    28/32

    2.3 8lerts

    TE*T(,9E&TE*()E**,?E*.F)#

    This dialog shows how to use the ,lert boxes to build the messaging engine of your Formsapplication.The message texts are read from the database then displayed ia ,lert boxes.To reduce the number of messages needed in the application" some of them can ta!e from 1up to 7 parmeters G1" G$ and G7. , pipe character allows to split the message onseeral lines.The main bloc! is based on the M9//89/table.

    CREATE TA-E MESSA*ES ( CO!E N"M-ER(,0) NOT N" ENA-E, .. %#i?%e i&e#ti7i/#t TE>TE VARC:AR(F) NOT N" ENA-E, .. te6t o7 t5ee$$/2e TITRE VARC:AR(100), .. tite o7 t5e /ert STOP VARC:AR(1) !EA"T 'N' NOT N" ENA-E, .. S5/ we $top t5epro3e$$ (r/i$e 7or_tri22er_7/i%re) AERTE VARC:AR(1), .. #/e o7 t5e /erto6 CONSTRAINT MS*_P PRIMARY EY (CO!E) ENA-E )

    This sample use theAffiche_*essage(procedure of the T;TO6FO

  • 5/23/2018 Oracle Forms 10g

    29/32

    ,9(E&&E'& wich is the simple DO; alert box. ,9()*?(O'I(-O- wich is a yes

  • 5/23/2018 Oracle Forms 10g

    30/32

    2.= &ropert' classes and !isual attriutes

    TE*T(+9,**E*(2&O2.F)#

    9etBs see some ways to use the property classes and the isual attributes to coloriCe andhighlight dynamically different ob@ects of the form alert" item" current record" etc..2roperty classes and isual attributes are located in the O*76T;TO6FO

  • 5/23/2018 Oracle Forms 10g

    31/32

    2.> Forms internal triggering e!ents

    TE*T(+5+9E*.F)#

    This dialog allows you to understand what trigger fire and in what order when you use theapplication.#efore each particular action" you can clear the list of triggers window.This window show you what trigger is firing in what order and from what bloc! and what item.

    (. Installation steps

    This sample dialog need database ob@ects to run.,ll the necessary ob@ects are proided in the tutoforms10g.Cip file shipped with the article.

    This Cip file contains $ sub directories/?configthat contains the configuration files.?scriptsthat contains the *>l script files to create the database ob@ects.

    %ownload the tutoforms10g.Cip file

    'nCip the tutoforms10g.Cip file under your "D9%/;IT96@OM9$?forms? directory.

    http://sheikyerbouti.developpez.com/tutoforms10g/files/tutoforms10g.ziphttp://sheikyerbouti.developpez.com/tutoforms10g/files/tutoforms10g.zip
  • 5/23/2018 Oracle Forms 10g

    32/32

    +reate a new user in your database

    6ith *>lplus or *>l%eeloper" run the?scripts?install.sqlscriptnote / because this demo use the 6ebutil functions" the Oracle user where you haecreated these ob@ects must hae the WE-"TI_!- pac!age compiled or a grant

    E3E+'TE to this pac!age if it is present in another schema.

    'nder the?tutoforms?directory compile all the source modules

    5ou can use the compile6all.atfile located in the same directory to compile allob@ects at once. e.g. 3opie_/ %$erJp/$$wor&i#$t/#3e

    Edit the?tutoforms?config?tutforms10g.en!file to indicate your own settings inblue in this example

    Joracle home adapt this alue to your own settingO&,+9E(HO)EKD:ADe!10g