Query Constructor

Query Constructor enables users to visually construct queries to the built-in AnyLogic database. You do not need to write SQL queries manually, but just construct the query graphically using controls, and AnyLogic automatically constructs the corresponding query and inserts it in the current expression.

 To insert a query to AnyLogic database

  1. In the Properties, click inside the field where you want to place a query. 
  2. Click the Insert Database Query... toolbar button.
  1. You will see the Insert Database Query dialog box. 
  1. In the Table list, select the table of the AnyLogic built-in database that you want to query.
  2. From the Value column drop-down list, choose the column of this table that contains the data you need. 
  3. In the Choice conditions section below, define the conditions specifying what particular values you want to select from the database table. Select the table column from the drop-down list. In the field below, specify the value that you are searching for in the specified table column (in the example shown in the figure, we are searching for "Senior Trainer" values in employee_type column).  
  4. If required, you can add more select conditions. Add a new section to define one more condition by clicking the  button. 
  5. Using Query Constructor, you can construct any queries. In the Choose action list of options, the Constructor proposes a list of most common actions. 
  6. In the Preview field, you will see the constructed query. Queries are constructed in two alternative syntaxes: SQL and Query DSL. You can use any syntax in your models. Try to switch between syntaxes in the Query Constructor dialog (Syntax option), and compare the resulting queries. This may help you in learning the Query DSL query syntax.
  1. When finished, click OK button. You will see the query inserted in the field that was active when you invoked the Query Constructor wizard. If needed, you can edit the query there.