Creating a function to copy data between 2 tables

rstols
Member Posts: 28
I am new to development in Nav and need some help with developing the following function:
A new table was created which contains a few similar fields as an 'obsolete' table. I need to copy the data from the old table to the new table for all matching records for certain common fields. After it copied the data from the 'obsolete' table, it can delete those records in the 'obsolete' table.
Both tables contain 2 fields (store # and invoice #) which should be unique in both tables.
Any suggestions or ideas please?
Thanks
Rudy
A new table was created which contains a few similar fields as an 'obsolete' table. I need to copy the data from the old table to the new table for all matching records for certain common fields. After it copied the data from the 'obsolete' table, it can delete those records in the 'obsolete' table.
Both tables contain 2 fields (store # and invoice #) which should be unique in both tables.
Any suggestions or ideas please?
Thanks
Rudy
0
Comments
-
in C/AL (Navision) or in SQL (because u post this in the SQL General forum)?
If NAV and both tables has the same structure (same fields with the same datatype) u can use the function "transferfields();"
A NAV code can look like this:OldRec.reset; if OldRec.findset() then begin repeat NewRec.init; NewRec.transferfields(OldRec); NewRec.insert; until OldRec.next = 0; end;
in SQL it is a simple insert into (fields) NewTable select(fields) from OldTableDo you make it right, it works too!0 -
The 2 tables don't have the same structure - only the common fields which needs to be transferred have the same datatype. Do you have any suggestions how to make that work?
The other issue... is it also not required to first combine the 2 fields (store# + invoice#) in both tables temporarily in order to know which records need to be updated in the new table.
Thanks for the help.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