5 Replies Latest reply on Sep 28, 2010 9:25 AM by philmodjunk

    Script to delete ALL records

    Mitch

      Title

      Script to delete ALL records

      Post

      Hi,

      Is there any way to write a script that deletes all records in a database...?

        • 1. Re: Script to delete ALL records
          MSpsi

          Yes,

          I would do something like this:

          Set Variable "LN" to Get(LayoutCount)

          Set Varable "X" to 1

          Loop

          Go to Layout X (ie 1)

          Show all records

          Delete found set

          exit loop if X=LN

          set "X" to "X"+1

          end Loop

          Syntax is wrong but the idea should work.  Have not had time to test it - but it should work.  Just go to layout by number is available in the script step but I do not know the name of this step from the top of my head

          Good luck

          • 2. Re: Script to delete ALL records
            sunmoonstar.13

            Rather than muck around with scripts, just save a copy of the database as a clone (no records).

             

            Nick

             

            • 3. Re: Script to delete ALL records
              philmodjunk

              For a hosted file, Save a Copy as with the clone option may or may not be the best option. In which case, MSpi's suggested solution has it's uses--though you may not have to loop through every layout--it depends on the design of your database.

              A key question not asked yet:  Why do you need to do this? Deleting all records is a very drastic step and sometimes there is a better approach.

              • 4. Re: Script to delete ALL records
                Mitch

                I am just lazy and want a script to execute all the commands in need prior to building a runtime.... this would include 'deleting all records' and 're-setting custom serial numbers' back to zero... to name a few.

                • 5. Re: Script to delete ALL records
                  philmodjunk

                  Then save a copy as with the clone option will get you the empty copy of your data base which you can then bind to your runtime engine. You can use a script with a Set Next Serial Value step for each serial number field to reset them to specified starting values, but this isn't truly necessary if you are using these fields as "meaningless primary keys". You can just leave the serial number fields next serial value settings "as is".