8 Replies Latest reply: Jan 7, 2013 10:59 PM by HamidHelal RSS

    verification of item

    Goldray
      Hi,
      I have an item called "year", I'll do a check for the user enters a valid year (example:2012)

      1st question: what is the item must be of type integer or number or ... ?

      2nd question: I created a trigger when-validate-item whose code is:

      if :block6.item7 >1900 and :block6.item7 <=2013 then
           message ('date valid');
      else
           message('date must be between 1990 and 2013');
           end if;





      is that this code is it efficient? if not offer me a better.
        • 1. Re: verification of item
          Andreas Weiden
          1st question: what is the item must be of type integer or number or ... ?
          The itemtype could be a NUMBER.
          2nd question: I created a trigger when-validate-item whose code is:
          No need for any trigger. In the properties you can set the minimum value and the maximum value.

          If you want to stay with a trigger... you have to do a RAISE FORM_TRIGGER_FAILURE in case the validation fails. This will ensure that the user cannot save the data.
          • 2. Re: verification of item
            Goldray
            i think i will use trigger because when user enter wrong date ,so the code will be like this:

            if //condition then
                 message('date valid');
                 raise form_trigger_failure;
            else
                 message('date musb be between 1900 and 2013');
                 raise form_trigger_failure;
            end if;

            exception when others then
                 
                      message('date musb be between 1900 and 2013');

            right ?
            • 3. Re: verification of item
              Andreas Weiden
              right ?
              No.

              The first RAISE FORM_TRIGGER_FAILURE is wrong, as the validation is ok in this case.

              The exception-handler is totally useless, because
              - there is no reasonable error which can occur in the code
              - as you only give a standard text, you will never see the real error
              - last, but worst, it will catch the FORM_TRIGGER_FAILURE and therefore make the whole validation useless.

              i think i will use trigger because when user enter wrong date ,so the code will be like this:
              Seems that you like it complicated..
              • 4. Re: verification of item
                Goldray
                but the user can be enter a char (exemple : a) ,so i must use exception , right ?
                i want to use trigger just to inform the user (using alert message)
                • 5. Re: verification of item
                  Andreas Weiden
                  but the user can be enter a char (exemple : a) ,so i must use exception , right ?
                  No. If you define an item as datatype number, forms will check itself if the value is numeric and shows an error in this case. No need for an exception handler.
                  • 6. Re: verification of item
                    Goldray
                    I know that dera error message displayed at the box ...
                    but is there a possibility to display this message in a alert message ??
                    • 7. Re: verification of item
                      user346369
                      You can show messages in an alert box using the Show_Alert command. It just takes a little more work.
                      • 8. Re: verification of item
                        HamidHelal
                        979155 wrote:
                        I know that dera error message displayed at the box ...
                        but is there a possibility to display this message in a alert message ??
                        Yes , you can display message in alert box.

                        To do this first create an alert. and set the property like message,style and button

                        then show the alert in w-v-i-t trigger.

                        like
                        DECLARE
                             ALT NUMBER;
                        BEGIN
                             IF <your condition> THEN
                               ALT:=SHOW_ALERT('alert_name');
                             END IF;
                        
                        END;
                        Hope this helps..

                        Hamid