Home » Developer & Programmer » Forms » Is There A Equivalent To ON-ERROR?
Is There A Equivalent To ON-ERROR? [message #79299] Wed, 22 May 2002 09:38 Go to next message
Tyler
Messages: 123
Registered: January 2002
Senior Member
Hello,

My problem is that sometimes when I use the on-error to catch an ORA or FRM error, it's not erroring it like I'm telling it to in the code, using ERROR_CODE and ERROR_TYPE. It will catch the error, so as not to message the error code at the bottom, but it will not display my message that I have told it to message 'if' it gets the specific ERROR_CODE. It just won't error anymore.

Is there a better trigger than on-error.

Thanx much,
T
Re: Is There A Equivalent To ON-ERROR? [message #79307 is a reply to message #79299] Thu, 23 May 2002 05:27 Go to previous message
nik
Messages: 55
Registered: January 2002
Member
tyler,
it should and probably does. Experiment at different levels i.e. block and form. Are you aware of the on-message trigger also, here have a look at my recent on-message and on-error triggs, which will probably help u. Remember try at BLOCK and FORM level.

BLOCK LEVEL (On -error)
-----------------------
declare

var_dummy number;
v_cr constant char(1) := CHR(10);
errnum number := error_code;
errtxt varchar2(80) := error_text;
errtyp varchar2(3) := error_type;

begin

if errnum = 40202 then
message('Must enter a location identification number !',no_acknowledge);
raise form_trigger_failure;
elsif errnum = 40200 then
message('Update of Location ID is not allowed.',no_acknowledge);
raise form_trigger_failure;
elsif errnum = 40353 then
message('Query cancelled !',no_acknowledge);
message('Press F7 to enter a query or enter a location identifcation number');
raise form_trigger_failure;
elsif errnum = 40356 then
message('Last Receipt Number must be numeric !');
raise form_trigger_failure;
elsif errnum = 40100 then
message('You are at the first record !',no_acknowledge);
raise form_trigger_failure;
elsif errnum in (41000, 41004) then
null;
elsif errnum = 50016 then
message('Field is numeric !',no_acknowledge);
raise form_trigger_failure;
elsif errnum = 40401 then
message (errtxt);
raise form_trigger_failure;
elsif errnum = 40509 then
bell;
set_alert_property('info_alert',title,'Not Permitted !');
var_dummy := wpe_show_alert('Info_alert','Records exist in cash expenditure/bank details file !');
raise form_trigger_failure;
elsif errnum = 40508 then
bell;
set_alert_property('info_alert',title,'No Duplicates !');
var_dummy := wpe_show_alert('Info_alert','This identification number already exists - NO duplicates allowed !');
raise form_trigger_failure;
elsif errnum = 40101 then
null;
elsif errnum = 40102 then
message (errtxt);
elsif errnum = 40657 then
message ('Record is being used by another user !');
elsif errnum = 40501 then
var_dummy := wpe_show_alert('error_alert','No action possible'||v_cr||
'This record is being used by another user !');
raise form_trigger_failure;
else
message(errtyp||'-'||to_char(errnum)||': '||errtxt);
raise form_trigger_failure;
end if;

end;

BLOCK LEVEL (on-message)
------------------------
declare

msgnum number := message_code;
msgtxt varchar2(80) := message_text;
msgtyp varchar2(3) := message_type;
var_dummy number;

begin

if msgnum = 40353 then
message('Query cancelled !');
clear_form(no_validate);
elsif msgnum = 41800 then
message('Function not available !');
elsif msgnum = 40352 then
set_alert_property('info_alert',title,'Last record !');
var_dummy := wpe_show_alert('info_alert','You are at the last record !');
elsif msgnum in (40301,40355) then
:ssbklocn.locn_id := null;
:ssbklocn.lname := null;
:ssbklocn.ladd1 := null;
:ssbklocn.ladd2 := null;
:ssbklocn.ladd3 := null;
:ssbklocn.lpost := null;
:ssbklocn.ltel := null;
:ssbklocn.rid := null;
:ssbklocn.lrno := null;
message('No matching records found !');
elsif msgnum = 40355 then
message (msgtxt||'...............');
elsif msgnum = 42100 then
message (msgtxt);
elsif msgnum = 40400 then
message (msgtxt,no_acknowledge);
elsif msgnum = 40101 then
null;
elsif msgnum = 40657 then
message ('Record is being used by another user !');
else
message(msgtyp||'-'||to_char(msgnum)||': '||msgtxt);
end if;

end;

on-err form level
-----------------
declare

errnum number := error_code;
errtxt varchar2(80) := error_text;
errtyp varchar2(3) := error_type;

begin

if errnum = 40401 then
message (errtxt);

else
message(errtyp||'-'||to_char(errnum)||': '||errtxt);
raise form_trigger_failure;

end if;

end;

on-message form-level
-------------------
declare

msgnum number := message_code;
msgtxt varchar2(80) := message_text;
msgtyp varchar2(3) := message_type;

begin

if msgnum = 40400 then
bell;
message (msgtxt||'...............');
else
wpe_message_handler;
message(msgtyp||'-'||to_char(msgnum)||': '||msgtxt);

end if;

end;

Experiment and enjoy
nik.
Previous Topic: TEXT_IO
Next Topic: Best Book for Oracle Architecture / DBA.
Goto Forum:
  


Current Time: Thu Apr 18 06:15:37 CDT 2024