6 Replies Latest reply on Nov 14, 2017 12:47 PM by Schuriik

    Timer with "Pause" function

    Schuriik

      Hello APEX-Community,

       

      I have 3 Items: Start (Date), End (Date) and Total (Number).

      When I click the Start-Button, i save the current timestamp in the start-item. When I click Stop, i save the current timestamp in the end-item and calculate the total time.

      Unbenannt.png

      Now to my problem: After I saved a total time, I want to click start and stop again and save the totaled up time with adding the last saved number to it. At the moment I just overwrite the old total time.

      How would you guys solve this problem?

       

      Greetings

       

      Alex

        • 1. Re: Timer with "Pause" function
          Tim Halbach

          Hi schuriik,

           

          how Looks your table where do you save the value?

           

          uses This function more than one person at the same time?

           

          this informations are helpful so I don’t want to tell you the wrong thing.

           

          best regard

          Tim

          • 2. Re: Timer with "Pause" function
            Schuriik

            Hi Tim,

             

            at the moment Im just saving the total time as a number in my table when I click on stop. I save the timestamps for start and end just in my items via dynamic actions where I just say "select sysdate from dual".

            Unbenannt.png

            In theory I just need to have a second item (placeholder in my example) which stores the old total time and say new total time = old total time + new total time. In the total item i use a dynamic action with set value and PL/SQL-Expression ":P201_PLACEHOLDER + :P201_TOTAL". Unfortunately it doesnt work.

            • 3. Re: Timer with "Pause" function
              Tim Halbach

              Hi Schuriik,

               

              P201_PLACEHOLDER  is your item to keep the value of the current time difference?

              P201_TOTAL is your item where the sum of all should come out?

               

              If this is so, you can create a Dynamic Action (on Change) on P201_PLACEHOLDER with a set value and execute an Execute PL/SQL in the TRUE branch.

              this ccodes works:

               

              if :201_total is not null

              then

                :201_total := :201_total + :p201_placeholder;

              else

                :201_total := :p201_placeholder;

              end if;

               

              You can set your place holder on hidden.

              if you do that i would made a button thats clear session state.

              so you can reset the timmer again and again.

               

              Best thing is you made an example on https://apex.oracle.com/en/

               

              regards Tim

              1 person found this helpful
              • 4. Re: Timer with "Pause" function
                Schuriik

                Hi Tim,

                 

                I forgot to check for null, thats why my code wasnt work. Your suggested Code is working! Thank you alot.

                 

                if you do that i would made a button thats clear session state.

                so you can reset the timmer again and again.

                Could you please explain how to clear session state with a button? When I refresh the page the total item still has a value.

                 

                 

                Greetings

                Alex

                • 5. Re: Timer with "Pause" function
                  Tim Halbach

                  Hi Schuriik,

                   

                  make a button.

                  define a dynamic action onklick

                  in true branch make a clear action thaths clear Placeholder item.

                  a 2nd true action (Execute PL/SQL code) in PL/SQL Code enter null; and by items to submit set Placeholder.

                  with that you have a simple clear of this item only on click the button

                   

                  best regard tim

                  1 person found this helpful
                  • 6. Re: Timer with "Pause" function
                    Schuriik

                    You are the best Tim! Its all working now. Thank you!