I wrote this trigger around 4 years ago to handle errors in an application based on Oracle Forms 6i. This trigger handles all errors with some custom messages for some specific errors and not only this after giving an appropriate message to the user it logs the error into a table named error_log, so that a DBA can view all the errors with their execution time, user and program information. See the example below:

On-Error Trigger code:

declare
    vabutton number;
    verrtxt varchar2(80) := error_text;
    verrno number := error_code;
    vdbms number := dbms_error_code;
    verrtype varchar2(20) := error_type;
begin
    if vdbms = -3114 or vdbms = -1017 or vdbms = -3115 or vdbms = -1012 then
   -- logon related errors
    set_alert_property('errmes', title, 'App '||ltrim(to_char(vdbms)));
    set_alert_property('errmes', alert_message_text, 'Logon denied.');
    vabutton := show_alert('errmes');            
    raise form_trigger_failure;
    end if;
    if verrno = 41009 OR VERRNO = 41008 or verrno = 40100 OR VERRNO = 40105 then
    --- ignoring all errors like at first record etc.
    NULL;
    elsif verrno = 40509 then
            insert into error_log (sqno, username, error_msg, error_cd, error_tp, error_dt, LOCATION) values 
      (error_seq.nextval, :MAIN.USERNAME, verrtxt, verrno, verrtype, sysdate, :SYSTEM.CURSOR_BLOCK);
      frmsave;
    set_alert_property('errmes', title, 'Info.'||ltrim(to_char(verrno)));
    set_alert_property('errmes', alert_message_text, 'You cannot update records.');
    vabutton := show_alert('errmes');    
    :main.er := :main.er + 1;
    else
        insert into hms.error_log (sqno, username, error_msg, error_cd, error_tp, error_dt, LOCATION) values 
      (hms.error_seq.nextval, :MAIN.USERNAME, verrtxt, verrno, verrtype, sysdate, :SYSTEM.CURSOR_BLOCK);
     --- frmsave is the database procedure to commit explicitly.
    frmsave;
    set_alert_property('errmes', title, 'Info.'||ltrim(to_char(verrno)));
    set_alert_property('errmes', alert_message_text, verrtxt);
    vabutton := show_alert('errmes');
    :main.er := :main.er + 1;
    end if;
    exception 
    when form_trigger_failure then
      null;
        when others then
        -- FOR DEBUG NEXT LINE TO KNOW ERROR NUMBER
--    set_alert_property('errmes', alert_message_text, '['||TO_CHAR(ERROR_CODE)||'] '||error_text); 
    insert into error_log (sqno, username, error_msg, error_cd, error_tp, error_dt, LOCATION)values 
      (error_seq.nextval, :MAIN.USERNAME, verrtxt, verrno, verrtype, sysdate, :SYSTEM.CURSOR_BLOCK);
      frmsave;
  set_alert_property('errmes', alert_message_text, error_text);
    vabutton := show_alert('errmes');
    :main.er := :main.er + 1;
end;

Error_Log Table structure:

1
SQNO
NUMBER(10)
2
USERNAME
VARCHAR2(20 BYTE)
3
ERROR_MSG
VARCHAR2(200 BYTE)
4
ERROR_CD
NUMBER(10)
5
ERROR_TP
VARCHAR2(10 BYTE)
6
ERROR_DT
DATE
7
LOCATION
VARCHAR2(20 BYTE)

See also: Writing On-Error Trigger in Oracle Forms

An Example of On-Error Trigger in Oracle Forms的更多相关文章

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

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

  3. Using Pre-Form Trigger In Oracle Forms

    Pre-Form trigger in Oracle Forms fires during the form start-up, before forms navigates to the first ...

  4. Define Custom Data Filter Using Pre-Query Trigger In Oracle Forms

    Oracle Forms is having its default records filter, which we can use through Enter Query mode to spec ...

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

  6. Examples For When-Validate-Item trigger In Oracle Forms

    The following example finds the commission plan in the COMMPLAN table, based on the current value of ...

  7. Using Post_Query Trigger in Oracle Forms

    When a query is open in the block, the Post-Query trigger fires each time Form Builder fetches a rec ...

  8. How to Log Users Login and Logout Details Through Oracle Forms

    Log user's login and logout details in to table through Oracle Forms using POST-LOGON and PRE-LOGOUT ...

  9. 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 FormsPre-Update Fires dur ...

随机推荐

  1. Ubentu搭建nfs服务器

    搭建nfs服务    功能:完成在线调试程序,远程挂载,在线调试    NFS(Network FileSystem,网络文件系统)是由SUN公司发展,并于1984年推出的技术,用于不同机器,不同操作 ...

  2. RMB转换人民币大小金额

    MXS&Vincene  ─╄OvЁ  &0000015 ─╄OvЁ  MXS&Vincene MXS&Vincene  ─╄OvЁ:今天很残酷,明天更残酷,后天很美好 ...

  3. sql插入删除表内字段基础操作

    1 取得表格资讯 1.1 DESCRIBE指令 「DESCRIBE」是MySQL资料库提供的指令,它只能在MySQL资料库中使用,这个指令可以取得某个表格的结构资讯,它的语法是这样的: 你在MySQL ...

  4. 【python cookbook】【数据结构与算法】17.从字典中提取子集

    问题:想创建一个字典,其本身是另一个字典的子集 解决方案:利用字典推导式(dictionary comprehension)可轻松解决 # example of extracting a subset ...

  5. 161011、oracle批量插入数据

    需求:从一张表中查询数据插入到另外一张表 -- Created on 2016/10/13 by RICK declare -- Local variables here begin ') loop ...

  6. LUA笔记之表

    表据说是LUA的核, 呵呵, 看例子吧, 看上去, 跟java的list很像, 又有点像json: a = {} -- create a table and store its reference i ...

  7. android 中通过代码创建控件

    package bvb.de.openadbwireless.circle; import android.annotation.TargetApi; import android.app.Activ ...

  8. 测试驱动开发神器框架Mockito

    作为菜鸟的我,以前没接触过Mock类型的框架,比如说要测试action层,我总是从action层调用service再调用dao访问数据库,这种方式从原则上来说是无疑是非常正确的,在没用mock框架之前 ...

  9. eclipse内置tomcat启动方法

    tomcat:run -Dmaven.tomcat.port=

  10. MySQL存储引擎中的MyISAM和InnoDB区别详解

    在使用MySQL的过程中对MyISAM和InnoDB这两个概念存在了些疑问,到底两者引擎有何分别一直是存在我心中的疑问.为了解开这个谜题,搜寻了网络,找到了如下信息: MyISAM是MySQL的默认数 ...