Changing Datatype of a field in a table which has 100 of Rec
tgupta
Member Posts: 86
Hi All,
I added a field on the Item table which was of integer type and this field does not have any sort of table relation or any sort of triggers on it .
but after few days when few records were inserted up on the live database client changed his mind and wanted that field to be of decimal type.Now what is the best solution for it do ??
Many Thanks,
Tarun
I added a field on the Item table which was of integer type and this field does not have any sort of table relation or any sort of triggers on it .
but after few days when few records were inserted up on the live database client changed his mind and wanted that field to be of decimal type.Now what is the best solution for it do ??
Many Thanks,
Tarun
0
Comments
-
Hi Tarun!
I always such an operation do in that way:
1. Add a new Integer field. This field is empty (zero values) for all records.
2. Create a new report with the only DataItem set to table 27 (Item)
3. In this report section OnAfterGetRecord should be like this:
<new_added_integer_field> := <old_integer_field>;
<old_integer_field> := 0;
modify;
where:
<new_added_integer_field> - is a field you have just added
<old_integer_field> - is a field you want to swich from integer to decimal.
After this operation an old field has zero values for all records but you did not loose these values because they are copied into new field.
4. Now you can change type of field from integer to decimal.
5. In just created report change OnAfterGetRecord trigger:
<old_integer_field> := <new_added_integer_field>;
<new_added_integer_field> := 0;
modify;
Of course <old_integer_field> is Decimal, now.
6. Delete <new_added_integer_field> field from table
7. Delete the report.
And that is all.
Best Regards
Marcin Woch
_____________________
"ANTEI" Woch Marcin
email: marcinwoch@wp.pl
tel.: (+48608) 39 46 29
Poland0 -
Hi Wochm,
Thanks a lot . You are 100 percent correct .I should have thought about that . =D>
Many Thanks,
Tarun0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 610 NAV Courses, Exams & Certification
- 1.9K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 251 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions