Format mask error handling - help! [message #354334] |
Fri, 17 October 2008 15:19 |
cgage
Messages: 3 Registered: October 2008
|
Junior Member |
|
|
I'm having a problem with handling invalid user
entries in a field with a format mask applied
at the Property Palette and error message notification
via a ON-ERROR trigger
The account number is a 22-digit number,
and the 'ACCOUNT_NUMBER' field has a property palette format
mask of 99'-'9999'-'9'-'9999'-'9999'-'9999'-'999
Current behavior: When users type an invalid account
number in the field e.g. '123', or 'abc', an FRM-40209
format mask error is thrown, and it is handled via
an ON-ERROR trigger which detects the FRM40209 error
and puts up an 'Invalid account number' message.
The problem is that it puts this message up TWICE...
Q: Is there a way to suppress the second message from
popping up?
Thank you for your responses....
|
|
|
|
Re: Format mask error handling - help! [message #354481 is a reply to message #354384] |
Sun, 19 October 2008 13:02 |
cgage
Messages: 3 Registered: October 2008
|
Junior Member |
|
|
I'm Sorry that I didn't email my
code home so I could have put it up.
Also, it appears that I left out some detail
(as always..). There is a KEY-NEXT-ITEM trigger
on the account_number field which moves the cursor
to the next account_number field if nothing is entered
(NULL), or to the Amount field if a valid account number
is entered.
the format that is always used when I
generate Alert messages is:
nError := ALERT_PKG.STOP_OK('Invalid account number.')
RAISE FORM_TRIGGER_FAILURE;
So your response doesn't answer my question...
I think the code for the ON-ERROR is something like this:
Don't pick at my syntax right now - I'm still a raw
beginner and I'm doing this from weak memory...
DECLARE
cType VARCHAR2(3) := ERROR_TYPE;--(however this gets assigned)
cError NUMBER := ERROR_CODE;--(same here)
cDesc VARCHAR2(30) := ERROR_TEXT;--(etc)
cCode VARCHAR2(10);
BEGIN
cCode := (cType || To_Char(cError) );
If cCode = 'FRM40209' THEN
nError := ALERT_PKG.STOP_OK('Invalid account number.')
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
I still believe that it may have something to do with
the immediate effect of the KEY-NEXT-ITEM trigger or
perhaps the format mask property of the ACCOUNT_NUMBER
field.
[Updated on: Sun, 19 October 2008 13:08] Report message to a moderator
|
|
|
Re: Format mask error handling - help! [message #354491 is a reply to message #354481] |
Sun, 19 October 2008 21:57 |
subba99
Messages: 31 Registered: September 2008
|
Member |
|
|
HI CGAGE ,I didn't Know the fuction
ALERT_PKG.STOP_OK('Invalid account number.')
In this example ,i set sal field, format mask=$99999, and written ON-ERROR Trigger on sal field when the user try to enter wrong format ,it will dispaly alert message,when u press ok it place the cursor in the same field
please try this code,
declare
cType VARCHAR2(3) := ERROR_TYPE;--(however this gets assigned)
cError NUMBER := ERROR_CODE;--(same here)
ccode VARCHAR2(30) := ERROR_TEXT;--(etc)
ctext VARCHAR2(10);
BEGIN
cCode := (cType || To_Char(cError) );
ctext:=GET_ITEM_PROPERTY('emp.sal',FORMAT_MASK);
If cCode = 'FRM40209' THEN
message('enter feild of the form '||ctext);
message(' ');
RAISE FORM_TRIGGER_FAILURE;
END IF;
END;
NOTE:If we use empty message() function after Message() function with message then it displays the message in the form of ALERT dialog box
sorry,I don't know with KEY-NEXT-ITEM trigger,
[Updated on: Sun, 19 October 2008 21:58] Report message to a moderator
|
|
|
Re: Format mask error handling - help! [message #354681 is a reply to message #354491] |
Mon, 20 October 2008 16:41 |
cgage
Messages: 3 Registered: October 2008
|
Junior Member |
|
|
Dear Subba99,
I believe I've solved my own problem...
The error messages were firing twice because
of the KEY-NEXT-ITEM triggers moving the cursor
to the next field automatically after a format
mask error (FRM-40209) is thrown.
I worked around this by putting in code to set
a global flag in the ON-ERROR triggers that capture the
FRM-40209 error (there are several). I then use this flag to determine if an error was thrown while the KEY-NEXT-ITEM trigger
has fired. KEY-NEXT-ITEM is a built-in trigger that fires
when TAB or ENTER is pressed. If the error flag is 'TRUE' then
the cursors are not moved and only one error message is shown.
VOILA. It may not be elegant and perphaps I shouldn't be using
any global variable to pass data between triggers, but it works for now.
|
|
|
|