11.01.2013 Views

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

Oracle Forms Developer – Form Builder Reference, Volume 1

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Pre-Update trigger<br />

Description<br />

Fires during the Post and Commit Transactions process, before a row is updated. It fires once for each<br />

record that is marked for update.<br />

Definition Level form or block<br />

Legal Commands<br />

SELECT statements, DML statements (DELETE, INSERT, UPDATE), unrestricted built-ins<br />

Enter Query Mode no<br />

Usage Notes<br />

Use a Pre-Update trigger to audit transactions.<br />

On Failure<br />

<strong>Form</strong> <strong>Builder</strong> performs the following steps when the Pre-Update trigger fails:<br />

• sets the error location<br />

• rolls back to the most recent savepoint<br />

Fires In<br />

Post and Commit Transactions<br />

See Process Flowcharts<br />

Pre-Update trigger examples<br />

Example<br />

The following example writes a row into an Audit Table showing old discount and new discount for a<br />

given customer, including timestamp and username making the change.<br />

DECLARE<br />

old_discount NUMBER;<br />

new_discount NUMBER := :Customer.Discount_Pct;<br />

oper_desc VARCHAR2(80);<br />

CURSOR old_value IS SELECT discount_pct FROM customer<br />

WHERE CustId = :Customer.CustId;<br />

BEGIN<br />

/*<br />

** Fetch the old value of discount percentage from the<br />

** database by CustomerId. We need to do this since the<br />

** value of :Customer.Discount_Pct will be the *new* value<br />

** we’re getting ready to commit and we want to record for<br />

** posterity the old and new values. We could use<br />

** SELECT...INTO but choose an explicit cursor for<br />

** efficiency.<br />

*/<br />

492

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!