Single Choice
Easy
QYou have tables named salesTable and salesLine. The salesTable contains the following data:
SalesId RecId
SO0001 1234567
SO0002 1234568
SO0003 1234569
The salesLine table contains the following information:
SalesId RecId
SO0003 2234567
SO0002 2234568
SO0003 2234569
You need to identify the output of the X++ statement:
SalesTable salesTable; SalesLine salesLine; while select salesTable order by salesLine.Recid desc join salesLine where salesLine.salesId == salesTable.salesid { info(strfmt("%1",salesTable.salesId)); }
What should you identify
ID: #9396
Database Manipulation in D365 F&O X++
182 views
Question Info
#9396Q ID
EasyDifficulty
Database Manipulation in D365 F&O X++Topic
Your Answer
Choose the Best Option
Click any option to instantly check if you're correct.
Correct Answer
Explanation
Justification:
- a) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. Therefore, we will not see SO0001 in the output.
- b) The three sales order IDs are correct, but they are in the wrong order because the order of the selects is based on the record ID on the sales line descending - resulting in SO0003 (highest recID on the lines), then SO0002, then finally SO0003 again (lowest recID on the lines).
- c) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. Therefore, we will not see SO0001 in the output. We then specify to order the salesLine table in descending order based on the RecID field. The while loop will print the SalesID line by line in that order, which would yield the result: SO0003 SO0002 SO0003.
- d) The code performs a join between the two tables on SalesID, which means only related records, or records that exists in both locations for that field will be returned. There is only one sales line with SalesID SO0002.
Related Lesson: Data Retrieval
Continue Practice
Share
Share This Question
Challenge a friend or share with your study group.
More from This Topic