1 2 Previous Next 27 Replies Latest reply: Mar 21, 2013 12:23 PM by CraigB RSS

    verification of a date

    Goldray
      I have 3 types list items:
      1) :1 Day -> 31
      2) Month: 1 -> 12
      3) Year :1990 -> 2013

      I want to check that the user has selected a valid date .. if not an error message will be displayed, for example:
      31-02-2013: will be rejected

      Any suggestions?
        • 1. Re: verification of a date
          HamidHelal
          979155 wrote:
          I have 3 types list items:
          1) :1 Day -> 31
          2) Month: 1 -> 12
          3) Year :1990 -> 2013

          I want to check that the user has selected a valid date .. if not an error message will be displayed, for example:
          31-02-2013: will be rejected

          Any suggestions?
          Create when validate record trigger and write something like this
          /*when validate record trigger sample code */
          DECLARE
            TEST DATE;
          BEGIN
          
          SELECT TO_DATE('31-02-2013','DD-MM-RRRR') INTO TEST --- your combination of date
          FROM DUAL;
          
          
          EXCEPTION 
          WHEN OTHERS THEN
            message('invalid date');
            message('invalid date');
          END;
          Hope this helps

          Hamid
          • 2. Re: verification of a date
            CraigB
            Have you considered displaying a calendar and having your user select the date from the calendar? Take a look at How to use a calendar in a Form. This article show how to use a pure Forms calendar as well as using a Java Bean calendar and includes all of the code you need to implement either calendar.

            Craig...
            • 3. Re: verification of a date
              Goldray
              I testedwith the example 31-02-2013 but nothing is displayed:


              DECLARE
              TEST DATE;
              BEGIN

              SELECT TO_DATE(':registration.day||'-'||:registration.month||'-'||:registration.year','DD-MM-YYYY') INTO TEST --- your combination of date
              FROM DUAL;


              EXCEPTION
              WHEN OTHERS THEN
              message('invalid date');
              message('invalid date');
              END;
              • 4. Re: verification of a date
                HamidHelal
                SELECT TO_DATE(':registration.day||'-'||:registration.month||'-'||:registration.year','DD-MM-YYYY') INTO TEST --- your combination of date
                replace the above line with
                 SELECT TO_DATE(:registration.day||'-'||:registration.month||'-'||:registration.year,'DD-MM-RRRR') INTO TEST
                my example is worked.. you need to adjust the statement.

                Hope this works..
                • 5. Re: verification of a date
                  Goldray
                  it not work :/
                  • 6. Re: verification of a date
                    HamidHelal
                    979155 wrote:
                    it not work :/
                    What is your complete code and what data u'r given ? where you write the code ? when will it fire ?

                    Edited by: HamidHelal on Mar 19, 2013 3:07 AM
                    • 7. Re: verification of a date
                      Goldray
                      I wrote the code level when-validate-record trigger

                      => For example 31-02-2013 the exception message is not displayed
                      my form contains other items
                      • 8. Re: verification of a date
                        CraigB
                        it not work :/
                        What does happen? Are you positive your When-Validate-Item (WVI) trigger is firing? Have you tried debugging your form through the Forms Debugger?

                        I agree with Hamid, can you please show us your code?

                        Craig...
                        • 9. Re: verification of a date
                          Goldray
                          I only have this code :
                          when-validate-record trigger:

                          DECLARE
                          TEST DATE;
                          BEGIN

                          SELECT TO_DATE(:registration.day||'-'||:registration.month||'-'||:registration.year,'DD-MM-RRRR') INTO TEST --- your combination of date
                          FROM DUAL;


                          EXCEPTION
                          WHEN OTHERS THEN
                          message('invalid date');
                          message('invalid date');
                          END;
                          • 10. Re: verification of a date
                            CraigB
                            What about...
                            What does happen? Are you positive your When-Validate-Item (WVI) trigger is firing? Have you tried debugging your form through the Forms Debugger?
                            Craig...
                            • 11. Re: verification of a date
                              Goldray
                              What does happen?
                              when I select a date "31-02-2013" normally an exception will be displayed but this is not the case

                              Are you positive your When-Validate-Item (WVI) trigger is firing?
                              I have not used WVI trigger I used only WVR trigger

                              Have you tried debugging your form through the Forms Debugger?
                              I got the same result
                              • 12. Re: verification of a date
                                HamidHelal
                                979155 wrote:
                                What does happen?
                                when I select a date "31-02-2013" normally an exception will be displayed but this is not the case
                                No, after selection WVR trigger will not fire. It will fire when you want to leave the record. Remember it and check it.

                                Have you tried debugging your form through the Forms Debugger?
                                I got the same result
                                SELECT TO_DATE(:registration.day||'-'||:registration.month||'-'||:registration.year,'DD-MM-RRRR') INTO TEST --- your combination of date
                                FROM DUAL;
                                What you get the value of TEST when debug ?

                                Hope this helps

                                Hamid
                                • 13. Re: verification of a date
                                  CraigB
                                  Are you positive your When-Validate-Item (WVI) trigger is firing?
                                  I have not used WVI trigger I used only WVR trigger>
                                  As Hamid states, the When-Validate-Record (WVR) trigger will only fire when you leave the current record. If you need the validation to occur before leaving the record, you will need to use a different trigger. If this is the case, I recommend you move your validation logic to a Forms Program Unit and then call program unit from a When-Validate-Item trigger on each of your date-part fields. For example:
                                  /* Sample Validate_Date procedure */
                                  PROCEDURE Validate_Date IS
                                     TEST   DATE;
                                  BEGIN
                                    /* First test each Date-Part field... */
                                    IF ( :REGISTRATION.Day IS NOT NULL 
                                         AND :REGISTRATION.Month IS NOT NULL 
                                         AND :REGISTRATION.Year IS NOT NULL ) THEN 
                                      /* Use PL/SQL not SQL to test the Date Parts. */
                                      /* This prevents a trip to the database and   */
                                      /* works just as well.                        */
                                      TEST :=  TO_DATE(:registration.day||'-'||:registration.month
                                                       ||'-'||:registration.year,'DD-MM-YYYY');
                                    END IF;
                                  EXCEPTION 
                                    WHEN OTHERS THEN
                                      message('invalid date');
                                      message('invalid date');
                                  END Validate_Date;
                                  /* Sample Date-part fields WVI trigger */
                                  BEGIN
                                    Validate_Date;
                                  END;
                                  Have you tried debugging your form through the Forms Debugger?
                                  I got the same result >
                                  What was the result? Nothing? Did your WVR trigger fire? What was the value of your "TEST" variable?

                                  Craig...

                                  Edited by: CraigB on Mar 19, 2013 9:13 AM
                                  • 14. Re: verification of a date
                                    HamidHelal
                                    >
                                    TEST := TO_DATE(':registration.day||'-'||:registration.month
                                    ||'-'||:registration.year','DD-MM-YYYY');
                                    Hi, Craig
                                    Above line should be
                                        TEST :=  TO_DATE(:registration.day||'-'||:registration.month
                                                         ||'-'||:registration.year,'DD-MM-YYYY');
                                    Hamid
                                    1 2 Previous Next