Single Choice Easy

QIn X++, what is the purpose of the like relational operator, and which of the following statements about its usage is correct?

ID: #24191 Relational operators in X++ Programming Language 78 views
Question Info
#24191Q ID
EasyDifficulty
Relational operators in X++ Programming LanguageTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A

    The like operator compares two numeric values using mathematical equality.

    ✔ ✖
  • B

    The like operator in X++ can use * as a wildcard for one character and ? as a wildcard for zero or more characters.

    ✔ ✖
  • C

    The like operator is evaluated in X++ runtime and always produces the same result across all environments.

    ✔ ✖
  • D

    The like operator returns true if expression1 matches the pattern in expression2, using * for any number of characters and ? for a single character.

    ✔ ✖
Correct Answer

Explanation

In X++, the like relational operator is used to compare patterns in strings. It works similarly to SQL's LIKE clause. Here's a breakdown of why option D is correct:


✔️ like Operator Behavior:

  • It returns true if the first expression (expression1) matches the pattern provided in the second expression (expression2).

  • The second expression can contain wildcards:

    • * (asterisk) → matches zero or more characters.

    • ? (question mark) → matches exactly one character.


📝 Example:


select * from xRefPaths
    where xRefPaths.Path like "\\\\Classes\\\\AddressSelectForm";

  • This will select records where the Path field matches the string \\Classes\\AddressSelectForm.


🔒 Important Notes:

  • like is evaluated by the SQL Server backend, not directly in X++.

    • So results may vary depending on the SQL collation or case-sensitivity of the server.

  • expression2 must not exceed 1000 characters.

  • When matching file paths, each \ must be written as \\ (because \ is an escape character), so you need four backslashes: \\\\.


❌ Why other options are incorrect:

  • A: The like operator is not used for numeric equality.

  • B: * matches zero or more characters, and ? matches one character — this option got the meanings reversed.

  • C: Since like is processed by SQL, its results may vary across environments — especially if SQL settings differ.

Today: 0 answered · 0 correct
Save progress
Free account

Want to remember what you got wrong?

Create a free account in seconds to track your score, revisit mistakes and continue X++ Programming Language where you left off.

  • Save your progress & streak
  • Topic-wise quizzes & scores
  • Bookmark tricky questions
  • Printable MCQ sets
Practice smarterFree account · save progress
Sign up free
No Previous No Next

Share This Question

Challenge a friend or share with your study group.