Search the table Descending order
vios15
Member Posts: 43
Dear All,
I am working on a coding to read a table but I need it to be in a descending order.
Reason being, I want the latest record to be read first.
Has anyone know how I should put in the coding in order to read descending?
Thanks
I am working on a coding to read a table but I need it to be in a descending order.
Reason being, I want the latest record to be read first.
Has anyone know how I should put in the coding in order to read descending?
Thanks
0
Answers
-
[IsAscending] := Record.ASCENDING([SetAscending])
IF Record.FIND('+') THEN
IF Record.FINDLAST THEN0 -
zzheng wrote:IF Record.FINDLAST THEN
This is not good for looping. Never use FINDFIRST and FIRSTLAST when looping through table.
And going through table backwards is not good for performance on MS SQL at all...0 -
Hi,
Could you provide a sample coding on the ascending on how to use
[IsAscending] := Record.Ascending ([SetAscending]}
Thanks0 -
Do you has read the help in C/AL Symbol Menu?
YourRecVariable.setcurentkey(YourKeyField(s)); YourRecVariable.ascending(false); if YourRecVariable.findset(false,false) then begin repeat until YourRecVariable.next = 0; end;
But as kine said, it's not good for performance (if you have many recs in your table.
If you need a descending key often and you are under SQL you can also define in SQL Managm. Studio a descending index on your table.
RegardsDo you make it right, it works too!0 -
Hi,
Thanks for the advice.
I only need to read once only and then out of the loop.
Regards0 -
Hi,
E.g in the table I have the following data;
Part-number1 EntryNo1
Part-number2 EntryNo2
Part-number3 EntryNo3
Part-number4 EntryNo4
Part-number1 EntryNo5 <- I need to pick-up this record instead of the one at the top as this is the latest of Part-number1
Part-number5 EntryNo6
As you can see by reading descending order, I can pick up the latest of Part-number1 transaction.
Hope it clarify my intention.
Regards0 -
You mean something like
MyRecVar.SETCURRENTKEY("Part-Number","ENtry No"); MyRecVar.SETRANGE("Part-number","Part-number1"); if MyRecVar.FINDLAST then...0 -
Hi,
Unfortunately, my version do not have "FINDLAST".
Regards0 -
use FIND ('+')NAV - Norton Anti Virus
ERP Consultant (not just Navision) & Navision challenger0 -
Then use find('+').
Do you need to modify the last rec or not? If yes set a locktable before, so the server knows, that you will modify the rec.
RegardsDo you make it right, it works too!0 -
Hi,
No modification is required, just reading only.0 -
then find('+') and before your needed key (if the needed key != primary key)Do you make it right, it works too!0
-
Dear All.
Thanks for the great help.
My problem has being resolved.
Regards0
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

