DELETE

Description

Deletes the rows in TableName specified by Criteria.

Syntax

DELETE FROM TableName WHERE Criteria {USING TransactionObject};

Parameter

Description

TableName

The name of the table from which you want to delete rows.

Criteria

Criteria that specify which rows to delete.

TransactionObject

The name of the transaction object that identifies the database containing the table. This clause is required only for transaction objects other than the default (SQLCA).

Usage

NoteError handling It is good practice to test the success/failure code after executing a DELETE statement. To see if the DELETE was successful, you can test SLQCode for a failure code. However, if nothing matches the WHERE clause and no rows are deleted, SQLCode is still set to zero. To make sure the delete affected at least one row, check the SQLNRows property of the transaction object.

Examples

Example 1

Example 1 This statement deletes rows from the Employee table in the database specified in the default transaction object where Emp_num is less than 100:

DELETE FROM Employee WHERE Emp_num < 100 ;

Example 2

Example 2 These statements delete rows from the Employee table in the database named in the transaction object named Emp_tran where Emp_num is equal to the value entered in the SingleLineEdit sle_number:

int		Emp_num

Emp_num = Integer(sle_number.Text)

DELETE FROM Employee 

		WHERE Employee.Emp_num = :Emp_num ;

The integer Emp_num requires a colon in front of it to indicate it is a variable when it is used in a WHERE clause.