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. Floyd算法核心代码证明

    Flody  大家都知道这个最终模版: for(int k=1;k<=n;k++) for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) dis[i ...

  2. java的servlet初步学习

    目录 1.servelet概念作用理解 ====来源于孤傲苍狼  http://www.cnblogs.com/xdp-gacl/p/3760336.html======= 2.servlet的运行过 ...

  3. android 应用架构随笔三(ListView)

    import java.util.ArrayList; import java.util.List; import com.heima.googleplay.holder.BaseHolder; im ...

  4. 161208、Java enum 枚举还可以这么用

    在大部分编程语言中,枚举类型都会是一种常用而又必不可少的数据类型,Java中当然也不会例外.然而,Java中的Enum枚举类型却有着许多你意想不到的用法,下面让我们一起来看看. 先来看一段代码示例: ...

  5. WINCE 隐藏标题栏

    转自:https://social.msdn.microsoft.com/Forums/en-US/cef1c20a-25cf-49b6-a56e-6bc733be88f8/removing-the- ...

  6. ThinkPHP跳转与重定向的区别在哪里

    跳转: 浏览器认为 : 当前 URL 请求成功 , 重新请求新的 URL . 浏览器会记录当前的 URL 和新的 URL 在请求历史记录中. 回退, 是可以回退到 , 当前的 URL 上的 . ( 无 ...

  7. PHP中使用数组指针函数操作数组示例

    数组的内部指针是数组内部的组织机制,指向一个数组中的某个元素.默认是指向数组中第一个元素通过移动或改变指针的位置,可以访问数组中的任意元素.对于数组指针的控制PHP提供了以下几个内建函数可以利用. ★ ...

  8. ecshop微信支付(0923更新)商户支付密钥key的生成与设置

    ECSHOP 微信支付(0923更新)商户支付密钥key的生成与设置 说明:新版微信支付,用户必须授权登录才能支付.需要商家自己设置商户号支付密钥. 申请微信支付手机版部分时需要填写的配置接口地址: ...

  9. Python模块学习

    6. Modules If you quit from the Python interpreter and enter it again, the definitions you have made ...

  10. Session机制(是对cookie的作用的提升,使用较多)

    1.Session作用类似于购物车,第一次,放入物品,可以获得Session的id,并可以设置id失效的时间,这样便于多次将物品放在购物车里面,使用的就是获取的Session的id: 2.Sessio ...