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. zw版【转发·台湾nvp系列Delphi例程】HALCON OverpaintRegion2

    zw版[转发·台湾nvp系列Delphi例程]HALCON OverpaintRegion2 unit Unit1;interfaceuses Windows, Messages, SysUtils, ...

  2. 关于UIView(转)

    曾经有人这么说过,在iphone里你看到的,摸到的,都是UIView,所以UIView在iphone开发里具有非常重要的作用.那么UIView我们到底知道多少呢.请看看下面的问题, 如果这些你都知道, ...

  3. win7 chm 打开失败记录

    近期学习rails,制作的html帮助文件想生成chm文件,用了几个网上的html制作chm软件,生成的chm无法打开. 网上大部分解决方法是修改文件属性,Unlock之后可解决. 以前遇到过打不开, ...

  4. 161201、常用 SQL Server 规范集锦

    常见的字段类型选择   1.字符类型建议采用varchar/nvarchar数据类型 2.金额货币建议采用money数据类型 3.科学计数建议采用numeric数据类型 4.自增长标识建议采用bigi ...

  5. scala一些高级类型

    package com.ming.test import scala.collection.mutable.ArrayBuffer import scala.io.Source import java ...

  6. std::map 自定义排序

    PS:开发中难免会用到快速检索的数据结构-map , 很多时候map自身提供的排序不能满足我们的需要或者不支持我们自定的数据结构的排序,解决办法就是自己实现排序. 这里的小案例是:我们要经用户的has ...

  7. 浅析String、StringBuffer、StringBuilder的区别以及性能区别

    前奏: 比较三者之间的区别在与区别他们做相同的事情的时候的区别,那就是在我们常见的拼接字符串的时候,StringBuffer.StringBuilder调用的是appende()方法,而String很 ...

  8. jQuery.isNumeric() 和 js isNaN()

    jQuery.isNumeric( value ) Description: 判断指定参数是否是一个数字值(字符串形式的数字也符合条件),返回 true 或者 false. Example: $.is ...

  9. rsync 排除指定目录或文件进行同步

    很常见的情况:我想同步/myweb下的 一些php文件 ,  但是不想复制/myweb/log/里边的一些日志文件,因为这些文件太大了,备份也是没有意义的. 现在如果想避开某个路径  直接添加—exc ...

  10. C#:WiFi

    写的一个简单启动关闭WiFi的类:具体如下 using System; using System.Collections.Generic; using System.Text; using Syste ...