+ All Categories
Transcript
  • 8/10/2019 Oracle Forms Developer Tutorial

    1/49

    Oracle Forms Builder tutorialWelcome to the Oracle Forms Developer tutorial. The objective of this tutorial is to letyou to familiarize yourselves with the forms development process. We will be

    creating a form with the same functionality as the sample form you have seen inclass.

    NOTE :

    lease read !hapter " from your lab manual before you start this tutorial. Open the

    #$% window and log into your account. Type in the following command

    select * from tab;

    NOTE :

    &tab& is a table that stores names of all tables in your account.

    'll tables with (#)( are a part of the database schema. We will be using only a partof the database schemafor this tutorial. This part consists of the following tables:

    #)O*D

    #)!+#TO,-*

    #)T-,

    #)-,

    #)*OD+!T

    #tart the O!/0 instance before you proceed.

    *emember to #'1- your wor2 at regular intervals.

    #tart Oracle Forms 3uilder. 4ou will see the following welcome screen:

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/pics/ER.jpghttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/pics/ER.jpg
  • 8/10/2019 Oracle Forms Developer Tutorial

    2/49

    For creating a new form click 'OK'. Step 2The Data Block Wizard

    5."

    !lic2 (6e7t( to leave the Welcome #creen.

    5.5

    #elect (Table or 1iew( and !lic2 (6e7t(

    NOTE :

    (Table or 1iew( lets you create data bloc2s based on a table or a view created on the

    Oracle Database #erver.

    5.8

    4ou will now see the following dialogue bo7. !lic2 on (3rowse(. ' small (!onnect(bo7 appears. -nter your %ogin information and clic2 (!onnect(.

  • 8/10/2019 Oracle Forms Developer Tutorial

    3/49

  • 8/10/2019 Oracle Forms Developer Tutorial

    4/49

    ,a2e sure that the !hec2 bo7es for (!urrent +ser( and (Tables( are chec2ed. f you

    are creating a data bloc2 based on a 1iew then the (1iews( chec2 bo7 has to bechec2ed.

    This will show you the list of all the tables in your account. We will first create a databloc2 based on the #)O*D Table. #elect that table from the list and clic2 (O9(

    5.

    4ou will now see all the columns of the #)O*D table under ('vailable !olumns(. !lic2

    the (>>( sign to select all of them to (Database tems(. !lic2 (6e7t( to proceed.

    5.;

  • 8/10/2019 Oracle Forms Developer Tutorial

    5/49

    We will retain the table name (#)O*D( as the name for the new data bloc2. !lic2

    (6e7t(

    5.>( sign to select all of them to (Database tems(. !lic2 (6e7t( toproceed.

    8.

  • 8/10/2019 Oracle Forms Developer Tutorial

    7/49

    The data bloc2 wizard realizes that the data bloc2 being created is based on a detail

    table. t gets this information from the foreign 2ey constraint (#)T-,)O*D)F9( andas2s you to confirm the same. !lic2 (O9(. The dialogue bo7 shows the foreign 2ey

    relationship as the join condition.

  • 8/10/2019 Oracle Forms Developer Tutorial

    8/49

    !lic2 herefor a Cuic2 presentation to understand the role of foreign 2eys in a

    relational database.

    n some cases a detail bloc2 may have more than one ,aster 3loc2s. n such ascenario press the (!reate *elationship( button again and select the other foreign

    2ey constraint. The (,aster Data 3loc2s( field in the above dialogue bo7 will then

    have two bloc2s listed. *epeat the procedure of every master bloc2. Whathappens if create #)T-, ?detail@ bloc2 first and then the #)O*D ?master@

    bloc2 n other words is the seCuence in which data bloc2s are created important

    !lic2 Eereto find the answer. 8.=

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/vsd.ppthttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut3.htm#answer1http://www.rhsmith.umd.edu/is/aqiuol/tutorial/vsd.ppthttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut3.htm#answer1
  • 8/10/2019 Oracle Forms Developer Tutorial

    9/49

    We will retain the table name (#)T-,( as the name for the new data bloc2. !lic2(6e7t(

    8.We will create a %ayout later. #elect (0ust create a data bloc2( and clic2 Finish.8."G' new data bloc2 called (#)T-,( has been created. >o to the object navigator?F8@ to chec2 this. The O30-!T 6'1>'TO* will loo2 li2e this

    NOTE :

    The #)O*D gets a relations item called (#)O*D)#)T-,( which documents

    the foreign 2ey relation between the two bloc2s. Double !lic2 on the icon ne7tthe the relation and open the roperty alette to verify the 0oin !ondition.

    (O6HO+%'T-HD-T'%#( and (O6H!E-!9HD-%-T-H,'#T-*( are two triggers

    that forms developer automatically creates to facilitate coHordination between

    related data bloc2. To learn more about these trigger ress Eelp ?!T*%AE@.

    -I-*!#)!+#TO,-*. lease 2eep in mind that #)!+#TO,-* and #)O*Dhave a ,asterHD

  • 8/10/2019 Oracle Forms Developer Tutorial

    10/49

    4ou should now have three data bloc2s and two relations items in your forms file.lease save the file and proceed. The Object 6avigator loo2s something li2e this at

    this stage.

    We will now start creating the form to accept customer orders. This form will thus

    have to contain items from two data bloc2s namely #)O*D and #)T-,. %et us start

    with the #)O*D bloc2. Step 4

    The Layout Wizard: reati!" a Layout #or $aster Bloc%&

  • 8/10/2019 Oracle Forms Developer Tutorial

    11/49

    /."

    Right-Click the icon for S_ORD data block in the OBJC! "#$%!OR. Select (a)o*t +i,ard. !hi

    will bring * the +elcome creen. Click "e/t

    /.5

    %n the ne/t dialog*e bo/ elect 0"ew Can1a2. !he dro down men* for !34 how 1ario* can1a

    la)o*t t)le. #t thi moment we hall *e the imlet of them all 5 Content.

    !lic2 Eerefor the answer. /.8!he ne/t dialog*e bo/ ak )o* to chooe the item from the block that will act*all) be 1iible on the

    can1a. Select all of them b) reing the >> b*tton. Click "e/t to roceed. /./Change the nameof the label *nder 4romt. !he defa*lt name gi1en to the item i alwa) the col*mn name in the baetable which ma) not alwa) be *ef*l to the end *er. (ea1e the width and height *nchanged. !hee can be

    changed b) iml) tretching the item on the can1a. Click "e/t

    /.;

    !)e in 5 ORDR D!#%(S in the frame title field. Click "e/t. Click Finih on the ne/t age. !he

    la)o*t wi,ard will now create a defa*lt la)o*t for )o*. #lo in the OBJC! "#$%!OR *nder

    C#"$#SS )o* will find a new can1a ob6ect with a defa*lt name. Click !wice 0 not a double click2 on it

    and rename it to ORDR_C#"$#S. !he (a)o*t will look a hown below5

    NOTE :Ob6ect name cannot contain ace. ORDR C#"$#S i not a 1alid name.

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut4.htm#answer2http://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut4.htm#answer2
  • 8/10/2019 Oracle Forms Developer Tutorial

    12/49

    We have to now add a button which will allow us to save the data entered in the formin the respective table ?#)O*D@. The resulting form will have minimal functionality.

    We can further enhance the form by customizing it. Step ' (a)

    *ddi!" a sa+e ,utto!

    STE- ' (a)lacing a button on the canvas. ?a@."!lic2 the (ush 3utton( icon onthe canvas toolbar ?shown below@ and then clic2 once on the canvas.

    ' new push button with default properties will be created. Forms builder will give ita default name li2e (+#E)3+TTO6"/(. 4ou can drag and place the button any

    where on the canvas.

    NOTE :

    The ush 3utton is automatically placed in the same data bloc2 ?#)O*D@ as the databloc2 on the current canvas.

    [email protected]

    On the canvas double clic2 on the ush button to open its *O-*T4 '%-TT-. n the

    value for the (%'3-%( field enter (#+3,T( or (#'1-( to indicate the function of thebutton.

    [email protected]

    Try running the form. !lic2 herefor instructions for running a form. Try clic2ing on

    the ush 3utton H nothing happens. This is because we still have not told Formsbuilder what to do once the button is clic2ed. This is done entering %J#$% code in a

    trigger. lease refer to the lab manual for more information on triggers. 't this

    moment it is enough for you to 2now that triggers are bloc2s of code that are

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htmhttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htm
  • 8/10/2019 Oracle Forms Developer Tutorial

    13/49

    e7ecuted when a particular event occurs. n this case we need certain code to bee7ecuted when the (#ubmit( button is pressed. #o we use what is called a WE-6H

    3+TTO6H*-##-D trigger K Eere is how the form would loo2:

    NOTE :

    The green bac2 ground is the default color for the form. This can be easily changed

    using the canvas toolbarL though at the moment we will not bother ourselves with

    such cosmetic details. Step '(,)

    reati!" a W.EN/B0TTON/-1ESSED tri""er

    STE- '(,)

    'ssociating some %J#$% code with the push button

    ?b@."

    On the O*D-*)!'61'# right clic2 on the (#ubmit( 3utton. #elect (%J #$% -ditor(

    from the menu. This will bring up a list of triggers that can be associated with thepush button. #elect (WhenH3uttonHressed( from this list.

  • 8/10/2019 Oracle Forms Developer Tutorial

    14/49

    [email protected]

    Once you select the trigger forms builder will open a %J#$% -ditor window. This iswhere you input %J#$% code that has to be e7ecuted when the (#ubmit( button is

    pressed. For saving information through a form we use the following line of code:

    commit_form;

    [email protected]

    !ompile the %J#$% code by clic2ing on the first button on the toolbar for the %J#$%-ditor.

  • 8/10/2019 Oracle Forms Developer Tutorial

    15/49

    NOTE :

    4ou should get a (6ot ,odified H #uccessfully !ompiled( message as shown in the

    picture above. 'ny errors generated during the compilation process will be shown inthe bottom part of the editor window.

    ?b@./

    !lose the %J#$% -ditor window and run the form. !lic2 herefor instructions for

    running a form.

    The data we enter in this form will be saved to the #)O*D table. We have to consider

    the rimary 9ey and Foreign 9ey !onstraints before we enter data. The primary 2eyconstraint stipulates that every record in the #)O*D table should have a uniCue

    primary 2ey ?D@. 'lso the Foreign 2ey constraints lin2 the #)O*D table to the#)!+#TO,-* and #)-, table.

    n short we have to :

    ".@ #elect a D ?primary 2ey@ that is not in the #)O*D table.

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htmhttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htm
  • 8/10/2019 Oracle Forms Developer Tutorial

    16/49

    5.@ #elect (!ustomer d( and (#ales *ep D( ?foreign 2ey@ from #)!+#TO,-* and#)-, tables.

    Follow steps ?b@. and ?b@.; to do this

    ?b@.

    Open the #$% Window H rograms MM Oracle 'pplication #erver MM 'pplication

    Development MM #$% lus.

    ?b@.;

    *un the following commands. select i! from s_or!;!hoose any number that is!otin the list of numbers returned. This will be our +6$+- primary 2ey for a new

    order. select i! from s_customer;!hoose any number from the list of numbersreturned. This will be our input in the (!ustomer d( field.

    select i! from s_em";!hoose any number from the list of numbers returned. This will be our input in the(#ales *ep d( field.

    NOTE

    We cannot e7pect users of the system to understand and do the things we did in theprevious step. To avoid this we need to !+#TO,N- the form. We will learn a few

    common types of customizations in later parts of the tutorial.

    [email protected] to the Object 6avigator and e7pand the #)O*D bloc2 to see the items containedwithin the bloc2. Double H !lic2 on the ('4,-6T)T4-( icon to bring up its

    *O-*T4 '%-TT-.

  • 8/10/2019 Oracle Forms Developer Tutorial

    19/49

    ;[email protected]

    !lic2 on the drop down menu for the T-, T4- field and select *adio >roup as theT-, T4-.

    ;[email protected]

    Type !'#E as the field value for 6T'% 1'%+- and close the *O-*T4 '%-TT-.

    NOTE :

    #etting (!'#E( as the initial value for the radio button ma2es !'#E the default

    option.

    ;?b@./

    n the roperty alette e7pand the ('4,-6T)T4-( item. !lic2 on the (*adio3utton( field and press the >reen (A( in the Object navigator toolbar TW!- ?since

    we have !'#E and !*-DT as our options@. 4ou will see two radio buttons created inthe Object 6avigator with default names li2e (*'DO)3+TTO6""( and

    (*'DO)3+TTO6"5(. *ename them as (!'#E( and (!*-DT(.

    ;?b@.

    Open the *O-*T4 '%-TT- for the (!'#E( radio button by a double clic2 on itsicon. !hange values of the (%abel( and (*adio 3utton 1alue( as shown in the picture

    below

  • 8/10/2019 Oracle Forms Developer Tutorial

    20/49

    NOTE :

    *adio button value is the actual data that gets saved to the database.

    ;?b@.;

    *epeat #tep ;?b@. for the !redit *adio 3utton. #et *adio 3utton 1alue to !*-DT.

    ;?b@.>-* called *-H6#-*T trigger. This trigger is fired just

    before forms developer saves data to the table. Since we have used the WHEN-

    BUTTON-PRESSED tie be"oe lets e#$ei%ent with the PRE-&NSERT tie'

    ;[email protected]

    n the O30-!T 6'1>'TO* e7pand the #)O*D data bloc2. 4ou will find the (Triggers(

    node right under the data bloc2 name. #elect the node and clic2 (( to add atrigger.

    ;?f@./

    #elect *-H6#-*T from the popHup list and clic2 O9. The %J#$% editor for the

    trigger will open up. +se the following code : select cust_"4ne7t.al into

    0s_or!4i! from !ual; The O30-!T 6'1>'TO* for the #)O*D bloc2 loo2ssomething li2e this:

  • 8/10/2019 Oracle Forms Developer Tutorial

    30/49

    NOTE

    Dual is a dummy table used to complete the (From( part of a #$% statementQ

    ;?f@.

    !ompile the code and close the editor window. *un the form to see how autoH

    generated primary 2ey wor2s. Step 2(")

    alculated 8alues a!d o!trol Loops

    Be#ore =e -roceedWe need to add three te7t fields in the control bloc2 :

    ctrl)s)ord

    ?".@ Total of all the items in a order ?nitial Total@

    ?5.@ Total #hipping cost R "G of the Total ?#hipping@

    ?8.@ $uantity discounts as per the following business rules ?Discount@

    nitial Total S PGG : 6o Discount

    PGG S nitial Total S P"GGG : Discount

    P"GGG S nitial Total S P"GG : Discount

  • 8/10/2019 Oracle Forms Developer Tutorial

    31/49

    First Sta"e

    !reating a rogram +nit

    ;?g@."

    Open the O30-!T 6'1>'TO* and select the *O>*', +6T node and clic2 (( toadd a program unit. 4ou will see the following dialogue bo7. -nter the name shown inthe picture and clic2 O9:

    ;[email protected]

  • 8/10/2019 Oracle Forms Developer Tutorial

    32/49

    ' %J#$% Window will automatically open up with the following code in it :

    8RO#ED9RE calc_or!er_!etails IS

    :EI$

    E$D;

    ;[email protected]

    -nter the code given below.

    8RO#ED9RE calc_or!er_!etails IS

    tot number;

    !isc number;

    :EI$0ctrl_S_or!4shi""in/ 0= 0ctrl_s_or!4total *

  • 8/10/2019 Oracle Forms Developer Tutorial

    33/49

    :EI$

    0ctrl_S_or!4shi""in/ 0= 0ctrl_s_or!4total *

  • 8/10/2019 Oracle Forms Developer Tutorial

    34/49

    !alling the rogram +nit

    ;?g@.

    *ight clic2 on the TOT'% te7t item from the ctrl)s)ord bloc2 ?referred to as

    :ctrl)s)ord.total@ and clic2 on the %J#$% editor to bring up the list of possible

    triggers.

    ;?g@.;

    #elect a WE-6H1'%D'T-HT-, trigger and enter the following code :

    calc)order)detailsQ

    This calls the program unit and e7ecutes the %J#$% code in it.

    What is validation When is the WE-6H1'%D'T-HT-, trigger fired !lic2

    Eereto find out.

    ;[email protected] Total ?:s)ord.total@ sothat the user cannot modify the values in these fields. This can be done by opening

    the *O-*T4 '%-TT- of the items and turning the value of the -6'3%-D field to

    6O.

    ;?g@.=

    *un the form to see the results. !lic2 herefor instructions for running a form.

    'lerts are simple mechanisms to reCuire user confirm the reCuested action. 'lerts

    are used to avoid mista2es made by the user. For e.g. when you as2 for a document

    to be deletedL the windows operating system as2s if you are sure H this is a alert thatreCuires the user to confirm his action. We shall see how alerts can be incorporated

    into forms.

    %et us add a alert to the form that as2s the user to confirm his reCuest to submit an

    order. (3 alet has to show u$ a"te the use has $essed the 7Sub%it7 button'*

    Step 2(h)

    *ddi!" *lerts

    First Sta"e

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut9.htm#answer1http://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut9.htm#answer1http://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htmhttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut9.htm#answer1http://www.rhsmith.umd.edu/is/aqiuol/tutorial/tut9.htm#answer1http://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htm
  • 8/10/2019 Oracle Forms Developer Tutorial

    35/49

    !reating the '%-*T

    ;?h@."

    #elect ('lerts( in the O30-!T 6'1>'TO* and clic2 on the (A(. ' new alert with a

    default name will be created. !hange the default name to (#'1-)'%-*T(.

    ;[email protected]

    Double clic2 on the icon to open the *O-*T4 '%-TT- for the alert. !hange thefield values as shown in the picture below.

    NOTE

    4our alert is now ready to be used. The ne7t stage is to call the alert using a %J#$%

    code.

    Seco!d Sta"e

    Calling the #lert

    ;[email protected]

    #ince we want the alert to be called when the user presses the (#ubmit( button we

    have to include code for the 'lert in the WE-6H3+TTO6H*-##-D trigger.

    ;?h@./

    Open the %J#$% editor for the WE-6H3+TTO6H*-##-D trigger associated with the

    #ubmit button. This can be done by opening O*D-*)!'61'# and right clic2ing on

    the #ubmit button. #elect (%J#$% -ditor( from the menu.

    ;?h@.

  • 8/10/2019 Oracle Forms Developer Tutorial

    36/49

    We already have the following code in this trigger:commit_form; +e will modif) thecode in thi trigger a hown below5declarealert)id alertQ

    choice numberQ

    3->6

    alert)id : Find)'lert ?'1-)'%-*T&@Qchoice : #how)'%ert?alert)id@Q

    F

    choice '%-*T)3+TTO6"TE-6

    commit)formQ

    -%#-

    nullQ-6D FQ

    -6DQ

    lease note the the commit)formQ code has now been placed 6#D- the fHTE-6H

    -%#- %OO.

    ;[email protected]

    !ompile the code and close the %J#$% editor window. 4our 'lert has now ready to

    be used. *un the form and see how the alert wor2s. !lic2 herefor instructions for

    running a form. This is how a alert loo2s after the #ubmit button has been pressed.

    http://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htmhttp://www.rhsmith.umd.edu/is/aqiuol/tutorial/frmrun.htm
  • 8/10/2019 Oracle Forms Developer Tutorial

    37/49

    *epeat th

    We currently have just one Data 3loc2 ?#)O*D@ on the O*D-*)!'61'#. The form as

    a whole is not yet complete L we will add #)T-, to the same canvas. Step @

    $ultiple Data Bloc%s o! same a!+as

    We have created a data bloc2 for #)T-, in the previous sections of this tutorial. 4ou

    may want to go over that part again before we go any further. To go over the

    creation of #)T-, data bloc2 !lic2 Eere.

  • 8/10/2019 Oracle Forms Developer Tutorial

    38/49

    n the O30-!T 6'1>'TO* right clic2 on the #)T-, data bloc2 and clic2 on %'4O+TWN'*D. This will bring up the Welcome #creen. !lic2 6-IT to proceed

  • 8/10/2019 Oracle Forms Developer Tutorial

    39/49

    We are not including $+'6TT4)#E-D as it is currently out of the scope of thetutorial. t involves wor2ing with the #)61-6TO*4 table which we will not be using

    for the purpose of this tutorial.

  • 8/10/2019 Oracle Forms Developer Tutorial

    40/49

  • 8/10/2019 Oracle Forms Developer Tutorial

    41/49

  • 8/10/2019 Oracle Forms Developer Tutorial

    42/49

    e entire procedure to create a %O1 to select #ales *epresentative 6ame

  • 8/10/2019 Oracle Forms Developer Tutorial

    43/49

    Forms Builder Advanced Topics

    S=itchi!" #rom o!e ca!+as,loc% to a!other

    f you want to switch from one canvas to anotherL you can use the command

    go)bloc2. For e7ampleL when you run #ample.fmbL pressing the button labeled&!ustomer ,aintenance& will bring you to a different canvas for customer

    maintenance.

    -7amine #ample.fmb in the Object 6avigatorL and you will find a button namedcustomers)maintenance in the !ontrol bloc2. ts WE-6H3+TTO6H*-##-D trigger

    has the following code:

    go)bloc2?&cust)bl2&@Q

    The command go)bloc2?&nameHofHbloc2&@ ta2es you to a bloc2L which is &cust)bl2& in

    this case. 6ote that the button is associated with the ord)can canvas and cust)bl2 isassociated with the cust)can canvas. Therefore when the trigger is firedL the

    application will switch from ord)can to cust)can.

    EoweverL if you only have the go)bloc2 commandL it will bring you to the new canvas

    and nothing else. n the #ample.fmbL we want to display the customer information inthe customer canvas. ThereforeL we should add the following code after the go)bloc2

    command:

    e7ecute)CueryQ

    'lsoL add a preHCuery trigger to the cust)bl2 li2e this:

    :cust)bl2.id : :ord)bl2.customer)idQ

    This will ma2e sure the customer id in the ord)bl2 is carried over to cust)bl2.

    lose a =i!do=

    #ometimes you need to close a window. n the previous e7ampleL after you clic2 the&!ustomer ,aintenance& buttonL there are two windows open. We prefer not having

    more than one window open at the same time. 3ecause multiple windows meanmultiple data bloc2sL and multiple data bloc2s usually cause trouble when you try to

    save the form. ?We will e7plain it later.@ 6ow if you press the &!lose& buttonL you willclose the customer window and return to the ord)can canvas. -7amine cust)bl2 in

    the Object 6aviagtorL you will find the WE-6H3+TTO6H*-##-D trigger of the &!lose&button has the following code:

    !lose)Win5Q

  • 8/10/2019 Oracle Forms Developer Tutorial

    44/49

    6ote that Win5 is associated with cust)can. This command will close Win5L so thatthe canvas and data bloc2s in it will also be closed. #ince the other window is the

    only open window at this timeL you will be automatically brought to it.

    The di""eence between o2block and close2win: t seems that both commands can

    bring you to a different window. EoweverL go)bloc2 simply switches between

    windows. t doesn&t close anything. n contrastL close)win cannot navigate to aspecific window. t will automatically bring you to the ne7t available window.

    *ddi!" "raphics to a #orm

    4ou can add graphic images to your application. To do thisL select a canvas in theObject 6avigatorL and clic2 on -dit U mport U mage. This will import into the form a

    file that contains a graphic image. 4ou can edit its layout in the %ayout -ditor.

    leari!" the +alues i! a #orm

    There are two commands !%-'*)FO*, and !%-'*)3%O!9. 3asicallyL !%-'*)FO*,

    will clear the whole formL no matter which data bloc2 the button belongs to. ncontrastL !%-'*)3%O!9 will only clear the data bloc2 which the button belongs to.lease download !learTest.fmb hereand e7amine the two buttons !%*)F, and

    !%*)3%9 in bloc2 #)T-,.

    Sa+i!" i!#ormatio! =ithi! a #orm

    When we want to create a #'1- button to save informationL we use the followingcode in the WE-6H3+TTO6H*-##-D trigger:

    !O,,T)FO*,Q

    f your form is simple and has only one data bloc2 associated with one tableL thisusually wor2s correctly. EoweverL if your form has two or more data bloc2s or if youhave multiHrecord data bloc2s corresponding to multiple rows of a tableL then the

    !O,,T)FO*, command will try to insert one or more tuples into multiple tablessimultaneously. Depending on the (logic( of your applicationL the form may give

    errors.

    How to Debu

    f you are having problems with inserting records into a table using !O,,T)FO*,L

    ?"@ #implify your application by reducing it to one data bloc2 and verify that it

    wor2s.?5@ 'dd more data bloc2s to the form.

    ?8@ #tart with inserting new data to the F*#T data bloc2 ?the one on the top ofthe data bloc2 list in the Object 6avigator@

    ?/@ 'void multiple #'1- buttons and !O,,T)FO*, commands in one form.?@ -7amine #aveTest.fmbto see how the two save buttons wor2.

    Unable to inset tu$les into a table8

    http://www.rhsmith.umd.edu/is/aqiuol/lab/other/cleartest.fmbhttp://www.rhsmith.umd.edu/is/aqiuol/lab/other/savetest.fmbhttp://www.rhsmith.umd.edu/is/aqiuol/lab/other/cleartest.fmbhttp://www.rhsmith.umd.edu/is/aqiuol/lab/other/savetest.fmb
  • 8/10/2019 Oracle Forms Developer Tutorial

    45/49

    f some attributes in a table have 6OT 6+%% constraintsL inserting a record that has6+%% values for those attributes will give errors. The solution is to either drop the

    6OT 6+%% constraints in the table definition or ma2e sure that you provide a valuefor those attributes.

    Deleti!" a record =ithi! a #orm

    !reate a button labeled D-%-T- and add a WE-6)3+TTO6)*-##-D trigger with the

    following code:

    delete)recordQ

    commitQ

    This will delete the current record. EoweverL if you have more than one data bloc2 in

    the formL it is more complicated. 3asicallyL D-%-T-)*-!O*D will delete the currentrecord in the data bloc2 which the button belongs to. f you have a tabular formL it

    will delete the first record by default. 'nd if you want to delete another recordL youcan move your cursor to that record and press the D-%-T- button. ,ost importantlyL

    if you have a masterHdetail relationship in your formL in order to delete a parentrecord with child recordsL you have to change the property of the relationship. *ight

    clic2 the relation ?which should be under the master bloc2@ and select the (ropertyalette(. !hange the (Delete *ecord 3ehavior( to (!ascading(. 6ow you should be

    able to delete the parent record even when there are child records.

    .o= to display error messa"es

    f you get an error when you run a formL you can use the Eelp feature to display theerror by clic2ing on Eelp J Display -rror on the menu bar. This may help you debug

    your form especially when there are multiple data bloc2s in the form. For e7ampleLthe error may actually occur in another table H not the one which you are trying to

    insert records intoK

  • 8/10/2019 Oracle Forms Developer Tutorial

    46/49

    E9ercises #or Forms Builder

    E9ercise A

    ". !reate a data bloc2 called (-mployee( based on the #)-, table.

    5. !reate a canvas called (-,)!'61'#( to display the data bloc2.8. #T'*T)D'T- is a field in the #)-, table. nitialize the value of #T'*T)D'T- to

    be the current date./. ,a2e !O,,##O6)!T a radio groupL and add five radio buttons: "GL "5.L "L

    "

  • 8/10/2019 Oracle Forms Developer Tutorial

    47/49

    c. !reate a control bloc2. 'dd the following items to the bloc2 which is not in thebase table: a te7t item D-T)6',- and a (Department( button.

    d& Sa+e the #orm as Wor%sm,< ,ecause you =ill use it i! othere9ercises&

    E9ercise 3

    This e7ercise uses the rental.sCl script to create tablesL if you have not already run

    this script from e7ercise 5 download it here. The figure below shows the relationalschema of these tables.

    a. !reate a data bloc2 1-W6> to display the viewing information and put the

    data bloc2 in canvas 1-W)!'61'#.b. ,a2e the initial value of viewDate be the current date.

    c. !reate a control bloc2. 'dd the following items to the bloc2 which is not in thebase table: a te7t item !%-6T)6',- and a (!lient( button.

    d. !reate another canvas called !%-6T)!'61'# to manage the information ofthe clients. 'dd a data bloc2 called !%-6T to !%-6T)!'61'#.

    e. ,a2e prefType a radio groupL and add two radio buttons: (Flat( and (Eouse(to the group. #o that the user can choose from these two preference types.

    #& Sa+e the #orm as 1e!talm,< ,ecause you =ill use it i! othere9ercises&

    E9ercise 4

    4ou need to complete Forms 3uilder Tutorial art to finish this e7ercise. The

    objectives of this e7ercise are: triggerL %O1L seCuenceL program units and calculatedvaluesL alert.

    http://www.rhsmith.umd.edu/is/aqiuol/lab/other/rental.sqlhttp://www.rhsmith.umd.edu/is/aqiuol/lab/other/rental.sql
  • 8/10/2019 Oracle Forms Developer Tutorial

    48/49

    ". The following e7ercises will use Wor2s.fmb which you created in -7ercise 5.

    a. !reate a (#ave( button to save information and add a WE-6H3+TTO6H

    *-##-D trigger.b. 'dd an %O1 which is connected to the (Department( button. The values

    returned by the %O1 must be input into D6+, and D-T)6',- in the form.

    c. ,a2e 6+,3-* a system generated field after creating a database seCuence.The value will be generated when you try to insert a new record ?use a *-H6#-*T trigger@. lease note that there are e7isting values in the columnL and

    ma2e sure your seCuence follow the primary 2ey constraint. #ince this valuewill be auto generated it will no longer be a reCuired field. >o to the roperty

    alette for number and change the (*eCuired( field to (6o(.

    d. 'dd a te7t item W'>- to the !O6T*O% 3%O!9. ,ove the newly added te7titem around so that it aligns with other items in the WO*9#)O6 data bloc2.

    e. 'dd a program unit called >et)Wage which calculates the wage based on thehours the employee wor2ed on the project ?wagehoursB5G@.

    f. 'dd a O#TH$+-*4 trigger to the WO*9#)O6 data bloc2 which calls the

    >et)Wage program unit.g. !reate an alert. ,a2e sure that the alert will be called when the (#ave( button

    is pressed and provide the option to submit or to cancel.h. #ave the form.

    5. The following e7ercises will use *ental.fmb which you created in -7ercise 8.a. !reate a (#ave( button to save information and add a WE-6H3+TTO6H

    *-##-D trigger on the !lient !anvas.b. 'dd an %O1 which is connected to the (!lient( button. The client6o and the

    !lient %ast 6ame returned by the %O1 must be input into client6o and!%-6T)6',- in the form.

    c. !reate an alert. ,a2e sure that the alert will be called when the (#ave( buttonis pressed and provide the option to submit or to cancel.

    d. #ave the form.

    E9ercise '

    4ou need to complete Forms 3uilder Tutorial art to finish this e7ercise. Theobjectives of this e7ericse are: triggerL delete recordsL clear formsL close windowsL

    switch between canvases.

    ". The following e7ercises will use Wor2s.fmb which you updated in -7ercise /.

    a. 'dd a (Delete roject( button to delete the project information. ,a2e sureyou delete all the wor2s)on information related to the deleted project.

    b. 'dd a (Delete Wor2s)On( button to delete the wor2s)on information.

    c. 'dd a (!lear( button to clear the whole form.d. !reate another canvas called -,)!'61'# to manage the information of the

    employees. 'dd a data bloc2 called -,%O4-- to -,)!'61'# to display the

    employee information.

    e. 'dd a (-mployee ,angement( button to *O0-!T)!'61'#L so that when theuser clic2 this buttonL heJshe will be navigated to -,)!'61'#.

    5. The following e7ercises will use *ental.fmb which you updated in -7ercise /.

  • 8/10/2019 Oracle Forms Developer Tutorial

    49/49

    a. 'dd a (Delete 1iewing( button to 1-W)!'61'# to delete the viewinginformation.

    b. 'dd a (!lear( button to 1-W)!'61'# to clear the whole form.c. 'dd a (!lient ,angement( button to 1-W)!'61'#L so that when the user

    clic2 this buttonL heJshe will be navigated to !%-6T)!'61'#.


Top Related