Delete All Records - Temporary Table

leikelman
Member Posts: 31
I am using a temporary table in one of my reports. The temporary table is pointing to a new table that we created, that has no custom table level CAL code.
At a point in my report I need to clear all the values from my table but I can't seem to get this to work. I've tried the following:
1. Calling the DELETEALL method
2. Looping through each record and calling the DELETE function
Is the problem that I am using a custom table we created or is there some other way of deleting record from a temp. table I am not familiar with?
Thank you,
Leo
At a point in my report I need to clear all the values from my table but I can't seem to get this to work. I've tried the following:
1. Calling the DELETEALL method
2. Looping through each record and calling the DELETE function
Is the problem that I am using a custom table we created or is there some other way of deleting record from a temp. table I am not familiar with?
Thank you,
Leo
0
Comments
-
Hi Leo,
TempRec.DELETEALL;
should work.
Can you post your code?0 -
This is a portion of my code:
TEMP_DTLotQuantities.DELETEALL;
DTLotQuantitiesCnt := 1;
DTQuantityRemaining := Quantity;
ItemLedgerEntry.INIT;
ItemLedgerEntry.SETRANGE("Item No.",ItemNo);
ItemLedgerEntry.SETRANGE("Item Tracking",ItemLedgerEntry."Item Tracking"::"Lot No.");
ItemLedgerEntry.SETFILTER("Lot No.",'<>%1','');
ItemLedgerEntry.SETFILTER("Remaining Quantity",'>0');
IF ItemLedgerEntry.FIND('-') THEN REPEAT
TEMP_DTLotQuantities.SETRANGE(RefERPNo,ItemLedgerEntry."Lot No.");
IF TEMP_DTLotQuantities.FIND('-') THEN
BEGIN
TEMP_DTLotQuantities.DTID := TEMP_DTLotQuantities.DTID + ItemLedgerEntry."Remaining Quantity";
TEMP_DTLotQuantities.MODIFY;
END
ELSE
BEGIN
TEMP_DTLotQuantities.ID := DTLotQuantitiesCnt;
TEMP_DTLotQuantities.RefERPNo := ItemLedgerEntry."Lot No.";
TEMP_DTLotQuantities.DTID := ItemLedgerEntry."Remaining Quantity";
TEMP_DTLotQuantities.INSERT;
DTLotQuantitiesCnt := DTLotQuantitiesCnt + 1;
END;
UNTIL ItemLedgerEntry.NEXT = 0;
This is being called inside of a function that is called multiple times in the report, which is why I need to delete all records in the temporary table (TEMP_DTLotQuantities) every time. I get an error "ID '1' Already exists" when calling this function multiple times.
Thanks.0 -
Hi Leo,
On the face of it the code looks fine. What's the key of the temp table?
Have you used the debugger to see where the error occurs?0 -
Use the TEMP_DTLotQuantities.RESET before deleteall, else you can have some filters from previous run etc. if the variable is global...1
-
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions