Field select
It is also possible to use a select statement in a lookup on a field. After a select statement that fetched a record in a table, you can write .field name to reference a field in the table.
Below you will find examples of this field select. Note, that these selects must be used in expressions!
X++:
void selectFieldExamples ()
{
// prints the NameRef field from the selected customer (which is CBS)
print (select Custtable order by NameRef).NameRef;
// Uses the balance field from the customer with accountNo 5000 (Pentagon).
// Prints a message.
if ((select Custtable where AccountNo == ).Balance > 500000)
print This customer has a balance above $500,;
}
Notice the difference between the normal select and the field select.
The field select operates directly on a table, whereas the select statement operates on a table variable