alguidelines/content/docs/BestPractices/DeleteAll/index.md
Henrik Helgesen fb17dc9640 Removed Discussion Links. Using new Theme solution.
Some additional MDLint cleanup as well
2022-02-24 15:36:06 -08:00

667 B

title tags categories
DeleteAll
AL
Performance
Best Practice

Created by waldo, Described by waldo

Description

When you perform a "DeleteAll" when there is nothing to delete, it will still perform a lock. When you for example perform a DeleteAll on an empty table, it will result in a table lock. Therefore it's good practice to always check if the table is empty when performing a DeleteAll.

Bad code

    EmptyTableWLD.SetRange(Code, 'AJ');
    EmptyTableWLD.DeleteAll(true);

Good code

    EmptyTableWLD.SetRange(Code, 'AJ');
    if not EmptyTableWLD.IsEmpty() then
        EmptyTableWLD.DeleteAll(true);