easy RecordRef Insert problem

mnewmedia
Member Posts: 13
Hello togheter,
I have two tables 50000 and 50001 both has the fields "Name" and "Description".
I wanna Copy all records from the the first table to the second, but it works only with the Field "Name". somebody knows why?
Any Ideas, Tipps?
Thanks
I have two tables 50000 and 50001 both has the fields "Name" and "Description".
I wanna Copy all records from the the first table to the second, but it works only with the Field "Name". somebody knows why?
RecordRef1.OPEN(50000); RecordRef1.FINDFIRST; RecordRef2.OPEN(50001); RecordRef2.INIT; IF RecordRef1.FIND('-') THEN REPEAT field1 := RecordRef1.FIELD(2); // works only with 1 field2 := RecordRef2.FIELD(2); // works only with 1 field2.VALUE := field1.VALUE; RecordRef2.INSERT; UNTIL RecordRef1.NEXT = 0;I get the Error (translated by me to english) "'table2' exists already. Identified Fields and Values: Name="
Any Ideas, Tipps?
Thanks
mnewmedia
NAV 2009 R2
NAV 2013 R2
NAV 2009 R2
NAV 2013 R2
0
Comments
-
Why not use Transferfields function......
.....................0 -
Because later i need to use RecordRef variable and TRANSFERFIELDS only works with a normal Record Variable...mnewmedia
NAV 2009 R2
NAV 2013 R20 -
The problem is you are not copying all fields across but just one field. This works for your Name field as this must be your primary key and doesn't work for the Description field because in that instance you are not setting the primary key field in the record being inserted so it is always blank. Put a loop in there to copy BOTH fields and it will work.0
-
Put a loop in there to copy BOTH fields and it will work
Or do you mean i have to do it like that:IF RecordRef1.FIND('-') THEN REPEAT field1 := RecordRef1.FIELD(1); field2 := RecordRef2.FIELD(1); field2.VALUE := field1.VALUE; field1 := RecordRef1.FIELD(2); field2 := RecordRef2.FIELD(2); field2.VALUE := field1.VALUE; RecordRef2.INSERT; UNTIL RecordRef1.NEXT = 0;
And what if let's say i already copied Field 1 (Name) and wanna later copy only the Field 2 (Description)? Do i have to change the Primary Key, or is there an other way?mnewmedia
NAV 2009 R2
NAV 2013 R20
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