Fires during the Post and Commit Transactions process, before a row is inserted. It fires once for each record that is marked for insert.
Definition Level form or block
SELECT statements, DML statements (DELETE, INSERT, UPDATE), unrestricted Built-ins
Enter Query Mode no
Use a Pre-Insert trigger to perform the following tasks:
Oracle Forms performs the following steps when the Pre-Insert trigger fails:
Post and Commit Transactions
This example assigns a primary key field based on a sequence number, and then writes a row into an auditing table, flagging creation of a new order.
DECLARE
CURSOR next_ord IS SELECT orderid_seq.NEXTVAL FROM dual;
BEGIN
/*
** Fetch the next sequence number from the
** explicit cursor directly into the item in
** the Order record. Could use SELECT...INTO,
** but explicit cursor is more efficient.
*/
OPEN next_ord;
FETCH next_ord INTO :Order.OrderId;
CLOSE next_ord;
/*
** Make sure we populated a new order id ok...
*/
IF :Order.OrderId IS NULL THEN
Message('Error Generating Next Order Id');
RAISE Form_Trigger_Failure;
END IF;
/*
** Insert a row into the audit table
*/
INSERT INTO ord_audit( orderid, operation, username, timestamp )
VALUES ( :Order.OrderId,
'New Order',
USER,
SYSDATE );
END;