Create Delete Query (Classic)

This topic describes how to create a Delete query.

Before you begin

Log in to Operations Hub.

Procedure

  1. In the main navigation menu, select QUERIES.
    The QUERIES workspace appears.

  2. Select Add new query.
    The Create Query window appears.
  3. In the Query name box, enter a name, and then select Create. The name must contain at least one uppercase or lowercase letter.
    The available options for creating the query appear.
  4. In the Description box, enter a value.
  5. In the Query Type box, select Delete.
  6. In the Entity box, select an entity from which you want to delete results.
    The Conditions section appears.

  7. In the Conditions section, select Add, and then enter or select values as specified in the following table.
    Field Name Description
    Required or Optional Select one of the following values:
    • Required: Select this value if the field must always contain a value. For example, suppose you are creating a query to delete account details based on the account number. If you select Required, when the query is run from an application, if an account number is not specified, a message appears, stating that the field is required.
    • Optional: Select this value if the field need not contain a value. For example, suppose you are creating a query to delete account details based on the account number. If you select Optional, when the query is run from an application, if an account number is not specified, the all the records are deleted.
      Important: Exercise extreme caution while selecting Optional for a delete query. If the user does not specify a value, all the data in the entity will be deleted.
    Field Select the entity field based on which you want to create a condition.
    Operator Select the operator that you want to use to compare the value in the text box if Input field is selected.
    Compare with Select one of the following values:
    • Input field: Select this value if you want to allow application users to specify a value that you want to compare with the entity field value. After you select this value, enter a name for the input field in the text box that appears. For example, suppose you want to create a query to delete devices in a specific site, and you want to allow the user to specify the site name. In this case:
      1. Select Input Type, and then enter Site Name.
      2. Modify the page in the application that contains the query to add an input control that allows users to specify the site name. Using the drag-and-drop method, map the input control in the query with the Site Name field.

        When the user enters a value in the Site Name field in the application, and runs the query, all the devices with the specified site name are deleted.

    • Fixed Value: Select this value if you want to specify the value that you want to compare with the entity field value. After you select this value, enter a value in the text box that appears. For example, if you want to delete data received from a device if the temperature exceeds 40 degrees Celsius:
      • In the Field box, select the field that stores temperature.
      • In the Operator box, select >.
      • Select Fixed Value, and then enter 40 in the text box.
    • Query: Select this value to specify a query whose output you want to compare with the field values in the specified entity. After you select this value, a drop-down list box appears in which you can select a query. For example, if there is a query that returns the maximum temperature recorded by a device, you can create a query to delete all the devices that record a temperature higher than the maximum temperature.
  8. Select Save or Save And Exit.
    The query is created.