Thanks for the question, Evans.
Asked: April 01, 2020 - 7:29 am UTC
Last updated: April 03, 2020 - 2:36 am UTC
Version: 19.2
Viewed 1000+ times
You Asked
Hello,
I am a newbie developing an app on APEX 19.2. I have a table with a field START_DATE of data type TIMESTAMP WITH LOCAL TIME ZONE.
I also have a form with this field, for which I have specified Identification Type as Date Picker, and Format Mask DD-MON-YYYY HH24:MI:SS.
With the default validation on this field which checks that the value is of timestamp format, it all works very well; I can input date and time using the date picker and the form submits fine.
I am now trying to add an additional validation to ensure that the START_DATE is a future timestamp. So for this validation, I set the Validation Type as PL/SQL Expression and set the following for the expression:
:P17_START_DATE > CURRENT_TIMESTAMP
For completeness, I have set the Error Message as "#LABEL# must be in the future" and Associated Item as P17_START_DATE (which is how the form item appears). All other settings for the validation are left as default.
If I then try to submit the form, I get an error message saying "Error processing validation."
What am I doing wrong?
and Connor said...
The issue is the format mask.
Your items in APEX are essentially all strings, ie, a browser doesn't really have the idea of a datatype.
So (without a format mask), when you pick a date from a picker in APEX, you are are getting a formatted string into your item, where the format is *known* to APEX.
When your validation fires, whilst it reads like:
:P17_START_DATE > CURRENT_TIMESTAMP
the database is doing this behind the scenes to get the datatypes correctly aligned:
to_timestamp(:P17_START_DATE) > CURRENT_TIMESTAMP
That will work when you are not using a format mask. However, when *you* add your own format mask, that call above might fail because yours might not align with what apex/database is expecting.
So just change you validation to explictly control the formatting, ie
to_timestamp(:P17_START_DATE,'DD-MON-YYYY HH24:MI:SS') > CURRENT_TIMESTAMP
and you should be good to go
Rating
(2 ratings)
Is this answer out of date? If it is, please let us know via a Comment