A script-enabled browser is required for this page to function properly.

Preventing Masterless Operations in the Detail Block

With few exceptions, end users should be prevented from performing masterless operations in a detail block. That is, end users should not be able to query or insert records in the detail block when there is no current record in the master block.

Setting the Prevent Masterless Operation relation property to Yes to prevent end users from performing masterless operations in the detail block of the relation has the following effects:

If end users attempt to insert records into the detail block when there is no master record in the master block, Oracle Forms will display an error message:FRM-41105: Cannot create records without a parent record.

If end users attempt to query records in the detail block when there is no master record (in the master block) that came from the database, Oracle Forms will display an error message:FRM-41106: Cannot query records without a parent record.

It is usually appropriate to prevent masterless inserts when end users are likely to encounter an error if they attempt to commit detail records that have been created independently of a master record. Such an error occurs when the detail block derives the value of its foreign-key items from the primary-key items in the master record (by way of the Copy Value from Item property).

Similarly, you might want to prevent masterless queries in a detail block because end users cannot perform effective queries from the detail block. End users can query the existence of specific detail records, but they cannot determine which master records own them. (This assumes that the foreign-key item(s) in the detail block are not displayed.)

Preventing Navigation to the Detail Block

Setting the Prevent Masterless Operation property to Yes prevents end users from querying and inserting in a detail block for which there is no corresponding master record, but it does not prevent them from navigating to the detail block and attempting these operations.

In some applications, it may be desirable to disallow any attempt to navigate to a detail block when there is no master record.

Preventing masterless operations in the detail block: Examples

Example

/* One way to prevent end users from navigating to a detail
** block for which there is no master. It is based on the
** detail block WAREHOUSE and the master block REGION.
** Use a When-New-Block-Instance trigger on detail block
** WAREHOUSE:
*/
DECLARE
alert_dummy NUMBER;

BEGIN
/* See if there is a master record by checking the status
** of the current record in the master block
*/

IF GET_RECORD_PROPERTY(GET_BLOCK_PROPERTY
('region', current_record), 'region', STATUS) = 'NEW'
OR :region.region_id IS NULL THEN

/*
** There isn't a master record; display an alert that tells the
** end user to query or enter a region record before moving to
** the warehouse block
*/

alert_dummy := SHOW_ALERT('my_alert');

/*
** Put the input focus in the master block
*/

GO_BLOCK('region');
END IF;
END;

/* The When-New-Block-Instance trigger fires whenever the end
** user navigates to the detail block. The Built-in function
** GET_RECORD_PROPERTY is used to determine the status of
** the current record in the master block. (The function
** GET_BLOCK_PROPERTY is nested as the first argument to
** GET_RECORD_PROPERTY to return the record number of the
** current record in the region block.)
**
** If the status of the current record is NEW, indicating that
** the record is not an existing master record, Oracle Forms
** displays an alert window with the message "Query or enter
** a master record before moving to the detail block."
** The trigger then navigates to the master block to allow the
** end user to do just that.
*/


Prevent Masterless Operations property