Skip to main content

Querying data

Altogic does not use a separate data query syntax (e.g., SQL) for selecting/filtering data from the database. You can use the same expression syntax to query your data. The following database nodes require a select query to fetch/filter data.

Before writing down your data query, you first need to specify the Retrieved object model (1) that the query will be executed to filter its objects. The Select query (2) property is used to specify the required data query logic. When you click/tap on the f(x) in the "Select Query" property of any of the above nodes, you will be directed to the Expression editor to define your query expression. Additionally, if the selected object model has object references, you can select the Lookup fields (3) and use their values in your query expression.

 Node properties - Key elements used in querying data

The query expression editor is similar to the overall expression editor. The key difference is the "this" tab which provides access to model fields of the queried object model. Other tabs in the expression editor provide additional input data and access to built-in functions.

Query expression editor
  1. Queried object model - Provides access to the fields of the model which you will be querying its data.
  2. Additional input model objects - Each query expression editor can have different model objects as input. The service node might have multiple input link points. For each input link point (excluding trigger link points), you will have a corresponding model object entry in the query expression editor. We have one model object used in the above example when defining the expression named "inputObject". When you click on the input model objects tab, the contents area is updated with the right model fields structure.
  3. Service parameters - Particularly for expressions defined in service designs, you can access all the input parameters provided by the start node of the service using this tab. It basically provides quick access to service input parameters.
  4. Functions - Through the functions tab, you can use built-in functions in your expressions.
  5. Contents - This is the main area of the expression editor where contents of each selected tab (e.g., model object, service parameters, functions) are displayed. You can either double click on a value or drag & drop it to the edit area to use it in your data query expression.
  6. Edit area - The text editor where you define your query expression.

Not all functions can be used in query expressions. The functions reference provides detailed information about each built-in function and whether the function can be used in query expressions or not.

One important aspect of the queries is that if you have lookup fields, the available fields of the queried object model will change. So, for example, assuming we have a salesOrder model with an object reference to a product model object, depending on whether we lookup the product filed or not, the contents of the query expression editor change. If we look up the product object, we can access its field values and use them in our expressions.

Content area with and without lookup to product object example

Lookups negatively impact the performance of your database queries. For faster service executions, try to minimize their use.