LibraryEASYProcess Reference Manual 5ProcessesServicesDBWorkshopDelete

Delete Overview

A “Delete” is a service that can be used to run a SQL delete statement.

The benefit of using a Delete to an ExecuteUpdate (another service that can be used to run a delete statement), is that you can enter the desired table and where clause and EASYProcess will build the SQL query for you. This does not require that the developer be very familiar with the SQL query syntax.

Deletes build the query for you given the table and where clause. It follows the pattern:

DELETE FROM [Table] WHERE [Where Clause]

The drawback of the Delete service is that EASYProcess will always use this pattern and requires that the WhereClause be predefined in the Keys. Sometimes a developer would like to build the delete statement based on XSLT functions. A developer also might just feel more comfortable writing the statement themselves which gives more control. In these examples an ExecuteUpdate service might be a better fit.

Since EASYProcess is in charge of maintaining the query pattern in a Delete service, it is able to do things for us, like parameterize the query.

A parameterized query is a query in which placeholders are used for parameters and the parameter values are supplied at execution time. The most important reason to use parameterized queries is to avoid SQL injection attacks. These can happen when a value used in the query comes from the page in user entered data.

Delete Use Examples
DbType"DbType" is the database type. This input is usually loaded from configuration variables.

ConnectionString"ConnectionString" is the connection string to the database. This input is usually loaded from configuration variables.

FileName"FileName" is the name of the database table on which we would like to run the delete.

KeysThe Keys create the WHERE Clause of the query. The keys are concatenated to form the following pattern: [AndOr1][Key1][AndOr2][Key2]... The AndOr values determine the order in which the keys are run. ANDs are always evaluated before ORs. This is similar to the way a BinaryDecision service works. This is the container node that contains all the Key nodes. It does not accept any input, but you can Right-Click to add new Keys (Key#0, Key#1, etc.). Each Key below this node is built into the query as a Where Clause.

KeyOnce EASYProcess builds each Key it will have the following format: [Column] [Operator] [Value]. Whether or not the Value is encased in single quotes is determined by the selected Type. "Key" is a container node which accepts no input but represents a single Key that can contain information related to a key. Each Key node is indexed.

AndOr"AndOr" is used when we are dealing with more than one key. Valid values are "And" and "Or". If this value is left blank it defaults to "And". The AndOr values determine the order in which the keys are run. ANDs are always evaluated before ORs.

ColumnThe column to be referenced from the table in the query.

OperatorThe operator to be used in the Key.

TypeThis is the data type of the "Value". This determines whether the "Value" is encased in single quotes.

Valuethe value which we will compare against the "Column" of the this Key.

CommandTimeout"CommandTimeout" is the timeout for query in milliseconds. After this time the service cancels execution of the query and throws an error.

NoOfRecordsDeletedA numeric value is returned when the service completes that indicates the number of records deleted.
QueryThe exact delete statement used to delete the records.

Delete Use Examples

Basic Use Example

In this example we have a Delete service named “DeletePriceCache”. It has been configured to delete from a table (EC_User_Price_Cache) where the column in this table (CustomerId) is equal to the variable we have entered.

Let’s say that variable is returning a value of ‘4242’. Here is the query which will run:

DELETE FROM EC_User_Price_Cache WHERE CustomerId = '4242'

The Delete service will only return the query that ran and the number of result that were deleted. Here is an example of what the output will return. Notice EASYProcess has done the parameterization for us.

Powered by EASYProcess (© 2022 K-Rise Systems, Inc).