Skip to main content

Notifications

Finance | Project Operations, Human Resources, ...
Suggested answer

delete_from syntax not applied after executed

(0) ShareShare
ReportReport
Posted on by 305

Hi guys,

In one of my code, I want to delete my custom table, but somehow while in the middle of process, when I do debugging, the table has not being deleted.

I'm using this kind of syntax: 

MY_PaymentGroupTmp       recPaymGroupPayDel;

ttsbegin;
delete_from recPaymGroupPayDel;
ttscommit;

While I debug this, after passed ttscommit, then checking in SSMS, the data still there. Ain't "delete_from" will delete all the records in the specified table ?

Anything that I missed ?

Thanks,

  • Suggested answer
    André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 291,979 Super User 2025 Season 1 on at
    RE: delete_from syntax not applied after executed

    Hi Axel,

    Are you trying to apply this coding on an in-memory temporary table? The delete_from statement is to optimize performance for deleting records form a database table. Clearing the memory can be done with the next statement.

    recPaymGroupPayDel = null;

  • Suggested answer
    Mohit Rampal Profile Picture
    Mohit Rampal 12,554 Super User 2024 Season 1 on at
    RE: delete_from syntax not applied after executed

    Hi, Your code looks fine, the issue might be in method calling this one like ttsbegin and ttscommit in caller. Also, you don't need ttsBegin & ttsCommit in Delete_From. To confirm, I have tested it by creating new table and runnable class.

  • Suggested answer
    Komi Siabi Profile Picture
    Komi Siabi 12,759 Most Valuable Professional on at
    RE: delete_from syntax not applied after executed

    Hello Axel,

    You might want to add the condition where.

    MY_PaymentGroupTmp       recPaymGroupPayDel;
    
    ttsbegin;
    delete_from recPaymGroupPayDel where recPaymGroupPayDel.recid !=0;
    ttscommit;

  • Suggested answer
    DAnny3211 Profile Picture
    DAnny3211 9,274 Super User 2024 Season 1 on at
    RE: delete_from syntax not applied after executed

    hi

    Yes, the delete_from statement should delete all the records from the specified table. However, the delete_from statement does not actually delete the records until a ttscommit statement is executed, which means that the deletion is not permanent until the transaction is committed.

    So, if you have executed delete_from and then ttscommit, the records should be deleted permanently from the table. If you are still seeing the records in SSMS after executing delete_from and ttscommit, then there may be other factors at play, such as a delay in the data being reflected in SSMS or an issue with the code. You may want to double-check that the correct table name is being used and that there are no errors in the code that could be preventing the deletion from occurring.

    DAniele

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,979 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,848 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans