Pre-Update and Pre-Insert Trigger Examples For Oracle Forms
See also: Why And When To Use Pre-Update and Pre-Insert Triggers In Oracle Forms
Pre-Update Fires during the Post and CommitTransactions process, before a row is updated in Oracle Forms. It fires once for each record that is marked for update.
The following example writes a row into an Audit Table showing old discount and new discount for a
given customer, including timestamp and username making the change.
old_discount NUMBER;
new_discount NUMBER := :Customer.Discount_Pct;
oper_desc VARCHAR2(80);
CURSOR old_value IS SELECT discount_pct FROM customer
WHERE CustId = :Customer.CustId;
BEGIN
/*
Fetch the old value of discount percentage from the database by CustomerId. We need to do this since the value of :Customer.Discount_Pct will be the new value we’re getting ready to commit and we want to record for posterity the old and new values. We could use SELECT...INTO but choose an explicit cursor for efficiency.
*/
OPEN old_value;
FETCH old_value INTO old_discount;
CLOSE old_value;
/* If the old and current values are different, then we need to write out an audit record */
IF old_discount <> new_discount THEN
/* Construct a string that shows the operation of Changing the old value to the new value. e.g.’Changed Discount from 13.5% to 20%’
*/
oper_desc := ’Changed Discount from ’||
TO_CHAR(old_discount)||’% to ’||
TO_CHAR(new_discount)||’%’;
/*
Insert the audit record with timestamp and user
*/
INSERT INTO cust_audit( custid, operation, username, timestamp )
VALUES ( :Customer.CustId,oper_desc,USER,SYSDATE );
END IF;
END;
Pre-Insert trigger
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.
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;
Pre-insert and Pre-update in Oracle Forms
Reviewed by Rasa on
Mar 24
Rating:
5
Pre-Update and Pre-Insert Trigger Examples For Oracle Forms的更多相关文章
- Map Columns From Different Tables and Create Insert and Update Statements in Oracle Forms
This is one of my most needed tool to create Insert and Update statements using select or alias from ...
- Trigger Execution Sequence Of Oracle Forms
Sequence of triggers fires on Commit.1. KEY Commit2. Pre Commit3. Pre/On/Post Delete4. Pre/On/Po ...
- An Example of On-Error Trigger in Oracle Forms
I wrote this trigger around 4 years ago to handle errors in an application based on Oracle Forms 6i. ...
- Pre-Query trigger in Oracle D2k / Oracle Forms
Pre-Query trigger in Oracle D2k / Oracle Forms DescriptionFires during Execute Query or Count Query ...
- Trigger Execution Sequence in Oracle Forms
Introduction ------------ This document lists the order in which triggers fire in Oracle Forms 4.5: ...
- 8 Most Required Examples Reference For Oracle Forms
Check the following 8 Links for best Oracle Forms examples with source code (Fmb files), which will ...
- Learn How To Create Trigger In Oracle Forms
I have written many posts related to triggers in Oracle Forms, I have given examples for Form Level ...
- Writing On-Error Trigger In Oracle Forms
Suppose you want to handle an error in oracle forms and want to display custom error message for tha ...
- Using Post-Form Trigger In Oracle Forms
Post-Form trigger in Oracle Forms fires during the Leave the Form process, when a form is exited. ...
随机推荐
- Sqlserver Sql Agent Job 只能同时有一个实例运行
Sqlserver Sql Agent中的Job默认情况下只能有一个实例在运行,也就是说假如你的Sql Agent里面有一个正在运行的Job叫"Test Job",如果你现在再去启 ...
- 【转】The Attached Behavior Pattern
原文:http://www.bjoernrochel.de/2009/08/19/the-attached-behavior-pattern/ The Attached Behavior Patter ...
- 【海岛帝国系列赛】No.4 海岛帝国:LYF的太空运输站
50212228海岛帝国:LYF的太空运输站 [试题描述] 最近,“购物券”WHT在“药师傅”帝国资源大会上提出了“SSTS”太空运输站计划.由于恐怖分子前些日子刚猖狂完,炸毁高楼无数,YSF不得不执 ...
- Asp.Net Web Api 2 实现多文件打包并下载文件示例源码_转
一篇关于Asp.Net Web Api下载文件的文章,之前我也写过类似的文章,请见:<ASP.NET(C#) Web Api通过文件流下载文件到本地实例>本文以这篇文章的基础,提供了Byt ...
- JDK结构介绍
dt.jar和tools.jar位于:{Java_Home}/lib/下, 而rt.jar位于:{Java_Home}/jre/lib/下, 其中: (1) rt.jar是JAVA基础类库,也就是你在 ...
- WKWebView新特性及JS交互
引言 一直听说WKWebView比UIWebView强大许多,可是一直没有使用到,今天花了点时间看写了个例子,对其API的使用有所了解,为了日后能少走弯路,也为了让大家更容易学习上手,这里写下这篇文章 ...
- VS 6.00 工程项目文件详解
*.dsp(DeveloperStudio Project):是VC++的工程配置文件,比如说你的工程包含哪个文件,你的编译选项是什么等等,编译的时候是按照.dsp的配置来的.*.dsw(Develo ...
- poj3270 Cow Sorting
给定有序数组a[1...n]的一个置换a[σ(1)...σ(n)], 通过交换数组元素把置换后的数组恢复为有序, 定义进行一次交换的代价为两元素之和,试问此过程的最小总代价. 实际上一种置换即定义S ...
- VRRP配置与维护手册-1
http://www.gpxz.com/diannao/hulianwang/80526.html 一 VRRP简介< xmlnamespace prefix ="o" n ...
- masonry插件和infinitescroll插件实现无刷新无分页完美瀑布流
地址有:http://www.17sucai.com/pins/2657.html 如果你善于发现美,如果你善于观察新鲜的事物,如果你是一名有爱的前端攻城师或设计尸,那么你一定不会对下面图片中的结构感 ...