Adding SQL Expressions to TVD Connectors
An SQL expression can be added to a TVD connector, allowing data in a TSDB to be transformed into a value which is appropriate for your model. For example, you may use an expression to apply a rating curve or fill in missing data in the data stream (overriding the usual priority order of the three input data streams). Any SQL expressions will be automatically evaluated during an appropriate Run.
Adding an expression
To add an SQL expression to a TVD connector:
- Ensure that the relevant network is opened in the GeoPlan.
- Select the Grid Windows | New polygon window option from the Window menu or use the button to display the polygon grid window.
- Select the TVD connector tab to display the TVD Connector Data Fields.
- If you are creating a new TVD connector, fill-in the relevant fields in the grid.
- In the Output Expression field, click to display the SQL Expression dialog, which can be used to type in the expression.
- Click Builder >>. This displays a set of buttons representing some of the operators that you can include in the expression.
- Specify the expression in the pane.
- Test the expression as described below.
- Click OK to save the expression and close the dialog.
- Select the corresponding units from the Connector units dropdown list in the TVD connector's data fields.
The TVD Connector - SQL Expression Dialog topic contains a list of the functions and operators which can be included in the expression.
If you are using the editor, then:
You can use the Field dropdown list to select the database fields for the TVD connector that you want to include in the expression. The functions and operators which can be included in the expression are listed in the TVD Connector - SQL Expression Dialog topic.
If the test is unsuccessful, then you may need to edit the expression. If it is successful:
The saved expression is now displayed in the Output expression field.
Testing the expression
To test that the expression contains valid SQL functions and operators:
- Drag a TSDB object from the database tree and drop it on the InfoWorks or SWMM network in the GeoPlan.
- Click Test. The Test SQL dialog is displayed, which, as default, displays the current date and time.
- Use the dropdown calendar to set the start and end date and time to be used in the test. If the Field type is set to Run origin, then you will also need to set the run origin time.
- Click OK.
If the expression is valid, a window containing the results of evaluating the expression, is displayed.
However, if the expression is invalid, a suitable warning message will be displayed in the window.