7 Replies Latest reply on Dec 4, 2013 7:52 PM by Andreas Weiden

    Procedure doesn't work

    Medo Hassan

      Hi

      i have a block which consists of buttons

      (query,edit,add,delete,next,previous,exit,save,cancel)

      and i create a Procedure and write this code:

       

      PROCEDURE TOOLBAR_BUTTON IS

      action varchar2(50);

      BEGIN

        if action = 'query' then

        EXECUTE_QUERY;

        elsif

        action = 'edit' then

        EDIT_FIELD;

        elsif

        action = 'add' then

        create_record;

        elsif

        action = 'delete' then

        delete_record;

        elsif

        action = 'next' then

        next_record;

        elsif

        action = 'previous' then

        previous_record;

        elsif

        action = 'exit' then

        exit_form;

        elsif

        action = 'save' then

        commit_form;

        clear_form;

        elsif

        action = 'cancel' then

        clear_form;

        end if;

       

      END;

       

      and i created WHEN-BUTTON-PRESSED  trigger on block level and wanna to calling the Procedure, so i write this

      toolbar_button;

       

      but when i run form the buttons doesn't work
      so what should i do ? is there is any thing missing or wrong in coding or what?

      i'll be grateful if any one could help me in this

      Thanks

        • 1. Re: Procedure doesn't work
          InoL

          Look at your code:


            action varchar2(50);

          BEGIN

            if action = 'query' then

            etc.

           

           

          The procedure works, it is just not doing anything. Your variable "action" has the value NULL. You are not setting a value anywhere.

          • 2. Re: Procedure doesn't work
            Medo Hassan

            sorry i'm a beginner ,
            could you show me how to do this?
            Thanks in advance

            • 3. Re: Procedure doesn't work
              Priyasagi

              No need to create procedure.

               

              On when-button-pressed trigger of each buttons just type the following commands:

               

              enter_query buttorn

              Enter_query;

              execute_query buttorn

              Execute_query;

              add buttorn

              create_record;

              delete buttorn

              delete_record;

              next buttorn

              next_record;

              previous buttorn

              previous_record;

              exit buttorn

              exit_form;

              save button

              commit_form;

              cancel button

              clear_form;

              • 4. Re: Procedure doesn't work
                Medo Hassan

                On this way i'll need to write this commands in all forms i'm gonna to create

                because this is like a toolbar and it is well be in all forms,so i created this procedure in PL/SQL libraries

                and i just call it in any form 

                • 5. Re: Procedure doesn't work
                  InoL

                  All the buttons you describe are standard in the default toolbar, or with keyboard shortcuts. So, there is no need really to program this at all.

                  If you want to make your own button bar, you need to pass the value of the action to the procedure:

                   

                  PROCEDURE TOOLBAR_BUTTON (action in varchar2 ) IS

                  BEGIN

                    if action = 'query' then

                    EXECUTE_QUERY;

                    elsif

                    action = 'edit' then

                  etc.


                  Every button calls the procedure with an ACTION. e.g.


                  TOOLBAR_BUTTON('query');



                  OR: give your buttons a logical name and do this:


                  PROCEDURE TOOLBAR_BUTTON IS

                  BEGIN

                    if lower(:system.trigger_item) = 'query' then

                    EXECUTE_QUERY;

                    elsif

                  etc.



                  • 6. Re: Procedure doesn't work
                    Medo Hassan

                    OR: give your buttons a logical name and do this:

                     

                    sorry , i don't understand this  if u can give me more details or something like example , i'll be grateful


                    by the way when i'm searching i found this Procedure and i think it's like what i wanna do

                    but unfortunately i could't understand some parts in it and i could't handle

                    it to work in my form ,i'll paste it may be it well be useful


                    -- This is a generic button procedure. It reads the NAME of the button and

                    -- performs a DO_KEY(item_name).

                    -- Regarding QUERY-operation:

                    -- if there are buttons called EXECUTE_QUERY and CANCEL_QUERY, this function shows

                    -- them, when the ENTER_QUERY button is pressed and hides them, when EXECUTE_- or

                    -- CANCEL_QUERY ispressed. No error should be returned, if these buttons do not exist.

                    -- To make naming of the buttons easier, EXIT, QUIT and EXIT_FORM all perform exit_form,

                    -- even if the form is in ENTER-QUERY mode !!!!!!!

                    -- A CANCEL_QUERY button-name cancels a currently "open" query.

                     

                     

                    PROCEDURE button_proc IS

                      action varchar(80);

                     

                     

                      -- hide a button (for ENTER_-, EXECUTE_- or CANCEL_QUERY)

                      PROCEDURE show_off(item_name VARCHAR2) IS

                      BEGIN

                        IF NOT Id_Null(Find_Item(item_name)) THEN

                          Set_Item_Property(item_name, DISPLAYED,PROPERTY_FALSE);

                        END IF;

                      END;

                     

                     

                      -- try to show a button (for the two query-states. If there is no button to show,

                      -- return FALSE to the calling procedure.

                      FUNCTION show_on(item_name VARCHAR2) RETURN BOOLEAN IS

                      BEGIN

                        IF NOT Id_Null(Find_Item(item_name)) THEN

                          Set_Item_Property(item_name,DISPLAYED,PROPERTY_TRUE);

                          Set_Item_Property(item_name,ENABLED,PROPERTY_TRUE);

                          RETURN TRUE;

                        ELSE

                          RETURN FALSE;

                        END IF;

                      END;

                     

                     

                    BEGIN   

                      action := Get_Item_Property(NAME_IN('SYSTEM.TRIGGER_ITEM'),ITEM_NAME);

                      IF action = 'ENTER_QUERY' THEN

                        -- only hide the ENTER_QUERY button, if there are EXECUTE_QUERY and (!!) CANCEL_QUERY

                        -- buttons. Otherwise an existing EXECUTE_QUERY button will be shown.

                        IF show_on('EXECUTE_QUERY') AND show_on('CANCEL_QUERY') THEN

                          show_off('ENTER_QUERY');

                        END IF;

                      END IF;

                      IF action IN ('EXIT_FORM', 'EXIT','QUIT') THEN

                      :GLOBAL.REDA_UNIT:='';

                      :GLOBAL.REDA_FILE:='';

                        --action := 'EXIT_FORM';

                        EXIT_FORM;

                        IF NAME_IN('SYSTEM.MODE')='ENTER-QUERY' THEN

                         -- Do_Key('EXIT_FORM');

                         EXIT_FORM;

                        END IF;

                      END IF;

                      IF action = 'CANCEL_QUERY' THEN

                       -- action := 'EXIT_FORM';

                       EXIT_FORM;

                      END IF;

                      Do_Key(action);

                      IF NAME_IN('SYSTEM.MODE') != 'ENTER-QUERY' THEN

                        IF show_on('ENTER_QUERY') THEN

                          show_off('EXECUTE_QUERY');

                          show_off('CANCEL_QUERY');

                        END IF;

                      END IF;

                    END;



                    • 7. Re: Procedure doesn't work
                      Andreas Weiden

                      The best way would be to put your whole "toolbar" (block, button with triggers, canvas) in an object-library and then subclass this objects into each form. Then you have the same set of triggers in all forms.