Script to delete ALL records
Is there any way to write a script that deletes all records in a database...?
I would do something like this:
Set Variable "LN" to Get(LayoutCount)
Set Varable "X" to 1
Go to Layout X (ie 1)
Show all records
Delete found set
exit loop if X=LN
set "X" to "X"+1
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
Rather than muck around with scripts, just save a copy of the database as a clone (no records).
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.
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.
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".
Retrieving data ...