Chapter 6 Creating Custom Forms To Oracle 10g 2 Open The 6bprojectsfmb Form
Chapter 6 Creating Custom Forms To Oracle 10g 2 Open The 6bprojectsfmb Form
Chapter 6 Creating Custom Forms To Oracle 10g 2 Open The 6bprojectsfmb Form
9
Guide to Oracle 10g 10
Alerts (continued)
• Styles:
– Note displays an “i” for information, conveys
information to the user
• Such as confirming that the form has inserted a record.
– Caution displays an exclamation point (!), inform the user
that he or she is about to make a choice that cannot be
undone and could lead to a potentially damaging situation,
• such as deleting a record
– Stop display a red "X" or a red stoplight
– inform the user that he or she has instructed the system to
perform an action that is not possible
• such as trying to delete a record that is referenced as a foreign
key in another table. 11
Alerts (continued)
12
To create the alert:
1. Open the 6BProjects.fmb form in the Chapter6\Tutorials folder on your
Solution Disk, and save the form as 6BProjects_ALERT.fmb in the
Chapter6\Tutorials folder on your Solution Disk. (If you did not create
the 6BProjects.fmb form earlier in the lesson, a copy of this file is in the
Chapter6 folder on your Data Disk.)
2. Make sure that the Object Navigator window is open in Ownership
View, then select the Alerts node under the PROJECT_FORM node.
3. Click the Create button on the Object Navigator toolbar to create a new
alert object.
4. Double-click the Alert icon beside the new alert to open its Property
Palette, and then change its properties as follows:
13
5. Close the Property Palette, and then save the form.
Alerts (continued)
• To declare/display alert:
DECLARE
alert_button NUMBER;
BEGIN
alert_button:=
SHOW_ALERT('alert_name');
END;
16
• To create the program unit to display the alert:
1. In the Object Navigator window, select the Program
Units node, and then click the Create button to
create a new program unit.
2. Type DISPLAY_ALERT for the new program unit
name, make sure that the Procedure option button is
selected, and then click OK.
3. Modify the procedure so it appears as shown
in Figure 6-24 . Then compile the code, correct any
syntax errors if necessary, close the PL/SQL Editor,
and save the form.
23
Validating Form Input Values (continued)
• You can perform complex validation operations by
using validation triggers.
• Item validation trigger
– Item-level trigger
– Associate with item’s WHEN-VALIDATE-ITEM event
– Fires when item is validated
• As determined by form validation unit
• The trigger code tests the current item value to determine
if it satisfies the validation condition or conditions.
– If not valid
• Raises built-in exception named
FORM_TRIGGER_FAILURE
24
To create and test an item validation trigger:
1. In the Layout Editor, select the Class text item, right-click, point to
SmartTriggers, and then click WHEN-VALIDATE-ITEM. The
PL/SQL Editor opens.
2. Type the following command in the PL/SQL Editor to create the
validation trigger:
IF NOT :student.s_class IN ("FR", 'SO', 'JR', 'SR') THEN
MESSAGE('Legal values are FR, SO, JR, SR');
RAISE FORM_TRIGGER_FAILURE;
END IF;
3. Compile the trigger, correct any syntax errors, close the PL/SQL
Editor, and save the form.
4. Run the form, and click Create. A new Student ID value appears.
5. Place the insertion point in the Class field, type AA, and then press
Tab. The message "Legal values are FR, SO,JR, SR" appears on the
message line, indicating that the item validation trigger fired correctly.
6. Close the browser window. 25
Disabling Form Command Buttons to
Avoid User Errors
• when a user clicks the Create button on the Students form, a new
Student ID value appears on the form. The user must enter values into
the other form text items, and then click the Save New button, to save
the new record. If the user clicks the Save New button without
clicking the Create button, then the form does not retrieve the Student
ID value from the sequence, and risks having a duplicate primary
key. Therefore, when the form first opens, the Save New button
should be disabled (grayed-out). The Save New button should not be
enabled until after the user has clicked the Create button.
26
Disabling Form Command Buttons to
Avoid User Errors
33
Trapping Form Runtime Errors