Simplicty and flexibility!


DataEase 8 - How to delete all the data in an application

Started by DataEase
You will need to Sign In to be able to comment on the Blog!

DataEase 8 - How to delete all the data in an application

We get a lot of strange requests and one we get quite regularly is how to delete all the data in an application.

There is no "button" to hit so the way forward has really been to meticolously create a big DQL with delete records in ... for each table.

Today we got this request again so we decided to help out and use some of the new functionality to automate this process. It is very easy after all ;-)

You simply need to create a DQL that look like this:


define "retval" text .

define "varTableName" text .

retval := RefreshStatus() . -- Status tables is updated when you run a status report, they are not updated automatically when you change your app. To make sure we have the latest info, we run the new function RefreshStatus() that will do it for us.

for $DeStat_TableInfo$ with TableDescription not= "System File" and TableName not="Application Objects" and TableName not="$DeARDL_Registry$" ; -- Some system tables are not marked as system tables. One can ask why, but we won't like the answer. To make sure we don't ruin the app, exclude these too from auto delete...

if varTablename not=TableName then -- Since this table contains a lot of entries for each table we make sure we only delete the table ones. Doesn't really matter if we delete it every time, but might be slower....

varTableName:=TableName .

retval := execdql(concat("delete records in ", tablename, "."),"","","","","") . -- this is the brilliance. In ExecDQL you can create any DQL and execute it on the fly. This is nothing....

end .


You can simply make a normal DQL or you can use it in ExecDQL...

The choice is yours ;-)


Written by DataEase 06/12/13 at 16:18:12 Dataease [{8}]FIVE