Updating data using SQLs
Update network data using an SQL query.
Tutorial resources
These downloadable resources will be used to complete this tutorial:
Step-by-step guide
In InfoWorks WS Pro, SQLs can be used to update network data of selected objects. In this exercise, you use SQL to first update the friction factor of pipes made of MDPE, and then a second time to populate a user text field.
- From the Model Group, expand the SQL Model group.
- Double-clicking the SQL Network to open the SQL Network and SQL Control on the GeoPlan.
- Right-click Stored Query Group.
- Select New > Stored Query.
- In the popup, type the Name “MDPE FF”.
- Click OK.
- In the Model Group, double-click the MDPE FF stored query object.
- In the Stored Query window, from the Object Type drop down, select Pipe.
- In the query window, on the first line, type: SELECT FROM Pipe WHERE material = "MDPE";
- On the second line, type: SET k = 0.1
- Click the Test button.
A pop-up appears indicating valid syntax.
- Click OK.
- Click Save to save the SQL.
- Click Run.
The SQL window closes, and the MDPE pipes are now selected in the GeoPlan.
- On the Tools toolbar, click the Properties tool.
- On the GeoPlan, select any of the highlighted pipes.
In the Properties window, notice the CW - k (mm) value changes to 0.1.
- Commit the changes to the database.
To create the second stored query:
- Right-click the Stored Query Group.
- Select New > Stored Query.
- In the popup, type the Name “User Text 1”.
- Click OK.
- In the Model Group, double-click User Text 1.
- In the Stored Query window, in the Object Type drop-down, select Customer Point.
- In the query window type: SET user_text_1 = "Significant Dom User" WHERE spec_consumption > 500
- Click Test.
- Click OK to close the notification.
- Click Save.
- Click Run.
- Once the SQL has completed, in the Windows toolbar, expand the Grid windows drop-down.
- Select New customer points window.
- Scroll to the User Text 1 column.
Note that some customers are now specified as Significant Users.
- Commit the changes to the database.