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. ...
随机推荐
- 怎么学习C++?
一个学习十年c++的建议如下: 其实学习C++的读书顺序应该是这样的(对于有C基础的朋友): C++ Primer Effective C++ Exceptional C++ Inside the C ...
- CentOS7.1搭建服务器篇(1)
服务器搭建篇 1.镜像选择,CentOS 7.1 minmal.iso 2.yum install net-tools[提供ifconfig工具,我不习惯IP命令] 3.配置静态IP地址58.154. ...
- 【linux】终端直接执行py文件,不需要python命令
先将终端所在路径切换到python脚本文件的目录下然后给脚本文件运行权限,一般755就OK,如果完全是自己的私人电脑,也不做服务器什么的,给777的权限问题也不大(具体权限含义参考chmod指令的介绍 ...
- yii2购物车实现
1.商品列表中点击加入购物车,则跳转到购物车列表,效果如图所示: 视图代码goods/list.php中.代码如下: <?php echo Html::a('加入购物车',['cart','id ...
- Reporting Service报表项默认可见+号和-号的显示问题
在Reporting Service里面可以设置报表项(组.tablix行.tablix列.文本框等所有SSRS报表项)的可见性,并且可以设置某个报表项的可见性由点击另外一个报表项来控制,比如报表项A ...
- JS货币数字转换中文
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- 由 "select *" 引发的“惨案”
今天凌晨做发布, 要合并多个分数据库的表数据到主数据库中, 有 30+ 分数据库. 前面都比较顺利, 在临近结束时,突然发现一个字段的值插入错误. 有一个表 T,字段分别为 (f1, f2, f3, ...
- DateTimeUtil 工具类,android 和 java 通用
import java.sql.Date;import java.text.SimpleDateFormat; public class DateTimeUtil { public final cla ...
- c sharp学习 问题记录
1.函数的调用可以嵌套,定义不可以 C# 参考之方法参数关键字:params.ref及out C#中方法的参数的四种类型
- Linux下Nagios的安装与配置
一.本文说明 本文是在参考:http://www.cnblogs.com/mchina/archive/2013/02/20/2883404.html David_Tang文章以及网上的一些资料完 ...