Tutorial for Designer/2000
Lesson 9, page 4
- 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: Selecting a push button
- 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: Selecting the Property Palette for the push button
- Now select the PL/SQL editor by right clicking on the push button. (See Figure 9.32).
Figure 9.32: Selecting the PL/SQL Editor for the push button
- Select the WHEN-BUTTON-PRESSED-TRIGGER, insert the following PL/SQL code in the blank space of the editor and then click Compile.
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
where studid = :studblock.studid;
when no_data_found then
message ('Invalid Student Id:Please enter a valid Id.');
- 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: Error Message when invalid Student ID is entered by the user
In a similar manner, create two other buttons, totaling three push buttons.
- 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:
- Label the third push button as Clear. At the When-Button-Pressed Trigger, write the following code:
- 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: The Form with the three Push buttons
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:
- Creating LOVs, or List of Values, where you connected to another table from which users make their selections
- Creating Radio Buttons
- Creating Poplists
- Creating Push Buttons
- Adding triggers to the push buttons for inserting, clearing and retrieving records
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.
About the Book
©1999 Prentice-Hall, Inc., A division of Pearson Education, Upper Saddle River, New Jersey 07458 Legal Statement
Comments should be directed to firstname.lastname@example.org