Select Statements [AX 2012]
Updated: February 13, 2012
Applies To: Microsoft Dynamics AX 2012 R2, Microsoft Dynamics AX 2012 Feature Pack, Microsoft Dynamics AX 2012
The select statement fetches or manipulates data from the database or both fetches and manipulates data from the database.
All select statements use a table variable to fetch records. This variable must be declared before a select statement can be executed.
The select statement only fetches one record, or field. To fetch additional records, you can use the next statement. The next statement fetches the next record in the table. If you use next without a preceding select command, an error occurs. Do not use next with the firstOnly find option. If you need to traverse a number of records, it is more appropriate to use a while select statement.
Results of a select statement are returned in a table buffer variable. If you use a field list in the select statement, only those fields are available in the table variable. If you use aggregate functions, such as sum or count, the results are returned in the fields that you perform the sum or count over. You can only count, average, or sum the integer and real fields.