How To Clear Junk Data In Entity During Developement

How To Clear Junk Data In Entity During Developement

  

Hi,

During development, i have a lot of junk data created while testing.

This is my first time to clear the junk data in OutSytems.

May i know how you guys do that?

1.Clear though SQL Management Studio?

2.Purposely create a button, writes the SQL in to clear the data?

Can someone advise?


Solution

Hi Johnson,

Typically, the junk data lives on our development environment, not the production environment, so not really a problem there. There's a number of things you could do, like indeed using SQL Management Studio (MSSQL) or Toad (Oracle), but a simple SQL node with a DELETE FROM {MyTable} that you "Test" may also work (I'm not 100% sure the Platform doesn't do a rollback, otherwise a simple Timer will do as well). The only downside to deleting is that Auto-numbers don't get reset. A third option could be a Ctrl-X/Ctrl-V of the Entitie(s), but the downside to that is that the data doesn't get purged, but keeps residing in the database.

Alternatively, if the database size is not the biggest concern, you could have an IsActive flag in each table (or at least the main table) that you could reset, which in general is a good idea to have to avoid "hard" deletes, and update the flag for all records.

So there's basically all kinds of possibilities, depending on your data and the structure of the database.


Solution

Thanks Kilian

You're welcome Johnson. Happy coding!

Hi,

Just to add to Killian's answer, about using an SQL node and "test" it.
Yes, the platform will do a roll back, so nothing will be deleted.
In order to make the deletion permanent, you need to do a "commit".

Ex.:

DELETE FROM {Table1};
DELETE FROM {Table2}; /* that has FK to Table1 */
DELETE FROM {Table3}; /* that has FK to Table1 and Table2 */
COMMIT;

After testing, you will see an error about NULL, but the delete will be effectively done.

Cheers,
Eduardo Jauch


Thanks for the useful addition Eduardo!