Building database queries for model searches
Step-by-step:
In InfoWater Pro, a database query is a time-saving tool that searches one or more fields within one or more database tables for specific information. The records that match the query are entered into a database table, domain, or facility.
Queries are built using Structured Query Language (SQL), but even if you do not know the language, you can use the Query Builder to help construct your searches in the proper SQL syntax. In this exercise, you set up a few DB queries to use with a modeling project.
- Open the appropriate .aprx file in ArcGIS Pro.
- From the ribbon, InfoWater Pro tab, Project panel, click Initialize.
- In the Model Explorer, Operation tab, right-click DB Query and select New.
- In the DB Identification popup, type “8inch, 8 inch pipes” as the DB Query ID.
- Click OK.
- In the DB Query dialog box, expand the Element Type drop-down and select Pipe.
- Click the Query Builder button (arrow icon) to open the Query Builder.
- In the Query Builder, PIPEHYD (pipe hydraulics) tab:
- In the Data Field pane, select PIPEHYD->DIAMETER(in). Note the green check mark appears to indicate the selected field.
- Select the Operator = (equals).
- Enter 8 in the empty field.
- Click Add.
The query statement to select 8-inch pipes is entered in the Query Statement box with the proper SQL format.
- Click Validate.
The query statement is validated. If the query statement is not a valid SQL statement, or if it does not select a single feature, an error is returned. In this case, your query should be valid.
- Click OK to close the Query Validation popup.
- Click OK to close the Query Builder.
Once you have an existing query, like the one you just created, you can use it as a starting point to create a more sophisticated query by cloning it.
- In the DB Query dialog box, select the 8INCH query.
- From the toolbar, click Clone.
- In the DB Identification popup, type “8IN_Z4, 8 inch pipes in Zone 4”as the DB Query ID.
- Click OK.
- In the DB Query dialog box, select the 8IN_Z4 query.
- Click the Query Builder button (arrow icon) to open the Query Builder.
- In the PIPE tab:
- Click in the Query Statement box so that your cursor is to the right of the existing statement (following all zeros in 8.000000).
- Double-click the .AND. operator. The .AND. function appears in the Query Statement box.
- In the Data Field pane, select PIPE->ZONE.
- Select the Operator = (equals).
- Enter 4 in the empty field.
- Click Add.
- Review your Query Statement.
The first query selected all 8-inch pipes, whereas this new query selects all 8-inch pipes in pressure zone 4.
- Click Validate.
The popup should indicate that the query is valid.
- Click OK to close the Query Validation popup.
- Click OK to close the Query Builder.
- Close the DB Query dialog box.
The queries are now available for use with databases, reports, and selections. They are listed in the Model Explorer, Operation tab, under DB Query:
Any number of queries can be stored in this area of the Operation tab, and queries can be shared between projects.