Home » Developer & Programmer » Forms » verification an item manually (oracle forms 10g ,win xp pack 2)
verification an item manually [message #574750] Tue, 15 January 2013 10:41 Go to next message
goldray
Messages: 108
Registered: December 2012
Senior Member
Hi,
I want to check an item manually.
Here is the code:
//when-validate-item
declare
	i number;

begin
if :a.b is null then
	i:=show_alert('null');
	
else if :a.b between 1900 and 2013 then 
	message('date valid');
else 
	i:=show_alert('date_invalid');
	:a.b:=null;
	raise form_trigger_failure;	

end if;
end if;

exception when others then
		i:=show_alert('exception');
		
		end;

the problem for example when I entered a value "3000" I received two messages (the first on the alert "date_invalid" and the 2nd on the exception message)
but normally I must received one message, the relative "date_invalid"
Re: verification an item manually [message #574755 is a reply to message #574750] Tue, 15 January 2013 10:52 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
So remove the exception handler, it does nothing useful here.
Re: verification an item manually [message #574757 is a reply to message #574755] Tue, 15 January 2013 11:05 Go to previous messageGo to next message
goldray
Messages: 108
Registered: December 2012
Senior Member
I used the exception to display a message when the user enters a value like this: a
I modified the code :

declare
i number;

begin
if :a.b is null then
i:=show_alert('null');

else if :a.b between 1900 and 2013 then
message('date valid');
else
i:=show_alert('date_invalid');
:a.b:=null;

end if;
end if;

exception when others then
i:=show_alert('exception');
raise form_trigger_failure;
end;

now its works ,but I want the cursor remains in the same item

[Updated on: Tue, 15 January 2013 11:09]

Report message to a moderator

Re: verification an item manually [message #574770 is a reply to message #574757] Tue, 15 January 2013 13:26 Go to previous messageGo to next message
cookiemonster
Messages: 13920
Registered: September 2008
Location: Rainy Manchester
Senior Member
Do you think I don't know how forms works?
do you think if I tell you to get rid of something I might have a good reason?

You've just broken your trigger. The whole point of when-validate-item triggers is that they should raise an error when the item is invalid. Doing so ensures that forms won't let you save the invalid value. You've removed the raise form_trigger_failure for date_invalid, so the trigger completes without error and forms thinks the item is valid and will let you save it.

As for this:

goldray wrote on Tue, 15 January 2013 17:05
I used the exception to display a message when the user enters a value like this: a

I assume the datatype of the item is number? If so forms checks the datatype before firing the when-validate-item trigger. So entering a non-numeric value will not cause the exception handler to fire.


So I repeat: remove the exception handler, it does nothing useful here.

If you do that and put the raise form_trigger_failure back where it was it'll work.

And read WHEN OTHERS

And if the field shouldn't be null set the required property.
Re: verification an item manually [message #574880 is a reply to message #574770] Wed, 16 January 2013 08:41 Go to previous message
goldray
Messages: 108
Registered: December 2012
Senior Member
ok, I'll make the field required ..
thank you
Previous Topic: How To call a java class into oracle forms11g
Next Topic: Problem when navigating with mouse cursor
Goto Forum:
  


Current Time: Thu Apr 25 05:35:55 CDT 2024