Queries can be used in C/AL code or in Dynamics NAV charts. They can also be published as web services and thus consumed by external applications. In this section, we will see exactly where queries can be used.
Queries can be accessed from C/AL code. It is a good idea to use queries instead of writing C/AL code involving record variables when you want to read records from multiple tables at the same time.
Executing a query from C/AL code is as simple as defining a variable of type
Query and typing the following sentences:
MyFirstQuery.OPEN; WHILE MyFirstQuery.READ DO OutputData(MyFirstQuery.Item_No, MyFirstQuery.Month_Posting_Date, MyFirstQuery.Sum_Quantity, MyFirstQuery.Source_No, MyFirstQuery.Description, MyFirstQuery.Name, ...