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

On-Check-Unique Trigger

Description

During a commit operation, the On-Check-Unique trigger fires when Oracle Forms normally checks that primary key values are unique before inserting or updating a record in a base table. It fires once for each record that has been inserted or updated.

Replaces the default processing for checking record uniqueness. When a block has the Enforce Primary Key property set to Yes, Oracle Forms, by default, checks the uniqueness of a record by constructing and executing the appropriate SQL statement to select for rows that match the current record's primary key values. If a duplicate row is found, Oracle Forms displays message FRM-40600: Record has already been inserted.

For a record that has been marked for insert, Oracle Forms always checks for unique primary key values. In the case of an update, Oracle Forms checks for unique primary key values only if one or more items that have the Primary Key item property have been modified.

Definition Level

form, block

Legal Commands

SELECT statements, PL/SQL, unrestricted Built-ins

Enter Query Mode no

Usage Notes

To perform the default processing from this trigger, call the CHECK_RECORD_UNIQUENESS Built-in.

On Failure

no effect

Fires In

Check Record Uniqueness

Post and Commit Transactions

On-Check-Unique Trigger Example

The following example verifies that the current record in question does not already exist in the DEPT table:

DECLARE
CURSOR chk_unique IS SELECT 'x'
FROM dept
WHERE deptno = :dept.deptno;
tmp VARCHAR2(1);
BEGIN
OPEN chk_unique;
FETCH chk_unique INTO tmp;
CLOSE chk_unique;
IF tmp IS NOT NULL THEN
Message('This department already exists.');
RAISE Form_Trigger_Failure;
ELSIF form_fatal OR form_failure THEN
raise form_trigger_failure;
END IF;
END;


CHECK_RECORD_UNIQUENESS Built-in