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 ...
随机推荐
- STM32内存跟FLASH问题
RO: 常量 ZI: 未初始化的全局变量 RW: 初始化的全局变量 Code: 程序本身 Code, RO-data,RW-data ..............flash RW-data, ZIda ...
- JBuilder链接sql server数据库
加载你的jdbc的驱动 一.将jdbc驱动解压到一个指定的目录,例如:c:\sql_server_jdbc, 其中包含三个驱动文件:msbase. ...
- 在Ubuntu Kylin下安装QQ教程
下载: 下载地址:http://www.ubuntukylin.com/application/show.php?lang=cn&id=279 下载后解压得到wine-qqintl文件夹,里面 ...
- vi的使用规则
1.vi的基本概念 基本上vi可以分为三种状态,分别是 命令模式(command mode).插入模式(Insertmode)和 底行模式(last line mode) 各模式的功能区分如下: 1 ...
- rotate array 旋转数组
class Solution {public: void rotate(vector<int>& nums, int k) { int n=nums.size(); int i=0 ...
- bodybuilding
增大肌肉块的14大秘诀:大重量.低次数.多组数.长位移.慢速度.高密度.念动一致.顶峰收缩.持续紧张.组间放松.多练大肌群.训练后进食蛋白质.休息48小时.宁轻勿假. 1. 大重量.低次数:健美理论中 ...
- hibernate核心接口,和扩展接口。回顾笔记,以前没记,现在补上,纯手工敲的。
hibernate核心接口: 所有的hibernate应用都会访问hibernate的5个核心接口 1,Configuration接口 Configuration用于配置并且根启动Hibernate. ...
- Oracle错误:ORA-01033
Oracle错误:ORA-01033 错误编码:ORA-01033: ORACLE initialization or shutdown in progress 故障描述:因为移动了数据库文件([NA ...
- 8、web入门回顾/ Http
1 web入门回顾 web入门 1)web服务软件作用: 把本地资源共享给外部访问 2)tomcat服务器基本操作 : 启动: %tomcat%/bin/startup.bat 关闭: % ...
- Eclipse中Outline里各种图标的含义
在使用Eclipse或者MyEclipse开发的时候,你一定看到过Outline和Package Explorer中小图标,很多刚刚接触编程的童鞋们可能不会在意它们代表的含义,但如果你花几分钟的时间了 ...