Tuesday, November 29, 2016

Oracle forms Alert Example

What is Alert?

An alert is a modal window that displays a message notifying the operator of some application condition.
Use alerts to advise operators of unusual situations or to warn operators who are about to perform an action that might have undesirable or unexpected consequences.
Oracle Forms has many Built-in alerts that display pre-defined messages. You can also create your own custom alerts that display in response to application-specific events.
When an event occurs that causes an alert to display, the operator must respond to the alert's message by selecting one of the predefined alert buttons.

Creating an Alert

Alerts are alternative method for communicating with the operator.
They are displayed in a modal window.
They provide an effective way for drawing attention and forcing the operator to answer the message before processing can continue.
Alerts are used to perform:
Display a message that the operator cannot ignore, and must acknowledge.
Ask the operator a question where up to three answers are appropriate( typically Yes, No or cancel).


When you create an alert, you need only specify basic information such as the message you want the alert to display and the text labels for the alert buttons.
Once you create an alert, you must write a trigger or user-named routine to display the alert in response to a particular event. In addition, the action that each button initiates is determined by the PL/SQL code you write to invoke the alert.

To create an alert:

In the Object Navigator, click the Alerts node.
Click Create in the toolbar.
Double-click the alert object icon to display the Property Palette.
Set the Alert Style property to the style that corresponds to the severity of your message: either Stop, Caution, or Note.
At runtime, an icon representing the style you select displays next to the message in the alert window.
Set the Message property by entering the message you want the alert to display at runtime. You can enter up to 200 characters.
Define one or more buttons for the alert by entering a text label in the Button 1 Label, Button 2 Label, and Button 3 Label fields.
Choose the Default Alert Button, either Button 1, Button 2, or Button 3.

Controlling an Alert using Alert Built-in’s

After creating an Alert, you can modify the definitions of that alert at run-time, by using pre-defined built-in’s.
There are 5 pre-defined built-in’s.
SHOW_ALERT
SET_ALERT_PROPERTY
SET_ALERT_BUTTON_PROPERTY
ID_NULL
FIND_ALERT
SHOW_ALERT


Displays the given alert, and returns a numeric value when the operator selects one of three alert buttons.
Syntax:
        SHOW_ALERT(alert_id Alert);
        SHOW_ALERT(alert_name VARCHAR2);
It is a function, which returns a numeric constant corresponding to the button the operator selected from the displayed alert.

SET_ALERT_PROPERTY

It is a procedure, which Changes the message text for an existing alert.
>    SET_ALERT_PROPERTY(alert_id ALERT or alert_nameVARCHAR2,
                         property NUMBER,
                         message VARCHAR2);        

>    Where property  Specifies the specific alert property you are setting,
    message  Specifies the message that is to replace the current alert message.
    If the message text exceeds 200 characters, it will be truncated.
>  SET_ALERT_PROPERTY(al_id, alert_message_text, err_txt );

SET_ALERT_BUTTON_PROPERTY
It is a procedure, which Changes the label on one of the buttons in an alert.
>    SET_ALERT_BUTTON_PROPERTY(alert_id ALERT  or                                           alert_nameVARCHAR2, button NUMBER,   property VARCHAR2,  value VARCHAR2);

>   Where button is a constant that specifies the alert button you want to change, either ALERT_BUTTON1, ALERT_BUTTON2, or ALERT_BUTTON3,     property specifies the property for the alert button and     value  Specifies the VARCHAR2 value to be applied to the property you specified.


ID_NULL

It is a function, that returns a BOOLEAN value that indicates whether the object ID is available or not.
>     ID_NULL(Alert ALERT);
>    Use ID_NULL when you want to check for the existence of an alert created dynamically at runtime.


FIND_ALERT

Searches the list of valid alerts in Oracle Forms.
When the given alert is located, the subprogram returns an alert ID.
You must return the ID to an appropriately typed variable.
Define the variable with a type of Alert.
>    FIND_ALERT(alert_name VARCHAR2);

Errors while using Alerts


FRM-11701: Alert with this name already exists. Cause:  There is already an alert with the same name defined in the active form.
FRM-11703: Unable to retrieve the alert objects from the file.
    Cause:  Internal system error.
FRM-11706: Unable to get the copied/referenced alert %s.
    Cause:  The specified alert does not exist in the database.
FRM-30170: Alert must contain at least one button - %s. Cause:  The alert contains no buttons.
FRM-30360: Alert does not contain the specified default button.
    Cause:  You specified a default button that is not part of the alert definition.
FRM-41039: Invalid Alert ID %d.
    Cause:  An invalid ID was passed to a built-in subprogram.
FRM-41313: No such Property for Set_Alert_Property.
    Cause:  An invalid property has been specified for SET_ALERT_PROPERTY.
FRM-41804: Variable was not entered: %.30s. Cause:  Your response to the Query Where alert contained a placeholder not used in any of the query items.

An alert is a modal window that displays a message notifying the operator of some application condition.
Alerts are used to interact with the users at run-time, to give instructions or give the status of the process.
Using Alert built-in’s, you can modify the contents of an Alert.
While creating an alert at design time, set the default properties to ignore the errors at run-time.

**********************************************************************************
                
**********************************************************************************


   

2 comments: