IF recGLEntry.FINDSET THEN REPEAT recTempGLEntry := recGLEntry; recTempGLEntry.INSERT(FALSE); UNTIL recGLEntry.NEXT = 0; recTempGLEntry.RESET; MESSAGE('TMP 1: Count %1',recTempGLEntry.COUNT);//TMP 1: Count 18302 recTempGLEntry.SETFILTER("G/L Account No.",'106999..108998'); MESSAGE('TMP 2: Count %1',recTempGLEntry.COUNT);//TMP 2: Count 0 recGLEntry.RESET; MESSAGE('DB 1: Count %1',recGLEntry.COUNT);//DB 1: Count 18302 recGLEntry.SETFILTER("G/L Account No.",'106999..108998'); MESSAGE('DB 2: Count %1',recGLEntry.COUNT);//DB 2: Count 43
Comments
Did you also try with
-Mohana
http://mohana-dynamicsnav.blogspot.in/
https://www.facebook.com/MohanaDynamicsNav
edit -- sorry bad info count will do the work of find --- edit
Steve
The comment about using SETRANGE vs SETFILTER is correct for performance, but would make no difference in the results.
Also a FIND statement is not required for the COUNT to work.
KCP Consultores
When you use a Temporary table the sorting and filtering is done on the client using the same logic as in Native database, where the DB table will be sorted in SQL fashion. I am guessing from your location that maybe you ran this code on a Swedish database, and if I remember correctly Sweden uses Text for the GL account no. so that you can conform to Swedish accounting requirements for sub accounts.
So if you have accounts like
12
121
12100
12123
123
12388
13
139
etc they will sort differently and thus filter differently and give you a different count.
12
13
121
123
139
12100
12123
12388
I think the best advise in this thread is that from Reinhard, follow his suggestion and you should be able to solve this.
This type of action is true whether it is Text or Code and is because of SQL. In the example provided by the OP, it does not appear that the G/L Account Nos. vary in length. Also whatever sorting issues there are will be the same whether it is a temporary variable or not. It has to be something else.
KCP Consultores
Gerry, if sorting does not affect filtering, what could be reasons for this behouvior? Account numbers are different length.
Is there a way to make sorting similiar on client side temporary table as it is on SQL? All accounts are numerical values on Code Data Type (20) field.
As far as I see it this is a bug, and one that needs to be fixed. At least before the release of Nav7.
in Fin.exe this sorting is correct and logical, but in FinSQL.exe, when sorting and filtering on a Temporary table, Navision should look at the SQLDataType field and the collation of the database and apply sorting according to this property.
:thumbsup:
As David said, temporary record works as native and this may change the sorting order. One workaround solution is copying the No. field value to Name field when you create temporary record and filter it using Name field. This way the sorting logic can change.
Pargesoft
You can fix the sorting so SQL acts like native if all the G/L Account Nos. are integers (no alpha characters). You can change the SQL Data Type to integer then it will sort as you would expect.
KCP Consultores