DBDelete

Deletes selected rows from a database table. (This function is equivalent to a SQL DELETE statement.)

Function Group Execution Windows Embedded Thin Client
DBDelete Database/ERP Synchronous Supported Supported Supported
Note: This feature emulates SQL (Structured Query Language) database operations. You should be familiar with how SQL commands are formed and executed before you use this feature.

Syntax

DBDelete( strDBConn, strTable, strCondition, "optStrErrorTag" )
strDBConn
The name of the database connection. Connections are configured in the Database/ERP folder.
strTable
The name of the table in the database.
strCondition
A string that specifies which rows of the table to select. This is equivalent to the SQL WHERE clause, and the string should follow the same syntax.
Tip: To delete all rows in the table, make the condition statement a single space (" ").
optStrErrorTag
The name of a String tag that will receive detailed error messages, if errors occur during runtime.
Note: The tag name must be enclosed in quotes, as shown in the syntax diagram, or else the project will try to get the value of the named tag.

This is an optional parameter.

Returned value

Returns the number of rows deleted from the table. In case of error, returns a negative number.

Examples

As used in a Math worksheet:
Tag Name Expression
nRowsDeleted DBDelete( "DB1", "Table1", "Column1 > 1000", "TagError" ) // Deletes all rows in Table1 where the value of Column1 is greater than 1000. The returned value (i.e., the number of rows deleted) is written to TagError.
Tag DBDelete( "DB1", "Table1", " " ) // Deletes all rows of Table1.