9 Replies Latest reply: Apr 24, 2013 8:31 AM by CraigB RSS

    Problem with enter query mode. FRM 41009, 40301

    MichaelR
      Hello Everyone,

      I have a problem with enter query mode. Let say i'm in the enter query mode, and i click on a button. I will get the error FRM-41009 displayed.

      Now, i wanted to handled it. So i created an on-error trigger to handle the error.

      IF ERR_CODE= 41009 THEN
      NULL;
      END IF;

      One problem is that when using null, it does not exit the enter query mode, and then i get the error frm 40301.

      Second problem is that i cannot use exit_form in an on-error trigger.

      I'm aware that i can press F4 to exit this mode but i dont want to make the user do it each time as i'm sure i'll get complaints.

      Another solution would be to put the following code in the when-button-pressed trigger for each button in the form:

      if :system.mode='ENTER-QUERY' then
      exit_form;
      end if;

      But i dont want to replicate this code everywhere in my form.

      Please can you provide me with an idea how to handle this properly ?

      Thank you,
      Michaël

      PS : Version of form => ORACLE FORMS 10g (Forms [32 Bit] Version 10.1.2.3.0 )
        • 1. Re: Problem with enter query mode. FRM 41009, 40301
          BEDE
          I believe you should handle the thing on the when-button-pressed trigger of the button you press, something like:
          if :syste.mode='ENTER-QUERY' then
            exit;
          end if;
          -- do the stuff the button is supposed to do...
           
          • 2. Re: Problem with enter query mode. FRM 41009, 40301
            MichaelR
            Thank you for the reply :) But I already mentioned that in my post.. I need another solution. I cant go and write this code for every button in my form!
            • 3. Re: Problem with enter query mode. FRM 41009, 40301
              Amatu Allah Neveen Ebrahim
              Hi
              pls check ur current data block &its items resides..
              Is its "Query allowed" property set to "Yes
              or
              try using...
              Clear_Message;
              Instead of null...

              Or
              if u r having go_block & go_item somewhere in ur form u could use
              SYNCHRONIZE before and after
              Hope it works...

              Amatu Allah

              Edited by: Amatu Allah on Apr 23, 2013 3:29 AM
              • 4. Re: Problem with enter query mode. FRM 41009, 40301
                MichaelR
                Thank you for your reply.. Unfortunately it didn't work. Please do you know if there are alternative ways to exit the enter_query mode without using 'EXIT_FORM'?

                (yn)

                Michaël.
                • 5. Re: Problem with enter query mode. FRM 41009, 40301
                  Amatu Allah Neveen Ebrahim
                  Hi
                  ok all u have to do is using KEY-EXIT Trigger form level using same code u previously posted in ur first thread using EXIT FORM Built in.

                  Amatu Allah
                  • 6. Re: Problem with enter query mode. FRM 41009, 40301
                    MichaelR
                    Hello,

                    Maybe this is impossible to do.. In fact I need builtin that operates like EXIT_FORM to place in my on-error trigger. That's why i needed an alternative to EXIT_FORM.

                    Code of on-error-trigger:

                    IF :system.mode='ENTER-QUERY' and error_code = 41009 THEN
                         Exit_Form; -- <== EXIT_FORM doesn't work in on-error trigger :(
                    END IF;

                    Thanks anyway :)

                    Michaël.
                    • 7. Re: Problem with enter query mode. FRM 41009, 40301
                      CraigB
                      I have a problem with enter query mode. Let say i'm in the enter query mode, and i click on a button. I will get the error FRM-41009 displayed.
                      What is the code in your Button's When-Button-Pressed (WBP) trigger? Perhaps you should check to see if the Form is in Query Mode in your WBP rather than try and supress the error? In other words, eliminate the error - don't supress it. :)

                      If you would rather supress the error, there is a technique to calling Restricted Built-ins from a trigger that doesn't allow them. You do this through the use of a zero millisecond Timer. For example:
                      /* Sample On-Error Trigger */
                      DECLARE
                        n_err_cd   NUMBER := ERROR_CODE;
                        t_on_error TIMER;
                        ZERO  NUMBER := 0;
                      BEGIN
                        IF ( n_err_cd = 41009 ) THEN
                          /* Create Timer to execute Exit_Form() */
                          /* to Cancel Query-Mode. */
                          t_timer := Create_Timer('ON_ERROR', ZERO, NO_REPEAT);
                        ELSE
                          /* Handle all other errors here... */
                        END IF;
                      END;
                      /* Sample When-Timer-Expired Trigger */
                      DECLARE
                        v_Timer  VARCHAR2(30);
                      BEGIN
                        v_timer := Get_Application_Property(TIMER_NAME);
                        
                        IF ( v_timer = 'ON_ERROR' ) THEN 
                          /* Notice, the timer name is case sensative! */
                          Exit_Form;
                        END IF;
                      END; 
                      I'm aware that i can press F4 to exit this mode but i dont want to make the user do it each time as i'm sure i'll get complaints.
                      Well, this is just standard Oracle Forms functionality. If you put the Form into Query Mode - you must either execute a query or cancel the Query Mode! That's how it works. Your users need to understand this and accept it - just as they accept the functional characeristics of other programs. ;) Another option would be to add a "Cancel Query" button to your form and make it so it is only enabled when the Form is put in Query Mode. Just a thought...

                      Personally, I prefer to prevent the occurance of an error rather than suppress the error. :)
                      Hope this helps.
                      Craig...
                      • 8. Re: Problem with enter query mode. FRM 41009, 40301
                        MichaelR
                        CraigB wrote:What is the code in your Button's When-Button-Pressed (WBP) trigger?
                        There was different buttons. Some having some specific coding. And some others to duplicate lines, query ect.


                        Both the timer and the cancel button worked! The timer is a very nice solution :)

                        Thank you for your help. (y)

                        Michaël.

                        Edited by: MichaelR on 23-Apr-2013 21:04
                        • 9. Re: Problem with enter query mode. FRM 41009, 40301
                          CraigB
                          Glad I was able to help!
                          Craig B-)