Whenever we commit after entering data in Oracle Forms, many triggers fires during this event and also Pre-Update and Pre-Insert triggers fires just before inserting or updating the record into table. We can write Pre-Update and Pre-Insert triggers on particular block to just allow the process or to stop the process by using "Raise Form_Trigger_Failure" command, the following are the some examples:
 
Suppose you have a data block and there is a field which need to be validate just before inserting the record, then you must write the Pre-Insert trigger for this purpose, below is an example:
 
Declare
v_avl_qty number;
Begin
   Select avl_qty into v_avl_qty
     From stock_inhand
    Where Item_Code = :Block1.item_code;
if v_avl_qty < :Block1.qty_issued then
Raise Form_Trigger_Failure;
--- Execution stopped...
end if;
--- Else insertion will take place...
End;

And now I am giving you another example, suppose there is a field which need to be assigned from database just before the updation of the record, then you must write a Pre-Update trigger for this purpose, below is an example:

Declare
   v_value varchar2(10);
Begin
   Select a_value into v_value
     From a_table
    Where b_value = :Block1.b_value;
--- Assign this value to block item
:Block1.a_value := v_value;
--- you can assign any others value to any field just before updation or insertion like:
:Block1.create_date := Sysdate;
Exception
  when others then
     --- After any error or no data found you still want to continue then you can use only Null; statement
     Null;
     --- and any other value to any field you can still assign
:Block1.create_date := Sysdate;
End;

Why And When To Use Pre-Update and Pre-Insert Triggers In Oracle Forms的更多相关文章

  1. 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 ...

  2. MySQL update语句和insert插入语句写法完全不一样啊,不要搞混

    1.mysql update 语句: update user set name = 'xiaoming',age = 18 where uid = 3000; 更新记录时update操作也不需要写ta ...

  3. update更新多行数据(oracle)

    转自:http://blog.itpub.net/25322446/viewspace-767505 说明:笔记总结了在工作中遇到过的几种update方法和各种方法适用的范围. 1.单表更新方案:使用 ...

  4. 转 update关联更新在sqlserver和oracle中的实现

    sqlserver和oracle中实现update关联更新的语法不同,都可以通过inline view(内嵌视图)来实现,总的来说sqlserver更简单些. 测试例子如下: create table ...

  5. 存储过程返回update结果集和insert主键

    update teacher set name ='111' where id in(286,289);print @@rowcount;--或select将查出,是@@rowcount,不是@row ...

  6. with as 和update ,Delete,insert

    这个SQL写了很久的时间,感觉pgSQL的很是麻烦. with as 先命名一个表出来,就可以当成临时表用. WITH tmp AS ( SELECT MAX(mgi.inner_cd) AS inn ...

  7. insert失败自动执行update(duplicate先insert)

    例如:有一张表 字段有  id主键自增,或者唯一索引:datetime时间  name名字 INSERT INTO TABLE (id,datetime) VALUES (1,1440000000), ...

  8. mysql 存在update不存在insert

    如果在INSERT语句末尾指定了ON DUPLICATE KEY UPDATE,并且插入行后会导致在一个UNIQUE索引或PRIMARY KEY中出现重复值,则在出现重复值的行执行UPDATE:如果不 ...

  9. MySQL中insert ignore into, on duplicate key update,replace into,insert … select … where not exist的一些用法总结

    在MySQL中进行条件插入数据时,可能会用到以下语句,现小结一下.我们先建一个简单的表来作为测试: CREATE TABLE `books` ( `id` ) NOT NULL AUTO_INCREM ...

  10. [转]Oracle Form 触发器执行顺序

    Trigger 不是数据库中的触发器,不过功能类似,都是当某个事件发生的时候会触发. Trigger中可以编写代码,当对应事件发生的时候就会执行该Trigger中的代码. Oracle Form中的T ...

随机推荐

  1. zw版【转发·台湾nvp系列Delphi例程】CheckDifference1

    zw版[转发·台湾nvp系列Delphi例程]CheckDifference1 procedure TForm1.Button1Click(Sender: TObject);var img, img1 ...

  2. pic计数

    #include <pic.h> //用的是PICC编译器 __CONFIG (HS & PROTECT & PWRTEN & BOREN & WDTDIS ...

  3. SqlSever中Index Seek的匹配规则(一)

    我们知道在SqlServer中,索引对查询语句的优化起着巨大的作用,一般来说在执行计划中出现了Index Seek的步骤,我们就认为索引命中了.但是Index Seek中有两个部分是值得我们注意的,我 ...

  4. OpenStack 计算节点删除

    前提 计算节点中一个僵尸计算节点存在,而里面的CPU数目在总物理CPU中,导致认为当前能创建实例.而实际没有这么多资源. 其中node-11为僵尸节点. 原因 删除计算节点不能直接格式化该服务器,否则 ...

  5. django上传图片和文字记录

    直接上代码 html <form class="form-horizontal" id="upload-form"> <div class=& ...

  6. FireDac 与数据库连接时字符集及对应的字段类型问题

    近日在一个过程调用时发生一个奇怪现象, 异常返回意思是说, 数据的长度是[6], 而字段定义的长度是[3].  分析后认为:  调用过程你不涉及到对返回数据集的字段手动定义问题, 出现这个问题应是两边 ...

  7. VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装

    VMware中安装CentOS7网络配置静态IP地址,常用配置和工具安装在阿里云开源镜像地址下载镜像Index of /centos/7.2.1511/isos/x86_64/http://mirro ...

  8. Windows cmd 颜色,字体,color font set up

    windows的cmds默认的字体很丑,丑的不认直视,『如花』一般. 但是总有用到的时候 这是我有优化的一种结果,怎么来弄呢 要字体颜色漂亮,先要在注册表的Console中注册你要使用的字体,这个至关 ...

  9. webApi FileReader

    https://developer.mozilla.org/en-US/docs/Web/API/FileReader https://github.com/node-file-api/FileRea ...

  10. android的充电图标显示

    最近RK3026的项目需要修改开机充电,才分析了Android原生态的充电过程. 充电的代码和图标在system/core/charger中,会编译成名字为charger的可执行文件,打包进ramdi ...