Tutorial for Designer/2000
and Developer/2000


Lesson 9, page 4

  1. We will now create three push buttons and write triggers for each button. To create a push button, select the button icon from the palette on the left of the canvas and drop in the lower part of the form. (See Figure 9.30)

    Figure 9.30

    Figure 9.30: Selecting a push button

  2. We will change the label of the first push button in the property palette to "Retrieve." To do this, right click on the button and go to its Property Palette. (See Figure 9.31).

    Figure 9.31

    Figure 9.31: Selecting the Property Palette for the push button

  3. Now select the PL/SQL editor by right clicking on the push button. (See Figure 9.32).

    Figure 9.32

    Figure 9.32: Selecting the PL/SQL Editor for the push button

  4. Select the WHEN-BUTTON-PRESSED-TRIGGER, insert the following PL/SQL code in the blank space of the editor and then click Compile.

    begin
    select studid, studname, ftpt_status, sex, start_sem, start_year, major
    into :studblock.studid, :studblock.studname, :studblock.ftpt_status,
    :studblock.sex, :studblock.start_sem, :studblock.start_year, :studblock.major
    from student
    where studid = :studblock.studid;
    exception
    when no_data_found then
    message ('Invalid Student Id:Please enter a valid Id.');
    raise form_trigger_failure;
    end;

  5. In the above code, we are writing a select statement for retrieving the record of a student with any particular student ID. If no data is found on a particular student ID, then Developer/2000 will give an error message and raise the form_trigger_failure trigger. Run the form and type in a invalid STUDID to check the message. (See Figure 9.33)

    Figure 9.33

    Figure 9.33: Error Message when invalid Student ID is entered by the user

    In a similar manner, create two other buttons, totaling three push buttons.

  6. Go to the second push button, right click on it and go to its property palette. Change its label to Insert. Now come back to the Layout Editor, right click again on the push button and go to its PL/SQL Editor. In it, write the following code in the When-Button-Pressed trigger:

    Commit;
    Clear_Form;

  7. Label the third push button as Clear. At the When-Button-Pressed Trigger, write the following code:

    Clear_Form;

  8. Now go back to the Canvas View and Program-> Run Form to view your form with the three push buttons. (See Figure 9.34)

    Figure 9.34

    Figure 9.34: The Form with the three Push buttons

Lesson Summary

In this lesson, you have learned how to add various objects to your form and write triggers on them to add functionality. Specifically this involved:

In the next lesson we will create another push button for deleting records, to which we will add alerts for warning the user before a record is deleted. We will also use a procedure to create the above mentioned functionality. To learn how to do this, proceed to Lesson 10.

Page 1, Page 2, Page 3, Page 4 / Back to the tutorial index.


Main Page About the Book Student Resources Oracle Resources Instructor Resources Contact Us

1999 Prentice-Hall, Inc., A division of Pearson Education, Upper Saddle River, New Jersey 07458 Legal Statement
Comments should be directed to webmaster@prenhall.com