how to copy the records from one table to another table

amt
Member Posts: 3
hai all
i am new to navision programming
i have a problem in coping the records from a perticulat field of a table to another table
for example
item1 is the table which i have created
i want to copy all the item nos from item table to item1 table's itemno field which is not a primary key.
All the records should be copied at a time.
is it possible?
i have tried in so many ways but not able to get . ](*,)
i think it is understandable,
please help me in this senario
thanks in advance
i am new to navision programming
i have a problem in coping the records from a perticulat field of a table to another table
for example
item1 is the table which i have created
i want to copy all the item nos from item table to item1 table's itemno field which is not a primary key.
All the records should be copied at a time.
is it possible?
i have tried in so many ways but not able to get . ](*,)
i think it is understandable,
please help me in this senario
thanks in advance
0
Comments
-
This is the general structure of what you need, assuming that the records don't already exist in your new target table:
Item.RESET; IF Item.FINDFIRST THEN REPEAT Item2.INIT; .. Item2."Item No." := Item."No."; .. Item2.INSERT; UNTIL Item.NEXT = 0;
Item would be a Record type variable pointing to the Item table, Item2 would be a Record type variable pointing to your new table.
Also, you say that the Item No. field in your target table is not the primary key? If so, you would need to fill in your primary key fields as well.1 -
As an alternative solution to the one proposed above you may want to try using the TRANSFERFIELDS Function. The one requirement of using this function is that field types, lengths and ID's match (as it uses the Field No property to copy fields).
IF Item.FINDSET THEN BEGIN REPEAT CLEAR(NewRecord); NewRecord.TRANSFERFIELDS(Item); NewRecord.INSERT; UNTIL Item.NEXT = 0; END;
This function can be used to copy fields between record types that are not the same (e.g. use TransferFields to copy data from a Sales Line record to a Sales Inv. Line record).
Check out the online documentation of TRANSFERFIELDS(Record) in Navision help.1 -
thank you for ur great responce
i got the solutuion0 -
As an alternative solution to the one proposed above you may want to try using the TRANSFERFIELDS Function. The one requirement of using this function is that field types, lengths and ID's match (as it uses the Field No property to copy fields).
IF Item.FINDSET THEN BEGIN REPEAT CLEAR(NewRecord); NewRecord.TRANSFERFIELDS(Item); NewRecord.INSERT; UNTIL Item.NEXT = 0; END;
This function can be used to copy fields between record types that are not the same (e.g. use TransferFields to copy data from a Sales Line record to a Sales Inv. Line record).
Check out the online documentation of TRANSFERFIELDS(Record) in Navision help.
It will not work as there will be issue with Key0 -
Caution for Primary Keys fields0
-
Guys if i have to transfer primary key data too and data already present in the table then please suggest some solution would be very thankful0
-
Guys if i have to transfer primary key data too and data already present in the table then please suggest some solution would be very thankful
Try this:
IF Item.FINDSET THEN BEGIN
REPEAT
CLEAR(NewRecord);
NewRecord.TRANSFERFIELDS(Item);
//for update
if not NewRecord.INSERT then
NewRecord.modfy;
//for insert only:
if not NewRecord.INSERT then;
UNTIL Item.NEXT = 0;
END;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