Let's see if I can explain this clearly...
There is a production order posting routine in codeunit 5407 (the exact code is not significant) that worked under C/Side but does not work after conversion to SQL. Investigation revealed that the problem is the inherent difference in sorting between the Navision 'code' datatype and and the SQL 'varchar' datatype.
The field in question is 'Operation No.' in the table 5409 Prod. Order Routing Line. In C/Side this field is type 'code'. The values that the client uses in that field are all numeric (90, 100, 560, etc.). The posting routine sets the key (which doesn't include the 'Operation No.' field) descending (ascending,false), and filters on a single production order. The records at that point are sorted numerically on Operation No. , since a C/Side 'code' field will sort numeric values numerically. The code needs to find the last Operation No., which it does, since the sort is descending, with a Find('-'). In C/Side this works fine because the dataset is sorted numerically descending by Operation No. (600,200,150,100,90,50,10).
In SQL, the 'Operation No.' field is type 'varchar,' which always sorts alphabetically. So when it gets to the Find('-') the records are not in order (90,600,50,200,150,100,10), it grabs the wrong record, and the procedure fails a few lines later.
The code in both versions is absolutey identical.
So the really puzzling thing is that the code is obviously expecting the Operation No. to be sorted numerically in the code field, so it is bound to fail, always, after conversion to SQL which forces the Operation No. to be sorted alphabetically.
Is this a widespread problem? We have never seen or heard of it before now, but changing all 'code' fields to 'varchars' seems like a very major conversion issue, with innumerable possible consequences.
Is there anything to be done??? Are there SQL settings we aren't aware of?
Thanks,
Chandler
0
Comments
If you are sure that this customer only uses numeric values, you can set the "SQL Data Type" property to Integer, and it will sort accordingly. If your customer is using numeric as well as alpha, then you'll have to rename the records with equal length code field values, forcing the correct order that way, so you'd have 001, 010, 100, etc.
RIS Plus, LLC
RIS Plus, LLC
WIll these other tables need to be changed?
RIS Plus, LLC
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
However I am now on a customer site where they have gone to SQL 2005 and this issue is a big one for them because all their items have K* or J* as structure but they have other items from 1..1000 for representing "Delivery costs" and things like this.
This is also something I always avoid, I always try and make sure people do NOT EVER use the item table to represent things that are not items.
My question now is... since this company have already done this, and since a HUGE amount of their code is bases upon the filter:
SETFILTER("No.", '>1000');
what can i do now? How would you recommend rewriting the above filter so all items from 1..1000 get ignored by their code?
The database is HUGE so I want to avoid having to work out every table where the item no. has been stored and renaming it in every place.
RIS Plus, LLC
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Also if you go to change back to the original datatype of varchar you may not get the original primary key back. For example we change the Customer Table No. field to be an integer. We realized it was a mistake and change it back. Customer's that had numbers like 000001 or 000002 originally were now permanently changed to 1 and 2. The really annoying thing is that the change is only in the customer table and not in any other table. So the customer table has a primary key of 1 but all other tables (Cust Ledger, Detailed Cust. Ledger etc...) still have 000001.
I'm sure there are fixes for these problems but just be aware and be careful. One final thought is that Temporary tables still sort the C/SIDE way. If you absolutely need to sort in code the "old way" you could use a temporary table if it is feasible.
jwilder@stonewallkitchen.com
RIS Plus, LLC
Normally I use SQL Collation that is accent and case insensitive (i.e. code page 54). I suggest this because it seems to offer the closest kind of sorting to how standard Navision works in the Nataive database server.
However when you create a Navision database by default it wants to use Windows Collation - which of course exhibits the exact problems that you have described here.
Epimatic Corp.
http://www.epimatic.com
When making any of these big changes to Navision you will probably want to set the recovery model to simple so that the transaction logs do not grow huge, and then put them back to full once you have a database that is good to go.
Epimatic Corp.
http://www.epimatic.com