Oracle forms force date validation [message #235130] |
Fri, 04 May 2007 02:44 |
kastania
Messages: 19 Registered: May 2007
|
Junior Member |
|
|
Hi to all!!! It's the first time I use this forum and I sincerely hope I'll find answers:)
Here I go.....
I have a form which has a database text item, type DATE. Whenever a users enters invalid data e.g characters or wrong date format, I want to force validation, that is, not let him leave the field until he enters correct data. I managed to do this, using an on-error trigger catching errors. In the trigger I RAISE Form_trigger_Failure. This way I managed to force the user enter valid data(although even if I won't use Form_trigger_Failure It will work...).
In my form I also have a CANCEL button. I want whenever the user press the button to cancel previous actions!
Now my problem: If user enters invalid date in the text field and not manually clear the field, the button Cancel doesnt work..... . I don't want to set date to null in my on-error trigger because then, If user presses SAVE the transaction will be commited and the date field will be left null and I don't want this.
I assume it's RAISE Form_trigger_Failure that causes the problem, but I have tried and without it...How else can I force validation???
|
|
|
Re: Oracle forms force date validation [message #235173 is a reply to message #235130] |
Fri, 04 May 2007 04:12 |
|
Littlefoot
Messages: 21823 Registered: June 2005 Location: Croatia, Europe
|
Senior Member Account Moderator |
|
|
If this date column may not be NULL, alter table and modify this column to be NOT NULL (Forms will automatically mark this item as REQUIRED). Leave it to the database whenever you can; don't code such things. Or, make your life a little bit more complicated and code KEY-COMMIT trigger (which fires when you press "Save") and test for all NULL items, such as
IF :date_item IS NULL THEN
message('Date item can not be null');
raise form_trigger_failure;
ELSE
COMMIT;
END IF;
[Updated on: Fri, 04 May 2007 04:12] Report message to a moderator
|
|
|
Re: Oracle forms force date validation [message #235186 is a reply to message #235173] |
Fri, 04 May 2007 04:33 |
kastania
Messages: 19 Registered: May 2007
|
Junior Member |
|
|
First I would like to THANK you for your quick answer! I totally aggree with you but the requirements of the project were that date field can be null....
I found a solution tha works but I don't know if it is the best solution or the smartest..
on-error trigger I SET_FORM_PROPERTY(:SYSTEM.CURRENT_FORM, VALIDATION_UNIT, FORM_SCOPE), so It does validation while it lets me push the Cancel button.
|
|
|
Re: Oracle forms force date validation [message #235224 is a reply to message #235186] |
Fri, 04 May 2007 07:09 |
ab_trivedi
Messages: 460 Registered: August 2006 Location: Pune, India
|
Senior Member |
|
|
you have solved it that is great but first let us know if you want date field is NOT NULL or it can accept null. beacause the answer given by LF is that condition date is compulsory?
But later on you told that date can be left blank???
AT
|
|
|
Re: Oracle forms force date validation [message #235232 is a reply to message #235224] |
Fri, 04 May 2007 07:27 |
kastania
Messages: 19 Registered: May 2007
|
Junior Member |
|
|
Yes, you are right I wasn't clear from the beginning. The Date, while editing, cannot be left null. But I was asked to do it, without altering the constraints of the database.
So, If I had left validation on ITEM_SCOPE, in case of invalid data entry, I could not click elsewhere(in my case Cancel button), unless I assigned NULL and that is because of the form_trigger_failure. Something that I could not "allow", because If I did the user might press "save" and the field would stay null.
That is why I alter the validation Scope.
I hope I made you understand.
|
|
|