Tutorial for Designer/2000
and Developer/2000


Lesson 10

In this lesson, you will learn how to:

Creating an Alert

  1. Go to Alerts in the Object Navigator and double click on it. (See Figure 10.1)

    Figure 10.1

    Figure 10.1: Creating a New Alert

  2. Double click on the newly created alert and name it DELETE_ALERT. (See Figure 10.2)

    Figure 10.2

    Figure 10.2: Changing the name of the new Alert

  3. Now double click on the alert and you will immediately go to its Property Palette. In the properties:

    (See Figure 10.3)

    Figure 10.3

    Figure 10.3: The Property Palette for the Alert

  4. To activate the alert, we will create a procedure which we will call from the delete button. To add a procedure, go to the Object Navigator and double click on Program Units. Immediately the window for the new Program unit will appear. (See Figure 10.4)

    Figure 10.4

    Figure 10.4: Creating a new Program Unit

  5. In the window for the new Program Unit, type in the name as Display_Delete-Alert. Make sure that procedure is selected as the type of Program Unit and click OK. (See Figure 10.5)

    Figure 10.5

    Figure 10.5: Naming the new Program Unit

  6. Once you click OK, you will be automatically taken to the PL/SQL Editor window. (See Figure 10.6)

    Figure 10.6

    Figure 10.6: The PL/SQL Editor window for the new Program Unit

  7. In the PL/SQL Editor, type in the following code for activating the alert. You may have to delete a couple of lines from the Editor to avoid duplication. In this code, we will declare a number variable called return_alert. We will then set it to show the alert that we created earlier in this lesson called Delete_Alert. We will then write a simple if/then statement, such that if the user clicks on OK, which is alert button 1, then Developer/2000 will perform the deletion and commit the changes. Otherwise, it will exit the alert window and help the users decide on their action. (See Figure 10.7 to get a view of the code as it should look in the PL/SQL editor. Do not forget to compile.)

    PROCEDURE Display_Delete_Alert IS
    return_alert NUMBER;
    BEGIN
         return_alert := show_alert ('DELETE_ALERT');
    if return_alert = alert_button1 then
    commit;
    else
    rollback;
    end if;

    END;

    Figure 10.7

    Figure 10.7: The code for activating the alert

  8. We will now add a push button to the form and then add the above procedure to it, so that whenever the user clicks on delete, the alert will be shown. To do this, go the Layout Editor and add a push button to the form, go its properties, andchange the label to Delete (use the steps used to create a push button in Lesson 9). Now go to its PL/SQL Editor by right clicking on the push button. (See Figure 10.8)

    Figure 10.8

    Figure 10.8: Selecting the PL/SQL Editor for the Delete button

  9. At the When-Button-Pressed trigger in the PL/SQL Editor, write the following code:

    delete from student where studid = :studblock.studid;
    delete_record;
    Display_Delete_Alert;

    The last line of the code will call the previously created procedure Display_Delete_Alert and activate the alert whenever the user clicks on the delete button. The first two lines of code delete the record for any particular student ID. (See Figure 10.9 to get a view of the alert when the user clicks the delete button).

    Figure 10.9

    Figure 10.9: The fully functional form with the alert on the Delete button

Lesson Summary

In this lesson you have learned how to:

Next you will learn how to create reports. To do this, proceed to Lesson 11.

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