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
- In the Properties, click inside the field where you want to place a query.
Click the Insert Database Query... toolbar button.
You will see the Insert Database Query dialog box.
- In the Table list, select the table of the AnyLogic built-in database that you want to query.
- From the Value column drop-down list, choose the column of this table that contains the data you need.
- 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 "Credit Specialist" values in employee_type column).
- If required, you can add more select conditions. Add a new section to define one more condition by clicking the button.
- Using Query Constructor, you can construct any queries. In the Choose action list of options, the Constructor proposes a list of most common actions.
- In the Preview field, you will see the constructed query. Queries are constructed in two alternative syntaxes: SQL and Java API (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.
- 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.
How can we improve this article?