DeleteData
Permanently removes one or more rows from a data source connected to a KnowledgeKube model.
Syntax
DeleteData( DataSourceName, FilterName, MultipleRowDelete );
Parameters
Parameter Name | Type | Description | Optional? | Default Value |
---|---|---|---|---|
DataSourceName | String | The name of the data connection from which you want to remove data. | No | n/a |
FilterName | String | The name of a filter associated with the chosen data source. Only values matching this filter will be removed from the database. | No | n/a |
MultipleRowDelete | Boolean | Determines whether or not all rows returned by the filter should be deleted. | Yes | 0/False |
Output
If successful, the function will return a string whose value is equal to the number of rows that have been deleted; otherwise, it will return False.
Use Case
The website belonging to a rock band mentioned contains a flaw: fans are able to submit their contact details without providing an e-mail address, resulting in database rows containing no means of getting in contact with the individual.
The original WriteData function has since been amended to prevent this happening again, but as a result of the initial problem, the administrator had to create an expression to delete all rows missing an e-mail address. The syntax of the expression is shown below:
DeleteData("FanDetailsDataConnect", "NoEmailAddress", "True");
The data source name, you will notice, is the same as the one used in the WriteData function. This ensures data is being removed from the same database as it was originally added to.
The NoEmailAddress filter, which had to be added to the FanDetailsDataConnect data source, is given the following conditions to ensure the correct results are fetched and deleted:
Email Is equal to "0"
Lastly, the MultipleRowDelete argument is set as "True" because the administrator wants to delete all invalid rows at once, rather than one at a time.