how can i delete all data in entity?

hello

how can i delete all data in entity?

Thanks

Rashed this link will help you with the problem you are having regarding, eliminating data from an entity!


https://success.outsystems.com/Documentation/How-to_Guides/Data/How_to_delete_data_from_Entities


Cheers 

I tried the process and apparently you will have to commit the operation, in the interface, you will get an error like "There was an error processing your request.", but when you check the entity all data was erased


Hi Rashed,


Depending on the version you are working on, you can try Rui Bernardes version or:

Delete from {Entity}
exec ('com' + 'mit')


Regards!

Still another possibility, if you have access to the database, you can drop the like table:


DROP TABLE table_name;


After that re-publish, the eSpace where the table is located and when publishing the system will create a new table with the id's starting again at one.

@diana Is there a way to not show this error in the end? Even though the process works?

Hi Rui!


Since you are doing this action at runtime, you shouldn't have any errors, we only get the error when we do it directly in the service studio. Are you sure the action worked? What's in the service center?


Regards

Hello Rui and Diana.

Supposedly, that trick was disabled a few months ago. You can no longer delete from Service Studio.


The way to do it is by publishing the module and calling the delete action as I explained here

https://www.outsystems.com/forums/discussion/60581/need-to-delete-rows-in-osusr-2ry-addresses/


There's no need to use commit, you just need this expression! And the screen won't popup any error.

You have two options, and both go through what has already been written here, using the query Delete From TableToDelete.

Then here you have two solutions, or put the function on a timer, and schedule the timer for when to publish, or do not put any type of scheduling and go to the correlated service center manually, or lastly make the committee as shown here exec ( 'com' + 'mit') but this depends on your platform version.

See this post to more info.


Regards,

Miguel

Another way of executing all kinds of SQL statements on the Platform Database is by using SQL Sandbox tool available on the Forge.

It’s my favorite and one of my most used tools out there!

Regards,

Nordin

Hello Rashed,


There are a lot of possibilities to delete the data present in an entity. When you deploy your modules, entities will be created and stored in a database server (each entity corresponds to a table in the database).

So (like Diana said), if you have access to this database server, you can use a framework (for example SQL Server Management Studio) to execute queries and delete / drop the corresponding physical table of the entity that you want.

Since it seems that you are using the OutSystems personal environment (according to your image), you don't have access to the database server, so you have to do it programmatically.


There are several ways to do this. My first suggestion is to create a button in a screen (like a backoffice screen), which calls a Server Action where you execute the SQL statement that you want. You can see an example here (already shared by Rui Fernandes): https://success.outsystems.com/Documentation/How-to_Guides/Data/How_to_delete_data_from_Entities

However, when you click in the button, this will run the server action synchronously. This means that the end-user needs to wait for the execution to end. If your entity (or entities) has a large amount of data, this can lead to a timeout error when you click the button. In this case (if you are working with a large amount of data), you can create a timer to execute the Server Action asynchronously. You can see an example here how to create a timer: https://success.outsystems.com/Documentation/11/Developing_an_Application/Use_Timers/Create_and_Run_Timers

You just need to create the timer, associate it to the Server Action that deletes the data and execute it (via Service Studio or Service Center).


But it doesn't seem to be the case (according to the number of the IDs in the table). So, just stick with the button solution and you will be good.


Kind regards,

Rui Barradas

Asslamu Alaikum Brother,


I hope you got your  answer as already few of them posted here. There is another option like

1.Create Server Action 

2.Add Sql Block

3. write  delete from {Entity};

4.call this server action by using any button or use timer.