Table already exist Identification fields and values.. even though the record is unique

kaelumchai
Member Posts: 7
Hi,
I having an error when running this script:
The Primary Keys of TransSales and TransSalesTransform is: Store No.,POS Terminal No.,Transaction No.,Line No.
It runs properly until a certain record saying that it is already exist when inserting even though it is not. I'm not sure if it has to do with the primary keys or my setrange or what. Thank you in advance!
I having an error when running this script:
TransSales.DELETEALL; TransSalesTransform.RESET; TransSalesTransform.SETCURRENTKEY("Store No.","POS Terminal No.","Transaction No.","Line No."); TransSalesTransform.SETRANGE("Trans. Date",CALCDATE('-1D',RunDate),RunDate); TransSalesTransform.SETRANGE("Store No.",Store."No."); IF TransSalesTransform.FINDSET THEN BEGIN REPEAT TransSales."Store No." := TransSalesTransform."Store No."; TransSales."POS Terminal No." := TransSalesTransform."POS Terminal No."; TransSales."Transaction No." := TransSalesTransform."Transaction No."; TransSales."Line No." := TransSalesTransform."Line No."; TransSales."Active Location Code" := Store."Location Code"; TransSales."Trans. Date" := TransSalesTransform."Trans. Date"; TransSales."Item No." := TransSalesTransform."Item No."; TransSales.Description := Item.Description; TransSales.Quantity := TransSalesTransform.Quantity; TransSales."Trans. Time" := TransSalesTransform."Trans. Time"; TransSales.INSERT; UNTIL TransSalesTransform.NEXT = 0; END;
The Primary Keys of TransSales and TransSalesTransform is: Store No.,POS Terminal No.,Transaction No.,Line No.
It runs properly until a certain record saying that it is already exist when inserting even though it is not. I'm not sure if it has to do with the primary keys or my setrange or what. Thank you in advance!
0
Answers
-
What is the primary key for TransSales?Kyle Hardin - ArcherPoint0
-
Hi Kylehardin,
Sorry. Same with the TransSalesTransform, the primary key of TransSales is:
Store No.,POS Terminal No.,Transaction No.,Line No.0 -
Paste the actual error message you are getting.Kyle Hardin - ArcherPoint0
-
Here is the error:
However upon checking it on the sql, the TransSalesTransform has a no duplicate record.
0 -
Error message says that duplicate record is in entry table. Same record probably has been posted before. Check this in entry table.0
-
Yes. but the record on the TransSales are being deleted before inserting.
So I'm not sure if the FINDSET looking that record twice or something?0 -
Do you have any filters set on TransSales before you do DELETEALL?Kyle Hardin - ArcherPoint0
-
kylehardin wrote: »Do you have any filters set on TransSales before you do DELETEALL?
None. Inside the function, it will delete all data in TransSalesTransform before anything else.0 -
Put either MESSAGE(TransSales.GETFILTERS) or TransSales.RESET before the DELETEALL, just to make sure.Kyle Hardin - ArcherPoint0
-
Hi,
This is now ok. What I did is, I delete the TransSales Table and I save as the TransSalesTransform (which is existing or the source) and named as new table (the TransSales) then remove the unnecessary fields and add the "Active Location Code" which is not present on the source. The codes are still the same.
I don't know how it happen, though.
Anyway, Thank you for your feedback! it is highly appreciated.0
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