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. 有图有真相——关于“视频专辑:零基础学习C语言 ”

  2. SVN使用(一)

    SVN简介: 为什么要使用SVN? 程序员在编写程序的过程中,每个程序员都会生成很多不同的版本,这就需要程序员有效的管理代码,在需要的时候可以迅速,准确取出相应的版本. Subversion是什么? ...

  3. UIViewController卸载过程(ios6.0以后)

    在ios6.0以后,废除了viewWillUnload方法和viewDidUnload方法. 在ios6以后,当收到didReceiveMemoryWarning消息调用之后,程序会自动调用didRe ...

  4. python PIL安装

    PIL:Python Imaging Library,已经是Python平台事实上的图像处理标准库了.PIL功能非常强大,但API却非常简单易用. 安装PIL 在Debian/Ubuntu Linux ...

  5. 【secureCRT】会话保存的路径

  6. Apache服务器访问过慢分析及解决

    起因:线上的一台服务器,最近总是出现 访问 很慢的情况发生,点击一个链接要2秒钟以上才能打开,按照我们对于访问人数的估计,服务器应该不至于响应这么慢,从而需要针对这个问题进行分析,来解决网站访问过慢. ...

  7. 将linux下的rm命令改造成移动文件至回收站【转】

    转自:http://blog.csdn.net/a3470194/article/details/16863803 [-] 将linux下的rm命令改造成移动文件至回收站 将AIX下的rm命令改造成移 ...

  8. Can't create/write to file '/tmp/#sql_887d_0.MYD' (Errcode: 17)

    lsof |grep "#sql_887d_0.MYD" 如果没有被占用就可以删掉 . https://wordpress.org/support/topic/cant-creat ...

  9. Install Hive

    一.Hive将元数据存储在RDBMS中,有三种模式可以连接到数据: 1.single User Mode:此模式连接到一个In-memory的数据库Derby,一般用于Unit Test. 2.Mul ...

  10. js笔记----(运动)淡入淡出

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...