Running a query
The [highlight txt=’run query’] instruction allows a user to run a query on a Managed Table. The instruction can be configured to check whether the number of rows it modifies satisfies a particular condition.[message type=”warning”]For the purposes of this article we are going to use a simple and fictitious Managed Table named “AirlineInfo”. You will want to replace this Table with one of your own.[/message]
Before we get started
Please further create a ‘Manipulate a file’ or ‘Multiple file manipulations’ action step so that you can add and use instructions.
The Managed Table has the following details and design:
1. Create a ‘Run query’ instruction.
2. Open the Expert SQL Editor by clicking the ‘View/Edit SQL’ hyperlink.
3. In the Expert SQL Editor, you can write the query you want to run, as well as specify the Table you want to run the query on. Here, we will write a query which clears all the data from the ‘AirlineInfo’ Managed Table. Type “DELETE FROM [AirlineInfo]” into the Editor.
4. Alternatively, type “DELETE FROM” into the Editor and then double-click the name of the Table from the ‘Available Tables’ pane. This will cause “[AirlineInfo]” (along with a single white space preceding it) to be inserted in the Editor after “DELETE FROM”.
5. Save the query.
6. Enable the ‘Check the numbers of rows modified to determine if this step was successful’ rule by ticking its box.
7. The first part of the ‘This step is successful if the number of modified rows’ condition is set to ‘Is exactly’ by default. Other options include ‘Is more than’ and ‘Is less than’.
8. Type “3” into the field for the second part of the ‘This step is successful if the number of modified rows’ condition. Alternatively, adjust the ticker next to this field to “3”.
9. Save and run the step.
10. If the step runs successfully, it means that exactly 3 rows were modified in the Table. As we saw earlier, there were only 3 rows in the Table. Therefore, a query which clears the Table must modify exactly 3 rows. After the step finishes running, open the Managed Table. You will see that the Table has no rows remaining: