An Example of On-Error Trigger in Oracle Forms
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的更多相关文章
- 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 ...
- 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. ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 显示刚刚添加的最后一条数据,access,选择语句,select
显示刚刚添加的最后一条数据,access,选择语句,select select top 1 * from s1 order by id desc
- Android 常用工具类之LogUtil,可以定位到代码行,双击跳转
package cn.utils; import android.util.Log; public class LogUtils { public static boolean isDebug = t ...
- flex datagrid 换行
<mx:DataGrid id="myGrid" width="100%" height="90%" headerStyleName= ...
- Codeforces 735C:Tennis Championship(数学+贪心)
http://codeforces.com/problemset/problem/735/C 题意:有n个人打锦标赛,淘汰赛制度,即一个人和另一个人打,输的一方出局.问这n个人里面冠军最多能赢多少场, ...
- linux下访问中文目录文件
文件路径包含中文时,可输入部分文件名,然后按Tab键. 当路径包含中文括号时,用斜杠,如: \(….\) . 也可用 ls -li ,先查看inum(inode编号),然后再根据编号进行访问,用查找命 ...
- js 判断某个对象是不是dom对象
<script type="text/javascript">//首先要对HTMLElement进行类型检查,因为即使在支持HTMLElement的浏览器中,类型却是有 ...
- hdwiki 软件包结构
HDWiki软件包结构转载自http://www.chinabaike.com/z/shenghuo/pc/2011/0414/814308.html 根目录下的PHP文件 ...
- class打包成exe方式
首先运行dos命令 jar -cvf **.jar *.class 把所有文件打包成jar包 用解压器打开jar包 打开meta-inf文件夹 打开用记事本打开main.mf文件 增加语句Main-C ...
- 棋盘问题 分类: 搜索 POJ 2015-08-09 13:02 4人阅读 评论(0) 收藏
棋盘问题 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 28474 Accepted: 14084 Description 在一 ...
- java 导入自定义类
eclipse导入很容易,昨天上课学了一下用记事本写java,导入自定义类,这就麻烦了. 代码贴一下,方便操作: package tom.jiafei; public class SquareEqua ...