4 Replies Latest reply on Jan 17, 2013 7:30 AM by jm47

    Scripting a purge with TimeStamp

    jm47

      I created an external table which records the various states of a place in concert (IE: free, reserved, blocked).

      For the same place I can thus have a history with timestamp evolution of this state.

      My need is to preserve only the last (timestamp) state.

      Who can give me an idea of ideal script to preserve only the last state? (Delete old states)

        • 1. Re: Scripting a purge with TimeStamp
          comment

          Here's one way - not necessarily the most efficient one, but easy to follow:

           

          Go to Layout [ Places ]

          Show All Records

          Go to Record [ First ]

          Loop

          If [ not IsEmpty ( States::PlaceID ) ]

              Go to Related Record [ States; Show related only ]

              # SORT BY TIMESTAMP, DESCENDING

              Sort Records [ Restore ]

              Go to Record [ First ]

              Omit Record

              Delete All Records

              Go to Layout [ Places ]

          End If

          Go to Record [ Next; Exit after last ]

          End Loop

           

           

          ---

          This is assuming the States table contains multiple states of multiple places - and that you also have a parent Places table. Make sure you have a backup before trying it.

           

           

          Message was edited by: Michael Horak

          • 2. Re: Scripting a purge with TimeStamp
            jm47

            I thank you a lot.

            But this is one step in my purpose : I have almost 400 places in my records. So I think this whole script must be only one step in a global script for all the paces.

            So, you've given me a fair idea and I will work with that.

            • 3. Re: Scripting a purge with TimeStamp
              comment

              jm47 wrote:


              I have almost 400 places in my records. So I think this whole script must be only one step in a global script for all the paces.

               

              No, this should take care of all the places. That's why it loops.

              • 4. Re: Scripting a purge with TimeStamp
                jm47

                Oops !

                Sorry, I hav'nt well read your post. This is quite GREAT ! I do thank you a lot. You gave me the right way to do what I wanted to do.