Using NAV sorting with SQL Views
stiasta
Member Posts: 106
Hello
Problem:
I have found that if i have a Dynamics NAV Table that is connected to a SQL View, there is a problem with sorting.
While sorting on the first table field everything is fine.
If i use a different sorting on something else than the first field, the form keeps changing the lines when i browse from for example a line with first field as 1 to a line with the first field with a 2.
It looks like the view and the dynamics NAV table is having a little fight about what type of sorting is beeing used.
the SQL view wants the sorting to be the primary index, and Dynamics NAV wants sorting on something else.
Does anyone know what to do here?
(If the problem was unclear tell me and ill try to explain further)
Problem:
I have found that if i have a Dynamics NAV Table that is connected to a SQL View, there is a problem with sorting.
While sorting on the first table field everything is fine.
If i use a different sorting on something else than the first field, the form keeps changing the lines when i browse from for example a line with first field as 1 to a line with the first field with a 2.
It looks like the view and the dynamics NAV table is having a little fight about what type of sorting is beeing used.
the SQL view wants the sorting to be the primary index, and Dynamics NAV wants sorting on something else.
Does anyone know what to do here?
(If the problem was unclear tell me and ill try to explain further)
0
Answers
-
I guess it's because the sorting is defined in the view, while NAV treats it as a table.
I think you ought to monitor the queries that NAV sends to SQL. And see if the order by clause is treated correctly within SQL.0 -
PS: @Sog: it is not possible to put an ORDER BY-clause in a view (except when you have a TOP clause).
I think it is because the view is not a real table and browsing the form does some weird things on the SQL server side.
You might try to (manually) create an index on the view to match the key you defined in NAV.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
You can create a key on the linked table object. Just don't maintain it in SQL.There are no bugs - only undocumented features.0
-
Kriki: I dont think the TOP command is allowed either.
I have tried to manually tried to make an index, but the "smarties" that made the view has put a bunch of unions in the view. Unions are not allowed to be used when creating an index on the view.
bbrown: I will try ur suggestion.
I'll keep you posted.0 -
I have tried to create an index without maintaining SQL Index. I have made a screenshot of what happends and some properties that i hope can help with troubleshooting.
On the top image is a print screen from the table when i run it. I have set the sorting on the key that is from the image down and to the left. Shipment date, sales company, reqdeldate (Bokf.dato, salgsselseskap, ReqDelDate). When i go to the top of the page using CTRL+Home and then scroll down using arrow down it starts changing the lines when i hit a tabell id other than 36. In this case when i hit 112 it changes the line.
0 -
In a view, you can use TOP. I know for sure because it was one of the daily questions of www.SQLservercentral.com some time ago.stiasta wrote:Kriki: I dont think the TOP command is allowed either.
Try this:Change your SQLIndex so, that you don't have doubles in it. So to your fields, add the primary key fields at the end.Regards,Alain Krikilion
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!0 -
Aright, i have been able to work around the sorting issue. I have made the forms use help tables(Temporary tables) that is a normal NAV table and not a view. For each time the form is opened the posts are loaded into the table. For views with alot of data, you can set filters on the view and it should go faster to load.
Thank you for your help.0
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
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 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