835
Views
8
Comments
Solved
Delete records from database

Hi, this is Sateesh,

Let me know one thing: a better way to delete the records from the database. either like entity delete action or write SQL query. and also give me one example of writing an SQL query to delete data from the database that should be joins.

2022-07-12 16-41-57
Pedro Costa
Solution

Hi Sateesh,

You have choose to use the logic exclusion, using the Is_Active (boolean) attribute to control the exclusion, or physical exclusion.

The good side of logic exclusion is to keep data history for later consultation or auditing when necessary.

For physical exclusion, you have two options: 

CRUD actions, that you can use Delete action to delete 1 record using the Entity Identifier.

Use Advanced Query (SQL Query) to execute a bulk delete. See an example:

Delete from {MyEntity} where {MyEntity}.[MyDate]< @LimitDate


"Massive deletes are faster in SQL queries than using Entity Actions"

So, answering your question, when you need to perform massive update or delete operations, Bulk Operations will be the best approach

Regards,

Pedro Costa

UserImage.jpg
TELUGU SATEESH

let me know how to write an SQL query to delete join records from the database. could please give me one example.

thanks,

sateesh.

2022-07-12 16-41-57
Pedro Costa

Just do as it is in the link that Pedro Marques mentioned.

But, follow image representing in Advanced Query.



UserImage.jpg
TELUGU SATEESH
2024-11-20 08-28-20
Pedro Marques

Hi Telugu,

To delete several records at once is always better to perform a bulk operation using a SQL query (more here https://success.outsystems.com/Documentation/Best_Practices/Performance_and_Monitoring/Performance_Best_Practices_-_Queries)


For an example of a Delete statement with joins you can check this link https://stackoverflow.com/questions/16481379/how-can-i-delete-using-inner-join-with-sql-server


Hope this helps,

Pedro

UserImage.jpg
TELUGU SATEESH

thanks, Pedro.

2022-07-12 16-41-57
Pedro Costa
Solution

Hi Sateesh,

You have choose to use the logic exclusion, using the Is_Active (boolean) attribute to control the exclusion, or physical exclusion.

The good side of logic exclusion is to keep data history for later consultation or auditing when necessary.

For physical exclusion, you have two options: 

CRUD actions, that you can use Delete action to delete 1 record using the Entity Identifier.

Use Advanced Query (SQL Query) to execute a bulk delete. See an example:

Delete from {MyEntity} where {MyEntity}.[MyDate]< @LimitDate


"Massive deletes are faster in SQL queries than using Entity Actions"

So, answering your question, when you need to perform massive update or delete operations, Bulk Operations will be the best approach

Regards,

Pedro Costa

UserImage.jpg
TELUGU SATEESH

let me know how to write an SQL query to delete join records from the database. could please give me one example.

thanks,

sateesh.

2022-07-12 16-41-57
Pedro Costa

Just do as it is in the link that Pedro Marques mentioned.

But, follow image representing in Advanced Query.



UserImage.jpg
TELUGU SATEESH
2022-02-08 09-40-14
Chandrashekhar Mankar

Helpful post, Thank you.

UserImage.jpg
Sunil Kumar

Hi Pedro Costa, I am trying to delete using an IN clause on EmployeeId and it fails if there are more than two ids in a IN clause. It works fine if there is a single value.

Can help on this pls


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.