The Delete Query

The delete query is typically used to delete the temporary concepts, which are no longer required.

Temporary concepts can be created in the query agent to hold rows of data returned by a query. Such data can then be transformed into an XML string and sent out of the system through a channel, or used to perform computations. When the temporary concepts are no longer needed, use the delete query to delete them.

You can create one concept (to act as a container), with an array of contained concepts to hold each row of results. In a rule function you can use the Concept.serializeUsingDefaults() function to create an XML string with all the results nested within the container. After you send the results out of the system, you can then use a delete query to remove the temporary concepts, which are no longer needed.

See Delete Clause for reference details.

Delete Query Limitations

Because of its limited context of use, this query has various limitations, listed next.

  • The delete query does not use locking. Use the delete query to delete concepts created in the query agent only. The delete action does not go through an RTC. Do not delete concepts that are used in inference agents; doing so may cause issues such as data integrity issues and rule processing issues. Do not attempt to delete concepts that could be accessed at the same time in any other agent as results could be unpredictable.
  • The delete query does not delete contained or referenced concepts. You must delete each contained concept individually.
  • The delete query does not delete child concepts (inherited concepts). For example deleting Customer does not delete RedCustomer and BlueCustomer.
  • Each statement deletes instances of one specified concept type, which is specified in the from clause. You cannot use more than one concept type in the from clause (that is, joins are not supported).
  • Only use the delete query with concepts that use cache only mode. The delete query deletes concepts from the cache only. (Not from Rete network or backing store).
  • Use the delete query only with write behind database write strategy (not cache-aside).
  • The delete clause can be used only in snapshot queries.