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. ...
随机推荐
- OpenStack 之vmware机器迁移到openstack集群
原理 openstack本身是支持使用vmware格式的镜像的,但是是需要我们我们在/etc/nova/nova.conf的配置文件中指定该计算节点使用vmware的驱动 1 2 3 4 5 6 7 ...
- linux设备驱动归纳总结(八):4.总线热插拔【转】
本文转载自:http://blog.chinaunix.net/uid-25014876-id-110774.html linux设备驱动归纳总结(八):4.总线热插拔 xxxxxxxxxxxxxxx ...
- 数据库日期格式为int型时存取格式
存入当前日期:time() 取出并转化为日期格式:date('Y-m-d H:i:s',strtotime($time)); 最好在前面加上这句: date_default_timezone_set( ...
- Virtualbox后台管理之VBoxManage
Virtualbox是提供了后台启动的.只是不是默认的. 查看有哪些虚拟机 VBoxManage list vms 查看虚拟的详细信息 VBoxManage list vms --long 查看运行着 ...
- makefile 中 $@ $^ %< 使用【转】
转自:http://blog.csdn.net/kesaihao862/article/details/7332528 这篇文章介绍在LINUX下进行C语言编程所需要的基础知识.在这篇文章当中,我们将 ...
- 安装centos7.1 32bit时,没有可用的网络设备的解决方法
安装的系统镜像文件:CentOS-7-i386-LiveGNOME-1511.iso 虚拟机版本: 问题: 原因: 原先我在这里选择的时候,以为自己安装的不是64位的,所以没有选择centos 64, ...
- 在centos6.5上面mount微软系统上安装ftp服务器
---恢复内容开始--- 现在用虚拟机开发linux软件,发现虚拟机提供的共享文件夹不能很好地工作,表现为: 1.我在windows上面修改了文件内容,在linux里面发现文件内容没有变化,需要做些等 ...
- PHP使用PHPExcel删除Excel单元格指定列的方法是怎样
有一个系统仅公司内部和外部经销商使用,在一个导出功能中公司内部员工跟外部经销商导出的列是不一样的(某些数据是不能提供给经销商的)因为导出的数据都是一样的(某些列外数据外部没有)因此并没有单独处理,而是 ...
- mongo 学习笔记
mysql语句 : ' ,,),(,,) mongo语句: db.}}).limit() db."}) db.}}) 条件操作符1 mongodb中的条件操作符有: (>) 大于 ...
- ecshop增加pc扫描二维码微信支付功能代码
ecshop开发网站,如果没有手机版,又想通过微信支付,可以加入pc二维码扫描微信支付功能 工具/原料 ecshop商城系统,phpqrcode,WxPayPubHelper 公众号已申请微信支付 方 ...