Created an Oracle Form to handle specific events / triggers like When-New-Form-Instance, Pre-Insert, Post-Insert, Pre-Update, Post-Update, Post-Query and Post-Forms-Commit.

I am doing the following simple tasks on these events to give you an example:

When-New-Form-Instance Trigger

Picking up Oracle Session ID through USERENV function and User to display below the title of the form, the following is the code written:

BEGIN
   SELECT    'ORACLE SESSION ID: '
          || USERENV ('SESSIONID')
          || ' USER NAME: '
          || USER
     INTO :VAL_FORM_INSTANCE
     FROM DUAL;
END;

Post-Query Trigger

Populating the Department Name.

BEGIN
   SELECT department_name
     INTO :scott_emp.dptname
     FROM dept
    WHERE department_id = :scott_emp.deptno;
EXCEPTION
   WHEN OTHERS
   THEN
      NULL;
END;

Pre-Insert Trigger

Checking if the Hiredate is current date or not.

BEGIN
   IF :SCOTT_emp.HIREDATE <> TRUNC (SYSDATE)
   THEN
      :VAL_PRE_INSERT := 'Hire Date must be current date.';
      RAISE form_trigger_failure;
   END IF;

   -- else ok
   :VAL_PRE_INSERT := 'Hire Date is valid.';
END;

Post-Insert Trigger

Counting total number of employees in table.

BEGIN
   SELECT 'Employee Count After: ' || COUNT ( * )
     INTO :val_pOST_insert
     FROM scott_emp;
END;

Pre-Update Trigger

Checking if current day is Sunday then stopping the user the update the record.

BEGIN
   IF TO_CHAR (SYSDATE, 'DAY') = 'SUN'
   THEN
      :VAL_PRE_UPDATE := 'Update is not allowed on Sundays';
      RAISE form_trigger_failure;
   END IF;

   :VAL_PRE_UPDATE := 'Update is allowed today.';
END;

Post-Update Trigger

Just giving a simple message.

BEGIN
   :VAL_POST_UPDATE := 'You updated ' || :scott_emp.ename || '''s record.';
END;

Post-Forms-Commit Trigger

Displaying Date and Time of Last Commit

BEGIN
   :VAL_POST_COMMIT :=
      'Last Commit executed on '
      || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS');
END;

The following is the screen shot of this form and source code(Table's Script and FMB file) can be download from the following link: Form_Triggers.Zip

Oracle Form's Trigger Tutorial With Sample FMB的更多相关文章

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

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

  2. Standard Attachments in Oracle Form 标准附件

    Standard Attachments in Oracle Form 默认情况下"附件"按钮是灰色的,本文将展示如何让某个Form的附件按钮变亮,并能上传附件. 以用户Form为 ...

  3. [Form Builder]Oracle Form系统变量中文版总结大全

    转:http://yedward.net/?id=57 Form中的系统变量,它存在于一个Form的整个运行时期的会话之中,变量包含了有关Form相关属性的字节信息.有些变量标明了当前状态,还有些变量 ...

  4. oracle form 触发器执行顺序及键定义[Z]

    1当打开FORM时: (1)PRE-FORM (2)PRE-BLOCK(BLOCK级) (3)WHEN-NEW-FORM-INSTANCE (4)WHEN-NEW-BLOCK-INSTANCE (5) ...

  5. Oracle Form Builder

    Oracle Form Builder 是Oracle的一个开发工具,可以针对Oracle公司的E-Business Suit的ERP系统开发的.对应的还有reports builder. Oracl ...

  6. Oracle Form Data Entry Sample

    I shared a data entry example form here in this post for Oracle Forms beginner developers, so that t ...

  7. 转: Oracle Form 中commit 与do_key('commit_form')区别

    1.commit_form针对form上面的数据变动进行commit,对于代码中的类似update,insert语句也进行提交:如果form上面的数据变动和代码中的数据变动有冲突,最后以界面上的为准. ...

  8. FRM-10001, FRM-10002, FRM-10003 Oracle Form Builder Error Solution

    These errors occurred usually due to forms connection problem or some internal problem, the solution ...

  9. Oracle Form属性、内置子程序、触发器、系统变量简要

    一.属性 1.1 通用属性 名称(Name) 子类信息(Subclass Information) 备注(Comments) 标题(Title) 方向(Direction) 字体名称(Font Nam ...

随机推荐

  1. mysql中为int设置长度究竟是什么意思

    根据个人的实验并结合资料:1.长度跟可以使用的值的范围无关,值的范围仅跟类型对应的存储字节数和是否unsigned有关:2.长度指的是显示宽度,比如,指定3位int,那么id为3和id为300的值,在 ...

  2. 46、android studio第一次使用时卡在gradle下载怎么解决?

    如果没法FQ或者FQ后网速慢,哥教你一个快速解决方案. 在根目录下的.gradle目录下,找到wrapper/dists目录,如果当前正在下载gradle.x.xx-all.zip,那么会发现grad ...

  3. 模板与c++11--右值引用

    函数参数传递 struct huge_data{ char *content; unsigned sz; huge_data():content(),sz(){ cout<<this< ...

  4. activemq 简单聊天

    有兴趣加群qq:200634530

  5. iOS开发UI篇—自定义layer

    一.第一种方式 1.简单说明 以前想要在view中画东西,需要自定义view,创建一个类与之关联,让这个类继承自UIView,然后重写它的DrawRect:方法,然后在该方法中画图. 绘制图形的步骤: ...

  6. File(IO流)

    import java.io.File; import java.io.IOException; import org.junit.Test; /** *java.io.File类 *1.凡是与输入输 ...

  7. python数据结构元组与集合

    元组 1.()来定义 2.有序,同列表 3.元组一旦创建,不能被修改 注:元组的标识是逗号,不是括号 元组的定义 a = (1,2) type(a) <class 'tuple'> 元组的 ...

  8. openssl Rsa 分段加密解密

    密钥长度 1024 openssl genrsa -out rsa_private_key.pem openssl rsa -in rsa_private_key.pem -pubout -out r ...

  9. 关于 react state的改变数据上面的一点问题

    在react当中 比如说 this.state = { loginInfo: { account: "...", password: "..." } } thi ...

  10. Session 存储和失效方式

    Session 一般的操作是放在本地的Asp.net StatService上.实现进程隔离,方便Session操作,下面说说Session各属性. 1)不使用Session <sessionS ...