executing a query in navision

jks
Member Posts: 277
Hi all,
Is it possible to retrieve the records from more than one table based on some join condition in navision(without using automation variable)?
Is it possible to retrieve the records from more than one table based on some join condition in navision(without using automation variable)?
0
Comments
-
You can't use SQL if that's what you mean. It is possible to set filters and display rows of data in Navision, if you know how to program it. Let us know what it is exactly what you need and we'll help you along.0
-
What i want is, i have two tables in navision e.g A and B. There is a relation between these two tables.
Now On a form i have placed one button. Inside Onpush trigger of this button i want to retrieve some records by joining these two tables based on some join condition.
For this do i need to create an variable of type automation and then connect to sql server using connection string(ie. provider, datasource, initial catalog etc)?
Isn't there any facility in navision so that i can do the same?
Please help0 -
whether you can perform a join depends on the exact relation of your tables - what exactly the join condition is ?0
-
query is
select * from B where B.userid=A.userid;0 -
B.RESET; B.SETFILTER(userid,'=%1',A.userid); IF B.FIND('-') THEN BEGIN // do some of your stuff here REPEAT // loop through the records UNTIL B.NEXT = 0; END;
0 -
It worked.
Thanks0 -
-
Hi all,
Still one problem is there.
I wrote following c/al code
btable.RESET;
atable.RESET;
btable.SETFILTER(User_Id,'=%1',atable.UserID);
MESSAGE('count is %1',btable.COUNT);
IF btable.FIND('-') THEN BEGIN
REPEAT
MESSAGE('value is %1',btable.Record_Id);
UNTIL btable.NEXT = 0;
END;
Now eventhough atable and btable have matching records on userid, btable.count gives zero i.e btable is empty.
User id is of type text(30) in both the tables. Do i need to do some formating of the text?
Please help.0 -
Ok now i got the solution:
We need to go through a loop.
FOR i:=1 TO btable.COUNT
DO BEGIN
btable.SETFILTER(User_Id,'=%1',atable.UserID);
btable.NEXT;
atable.NEXT;
END;
Thanks0 -
No that's not right. If you want to have an accurate count of the numer of records within your filter, you do use the COUNT command, but not where you put it. Put it AFTER you do FIND, like so:
B.RESET; B.SETFILTER(userid,'=%1',A.userid); IF B.FIND('-') THEN BEGIN // do some of your stuff here MESSAGE('count is %1',B.COUNT); REPEAT // loop through the records UNTIL B.NEXT = 0; END;
THe way you're doing it is COUNT returns the number of records without a filter, and for each on you set another filter. You have to keep the sequence of your statements in order. You can't COUNT the records until after you retrieve them. Similarly, you can't retrieve your records until after you set the correct filters.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions