Skip to main content

Notifications

Announcements

No record found.

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

How to Clear a Temp Table

Posted on by 32

I'm trying to use a temp table as the data source for a report.  My challenge is that the table records are not clearing which is causing the number of labels that we end up printing to increase with every report run.

I've tried clear, delete and remove at the end of the below range phrase, but nothing is working.  The temp table has one index with 4 columns as shown below.  I've tried single table commands as well.  My goal with the below snippet is to end up with either an empty or missing TAS_Packing_Labels_TEMP.

range clear table TAS_Packing_Labels_TEMP;
clear field 'SOP Number' of table TAS_Packing_Labels_TEMP;
clear field 'SOP Type' of table TAS_Packing_Labels_TEMP;
clear field 'Component Sequence' of table TAS_Packing_Labels_TEMP;
clear field 'Line Item Sequence' of table TAS_Packing_Labels_TEMP;
range start table TAS_Packing_Labels_TEMP;
fill field 'SOP Number' of table TAS_Packing_Labels_TEMP;
fill field 'SOP Type' of table TAS_Packing_Labels_TEMP;
fill field 'Component Sequence' of table TAS_Packing_Labels_TEMP;
fill field 'Line Item Sequence' of table TAS_Packing_Labels_TEMP;
range end table TAS_Packing_Labels_TEMP;
clear table TAS_Packing_Labels_TEMP;

What am I doing wrong?

Categories:
  • Suggested answer
    David Musgrave MVP GPUG All Star Legend Moderator Profile Picture
    David Musgrave MVP ... 13,917 Most Valuable Professional on at
    RE: How to Clear a Temp Table

    I would do 

    clear range table TAS_Packing_Labels_TEMP;

    remove range table TAS_Packing_Labels_TEMP;

    This will ensure there is no range (ranged to entire table) before removing the records.

    FYI.

    Rather than clearing and filling field by field when setting ranges, use clear table and fill table. It is simpler and future proof. If you ever add extra segments to the key, the code will still work without needing to be updated.

    See this article

    https://winthropdc.wordpress.com/2018/02/21/dexterity-future-proof-range-setting/

    Regards 

    David 

  • Almas Mahfooz Profile Picture
    Almas Mahfooz 11,003 User Group Leader on at
    RE: How to Clear a Temp Table

    The clear keyword clears any range set for the records, but doesn’t affect the table buffer. So you are missing remove command at the end of this 

    remove range table TAS_Packing_Labels_TEMP;

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans