You have a form that called a database stored procedure. You do not want processing to continue, so immediately after the call to the stored procedure, you add the following code:
IF NOT FORM_SUCCESS THEN
MESSAGE ('Stored Procedure failure');
RAISE FORM_TRIGGER_FAILURE;
END IF;
You test the code and input some data that intentionally causes the stored procedure to fail. However, the message that you defined does not appear. What are two possible reasons for this?
A: You should use DBMS_ERROR_CODE and DBMS_ERROR_TEXT in an ON-ERROR trigger to trap errors propagated from Oracle server from Forms.
Note: FORM_SUCCESS and FORM_TRIGGER_FAILURE
Either the FORM_SUCCESS built-in or the FORM_TRIGGER_FAILURE exception must be used to handle all Forms errors. FORM_SUCCESS is a Boolean function that evaluates to TRUE or FALSE depending on the success or failure of a Forms built-in. FORM_TRIGGER_FAILURE is an exception that has to be raised to stop further processing whenever an error occurs or FORM_SUCCESS evaluates to FALSE. The following sections describe their use in error-message handling.
You have been assigned to maintain a forms application that was designed by a developer who has left the company.
The form uses different property classes to standardize the appearance of objects in the form. For example, all buttons should be of the same width.
The CV_Tools canvas contains several buttons. The Print invoice button is not quite wide enough to display its complete label.
In forms Builder, you open the Button_PC property class and change its Width property to a higher number. All the buttons become larger except the Print invoice button, which remains its original size. What could have caused this problem?
The Orders database table uses Order_id as its primary key. You have written the following code to use in the Orders block of a form:
SELECT orders_seq.NEXTVAL
INTO :orders.order_id
FROM SYS.dual;
Which statement is true about this code?
Assigning Sequence Numbers to Records
You will recall that you can assign default values for items from an Oracle sequence, to
automatically provide unique keys for records on their creation. However, if the user does
not complete a record, the assigned sequence number is ''wasted.''
An alternative method is to assign unique keys to records from a Pre-Insert trigger,
just before their insertion in the base table, by which time the user has completed the
record and issued the Save.
Assigning unique keys in the posting phase can:
* Reduce gaps in the assigned numbers
* Reduce data traffic on record creation, especially if records are discarded before
saving
Example
This Pre-Insert trigger on the ORDERS block assigns an Order ID from the sequence
ORDERS_SEQ, which will be written to the ORDER_ID column when the row is
subsequently inserted.
SELECT ORDERS_SEQ.nextval
INTO :ORDERS.order_id
FROM SYS.dual;
View the Exhibit.
To test how the Orders application works with database triggers, you add to the Orders table the following database trigger that fires before the update of Customer_Id:
BEGIN
If :old.customer_id != : new.customer_id then
RAISE_APPLICATION_ERROR (-20101, 'Database trigger says no!');
end if;
END;
You run the Orders form, change the customer ID, and click Save. You receive the error message "FRM-40509: Oracle error: unable to UPDATE record." You select Help > Display Error, and the Database Error dialog box that is shown in the Exhibit appears.
Which code would you put in your Form-level On-Error trigger to display the ORA- error message instead of the FRM- error message?
You add a display item named Quantity to the Order items block of your Orders form to display the quantity on hand for each product. Quantity is a non-base table item that should reflect the count of an ordered product from the inventories table.
What is the best way to populate the Order_Iterns.Quantity item?